diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 054901d..9c7c76c 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -16,6 +16,6 @@ jobs: node-version: '20.x' registry-url: 'https://registry.npmjs.org' - run: bun install - - run: npm publish --provenance --access public + - run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/CapsLockX.ahk b/CapsLockX.ahk index f02214f..78b283b 100644 --- a/CapsLockX.ahk +++ b/CapsLockX.ahk @@ -35,11 +35,11 @@ global 显示加载提示 := 1 global loadingTips := "" ; 对 核心模块 进行 编码清洗 -清洗为_UTF8_WITH_BOM_型编码(CLX_CoreDir "/CapsLockX-Config.ahk") -清洗为_UTF8_WITH_BOM_型编码(CLX_CoreDir "/CapsLockX-Core.ahk") -清洗为_UTF8_WITH_BOM_型编码(CLX_CoreDir "/CapsLockX-RunSilent.ahk") -清洗为_UTF8_WITH_BOM_型编码(CLX_CoreDir "/CapsLockX-Update.ahk") -清洗为_UTF8_WITH_BOM_型编码(CLX_CoreDir "/CapsLockX-i18n.ahk") +CONVERT_FILE_TO_UTF8_WITH_BOM_ENCODING(CLX_CoreDir "/CapsLockX-Config.ahk") +CONVERT_FILE_TO_UTF8_WITH_BOM_ENCODING(CLX_CoreDir "/CapsLockX-Core.ahk") +CONVERT_FILE_TO_UTF8_WITH_BOM_ENCODING(CLX_CoreDir "/CapsLockX-RunSilent.ahk") +CONVERT_FILE_TO_UTF8_WITH_BOM_ENCODING(CLX_CoreDir "/CapsLockX-Update.ahk") +CONVERT_FILE_TO_UTF8_WITH_BOM_ENCODING(CLX_CoreDir "/CapsLockX-i18n.ahk") ; 复制用户模块 ; TODO FIX:如果CLX已经开了的话,这一步会触发重启,这可能会导致一些文件冲突的BUG…… @@ -210,7 +210,7 @@ Return 加载提示追加(t("跳过模块:") . i . " " . 模块名称) } else { ; 这里引入模块代码 - 清洗为_UTF8_WITH_BOM_型编码(CLX_ModuleDir "/" 模块文件) + CONVERT_FILE_TO_UTF8_WITH_BOM_ENCODING(CLX_ModuleDir "/" 模块文件) ; 导入模块 模块初始化代码 .= "GoSub CLX_ModuleSetup_" i "`n" 模块导入代码 .= "`n" "#If" "`n" "`n" diff --git a/Core/CapsLockX-i18n.ahk b/Core/CapsLockX-i18n.ahk index 2db43f7..c6da404 100644 --- a/Core/CapsLockX-i18n.ahk +++ b/Core/CapsLockX-i18n.ahk @@ -2,7 +2,7 @@ global CLX_i18nConfigPath := "Core/lang.ini" global CLX_i18n_newTranslated := "Core/lang.ini" -清洗为_UTF16_WITH_BOM_型编码(CLX_i18nConfigPath) +CONVERT_FILE_TO_UTF16_WITH_BOM_ENCODING(CLX_i18nConfigPath) ; - [Language Codes \| AutoHotkey v1]( https://www.autohotkey.com/docs/v1/misc/Languages.htm ) LCID_7804 := "Chinese" ; zh @@ -82,21 +82,25 @@ i18n_translated(lang, key) return translated } - question := "TASK: translate to " . lang . ",dont explain, just translate`n" . "ORIGIN TEXT: " . key + question := ">>> ROLE: Act as translator, input text is between '>>> TEXT BEGIN' and '>>> TEXT END', output transcript, no explain" . "`n" + question .= ">>> TASK: translate to " . lang . "`n" + question .= ">>> TEXT BEGIN" . "`n" + question .= key . "`n" + question .= ">>> TEXT END" . "`n" global brainstorm_origin if (!brainstorm_origin) { brainstorm_origin := CLX_Config("BrainStorm", "Website", "https://brainstorm.snomiao.com") } - endpoint := brainstorm_origin . "/ai/chat?ret=text" + endpoint := brainstorm_origin . "/ai/translator?ret=text" xhr := ComObjCreate("Msxml2.XMLHTTP") xhr.Open("POST", endpoint) xhr.setRequestHeader("Authorization", "Bearer " . brainstormApiKey) - xhr.onreadystatechange := Func("brainstorm_translatePostResult").Bind(lang, key, xhr) + xhr.onreadystatechange := Func("i18n_brainstorm_translatePostResult").Bind(lang, key, xhr) xhr.Send(question) return "…[" . key . "]" } -brainstorm_translatePostResult(lang, key, xhr) +i18n_brainstorm_translatePostResult(lang, key, xhr) { if (xhr.readyState != 4) return @@ -107,7 +111,7 @@ brainstorm_translatePostResult(lang, key, xhr) ; ignore 500 error return } - MsgBox, % xhr.status . " " xhr.responseText . " " . ("未知错误 / Unknown Error") + MsgBox, % xhr.status . " " . xhr.responseText . " " . ("未知错误 / Unknown Error") return } global transcript := xhr.responseText @@ -160,7 +164,7 @@ CLX_i18n_ConfigSet(field, varName, value) global CLX_ConfigDir IniSave(encodedValue, CLX_ConfigDir . "/" . field . ".ini", field, encodedKey) - ; 清洗为_UTF16_WITH_BOM_型编码(CLX_ConfigDir) + ; CONVERT_FILE_TO_UTF16_WITH_BOM_ENCODING(CLX_ConfigDir) } CLX_i18n_ConfigEnocde(str){ str := RegExReplace(str, "\\", "\\") diff --git a/Core/CapslockX-Config.ahk b/Core/CapslockX-Config.ahk index 99cde5b..c294f7e 100644 --- a/Core/CapslockX-Config.ahk +++ b/Core/CapslockX-Config.ahk @@ -29,9 +29,9 @@ if (!CLX_ConfigPath) { ; 配置文件编码清洗 global CLX_ConfigChangedTickCount CLX_ConfigChangedTickCount := A_TickCount -; msgbox 清洗为_UTF16_WITH_BOM_型编码1 -清洗为_UTF16_WITH_BOM_型编码(CLX_ConfigPath) -; msgbox 清洗为_UTF16_WITH_BOM_型编码2 +; msgbox CONVERT_FILE_TO_UTF16_WITH_BOM_ENCODING1 +CONVERT_FILE_TO_UTF16_WITH_BOM_ENCODING(CLX_ConfigPath) +; msgbox CONVERT_FILE_TO_UTF16_WITH_BOM_ENCODING2 CLX_Config("_NOTICE_", "ENCODING_USING", "UTF16_LE", "") @@ -110,7 +110,8 @@ CLX_Config(field, varName, defaultValue, comment := "") return content } -清洗为_UTF16_WITH_BOM_型编码(path){ +; convert file to UTF16 (which is required by ReadINI in ahk) +CONVERT_FILE_TO_UTF16_WITH_BOM_ENCODING(path){ ConfigLock("UTF16_WITH_BOM 文件编码清洗:" path) if (FileGetFormat(path) === "UTF-16 LE") { ConfigUnlock() @@ -150,7 +151,7 @@ FileGetFormat(file) Return StrLen(f) = size ? "ANSI" : "UTF-8 no BOM" } -清洗为_UTF8_WITH_BOM_型编码(path){ +CONVERT_FILE_TO_UTF8_WITH_BOM_ENCODING(path){ ConfigLock("UTF8_WITH_BOM 文件编码清洗:" path) if (FileGetFormat(path) === "UTF-8") { ConfigUnlock() @@ -164,14 +165,14 @@ FileGetFormat(file) ConfigUnlock() } -ConfigLock(名义:="") +ConfigLock(reason:="") { k:= 0 while (FileExist(CLX_ConfigPath ".lock")) { k := k + 1 if ( k > 10 ) { - FileRead 上次名义, % CLX_ConfigPath ".lock" - ; MsgBox, 程序退出, %名义% 配置写入失败,配置文件被意外锁定,上次锁定名义为 %上次名义% + FileRead lastReason, % CLX_ConfigPath ".lock" + ; MsgBox, 程序退出, %reason% 配置写入失败,配置文件被意外锁定,上次锁定名义为 %lastReason% ConfigUnlock() Reload ExitApp @@ -181,7 +182,7 @@ ConfigLock(名义:="") } CLX_DontReload := 1 - FileAppend %名义%, % CLX_ConfigPath ".lock" + FileAppend %reason%, % CLX_ConfigPath ".lock" return True } ConfigUnlock() diff --git a/Core/lang.ini b/Core/lang.ini index 4c30440..ac58264 100644 Binary files a/Core/lang.ini and b/Core/lang.ini differ diff --git a/DevTools/setup.iss b/DevTools/setup.iss new file mode 100644 index 0000000..f977e1c --- /dev/null +++ b/DevTools/setup.iss @@ -0,0 +1,28 @@ +; -- setup.iss -- +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES! + +[Setup] +AppName=CapsLockX +AppVersion=1.34.6 +WizardStyle=modern +; DefaultDirName={autopf}\CapsLockX +DefaultDirName={userappdata}\CapsLockX +DefaultGroupName=CapsLockX +UninstallDisplayIcon={app}\CapsLockX.exe +Compression=lzma2 +SolidCompression=yes +OutputDir=userdocs:Inno Setup CapsLockX Output + +[Files] +Source: "README.md"; DestDir: "{app}"; Flags: isreadme +Source: "CapsLockX.exe"; DestDir: "{app}" +Source: "CapsLockX.ahk"; DestDir: "{app}" +Source: "Core\*"; DestDir: "{app}" +Source: "Data\*"; DestDir: "{app}" +Source: "docs\*"; DestDir: "{app}" +Source: "Lib\*"; DestDir: "{app}" +Source: "Modules\*"; DestDir: "{app}" +Source: "Tools\*"; DestDir: "{app}" + +[Icons] +Name: "{group}\CapsLockX"; Filename: "{app}\CapsLockX.exe" diff --git a/Modules/App-ScreenRotate.ahk b/Modules/App-ScreenRotate.ahk deleted file mode 100644 index 4d3676c..0000000 --- a/Modules/App-ScreenRotate.ahk +++ /dev/null @@ -1,195 +0,0 @@ -; placeholder -; ; -; ; ; SnowstarCyan_Monitor_Libriay -; ; ; Updates: -; ; ; 2016y 01m 28d -; ; ; Created By Snowstar (SnowstarCyan@gmail.com) -; ; ; For rotate my screens to play computer games on bed at winter. ~(≧▽≦)~ -; ; -; ; API Functions for Reference -; ; ChangeDisplaySettingsA := DllCall("User32.dll\ChangeDisplaySettingsA", "Ptr", &lpDevMode, "Int", dwflags) -; ; ChangeDisplaySettingsExA := DllCall("User32.dll\ChangeDisplaySettingsExA", "Str", DeviceName, "Ptr", &lpDevMode, "Ptr", HWND, "Int", dwflags, "Ptr", lParam) -; ; EnumDisplaySettingsA := DllCall("User32.dll\EnumDisplaySettingsA", "Str", DeviceName, "Int", iModeNum, "Ptr", &lpDevMode) -; ; EnumDisplayDevicesA := DllCall("User32.dll\EnumDisplayDevicesA", "Str", DeviceName, "Int", iDevNum, "Ptr", &lpDevMode, "Int", dwflags) - -; ; MsgBox % "EnumDisplayDevicesA" . EnumDisplayDevicesA -; ; -; ; Monitor.RotateOneMonitor(90) -; ; len := GetDisplayDevices().length - -; ; MsgBox, % "len" . len - -; class DEVMODE_DISPLAY_DEVICE { -; __New() { -; this.dmSize := 156 -; this.dmFields := 0 -; } -; __Set(key, value) { -; if (key == "position_x") || (key == "position_y") -; this.dmPosition := &value -; else -; this[key] := value -; } -; } - -; class DISPLAY_DEVICE { -; __New() { -; this.cb := 424 -; } -; } - -; ; _DISPLAY_DEVICE_ATTACHED_TO_DESKTOP := 1 - -; Monitor := {} -; Monitor.MapByFunc := Func("MapByFunc") -; Monitor.Merge := Func("Merge") -; Monitor.GetDeviceMode := Func("GetDeviceMode") -; Monitor.GetDeviceName := Func("GetDeviceName") -; Monitor.RotateDevMode90 := Func("RotateDevMode90") -; Monitor.ApplyDevMode := Func("ApplyDevMode") -; Monitor.GetDisplayDevices := Func("GetDisplayDevices") -; Monitor.RotateOneMonitor := Func("RotateOneMonitor") -; Monitor.RotateAllMonitor := Func("RotateAllMonitor") - -; Monitor.RotateOneMonitor(90) -; MsgBox, % "len: " . GetMonitorCount() - -; ; len := GetDisplayDevices().length - - -; MapByFunc(tab, func, params*) { -; newtab := {} -; for k, v in tab { -; newtab[k] := %func%(v, params*) -; } -; return newtab -; } - -; Merge(tab1, tab2) { -; newtab := {} -; for k, v in tab1 { -; if (tab1[k] && tab2[k]) { -; newtab.push([tab1[k], tab2[k]]) -; } -; } -; return newtab -; } - -; GetDeviceMode(deviceName) { -; devMode := new DEVMODE_DISPLAY_DEVICE() -; success := DllCall("User32.dll\EnumDisplaySettingsA", "Str", deviceName, "Int", -1, "Ptr", devMode) -; if (!success) { -; MsgBox Can't get current settings. -; return null -; } -; return devMode -; } - -; GetDeviceName(device) { -; return device.DeviceName -; } - -; RotateDevMode90(devMode, devModeMain) { -; New_Orientation := Mod(devMode.displayOrientation + 1, 4) - -; ; Calculate new positions -; New_position_x := (devModeMain ? devModeMain.pelsHeight - devMode.position_y - devMode.pelsHeight : devMode.position_y) -; New_position_y := devMode.position_x -; New_pelsWidth := devMode.pelsHeight -; New_pelsHeight := devMode.pelsWidth - -; devMode.position_x := New_position_x -; devMode.position_y := New_position_y -; devMode.pelsWidth := New_pelsWidth -; devMode.pelsHeight := New_pelsHeight -; devMode.displayOrientation := New_Orientation - -; return devMode -; } - -; ApplyDevMode(deviceToDevmode) { -; deviceName := deviceToDevmode[1] -; devMode := deviceToDevmode[2] -; success := DllCall("User32.dll\ChangeDisplaySettingsExA", "Str", deviceName, "Ptr", devMode, "Ptr", 0, "Int", 0, "Ptr", 0) -; return success -; } - -; GetDisplayDevices() { -; lsDisplayDevice := [] -; iDevNum := 0 -; Loop { -; lpDisplayDevice := new DISPLAY_DEVICE() -; if !DllCall("User32.dll\EnumDisplayDevicesA", "ptr", 0, "Int", iDevNum, "Ptr", lpDisplayDevice, "Int", 0) { -; break -; } -; if (lpDisplayDevice.StateFlags & _DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) { -; lsDisplayDevice.Push(lpDisplayDevice) -; } -; MsgBox % "num" . iDevNum -; iDevNum++ -; } -; return lsDisplayDevice -; } - -; RotateOneMonitor(degree, abs := false, deviceName := "") { -; devMode := Monitor.GetDeviceMode(deviceName) -; if !devMode { -; return -; } - -; rotCount := Mod((Floor(degree / 90)), 4) -; if abs { -; rotCount := Mod(rotCount - devMode.displayOrientation, 4) -; } -; Loop %rotCount% { -; devMode := Monitor.RotateDevMode90(devMode) -; } - -; success := Monitor.ApplyDevMode([deviceName, devMode]) -; return success -; } - -; RotateAllMonitor(degree, abs := false) { -; lsDevice := Monitor.GetDisplayDevices() -; lsDeviceName := Monitor.MapByFunc(lsDevice, Monitor.GetDeviceName) - -; lsDevMode := Monitor.MapByFunc(lsDeviceName, Monitor.GetDeviceMode) -; if !lsDevMode[1] { -; MsgBox You can't rotate the `non-screen` -; return -; } - -; rotCount := Mod((Floor(degree / 90)), 4) -; if abs { -; rotCount := Mod(rotCount - lsDevMode[1].displayOrientation, 4) -; } -; Loop %rotCount% { -; lsDevMode := Monitor.MapByFunc(lsDevMode, Monitor.RotateDevMode90, lsDevMode[1]) -; } - -; lsDeviceToDevmode := Monitor.Merge(lsDeviceName, lsDevMode) -; lsSuccess := Monitor.MapByFunc(lsDeviceToDevmode, Monitor.ApplyDevMode) -; return lsSuccess -; } - -; ; return - -; ; #^p:: ScreenRotate() -; ; ScreenRotate(){ - -; ; ; Unit Test -; ; Monitor.RotateOneMonitor(90) -; ; ; Sleep, 3000 -; ; ; Monitor.RotateOneMonitor(0, true) -; ; ; Sleep, 3000 -; ; ; Monitor.RotateAllMonitor(-90) -; ; ; Sleep, 3000 -; ; ; Monitor.RotateAllMonitor(180) -; ; ; Sleep, 3000 -; ; ; Monitor.RotateAllMonitor(90, true) -; ; ; Sleep, 3000 -; ; ; Monitor.RotateAllMonitor(-90, true) -; ; ; Sleep, 3000 -; ; ; Monitor.RotateAllMonitor(0, true) -; ; ; Sleep, 3000 -; ; } diff --git a/Modules/App-ScreenRotate.md b/Modules/App-ScreenRotate.md deleted file mode 100644 index f8db681..0000000 --- a/Modules/App-ScreenRotate.md +++ /dev/null @@ -1,8 +0,0 @@ -# Screen Rotate - -使用方法 - -1. OneNote 2016 打开一个窗口,标题写成这样 "剪贴板收集"。 -2. 然后再用 Ctrl + C 复制东西的时候就会自动记到 OneNote 里 -3. 如图 - ![插件-OneNote剪贴板收集器.gif](./插件-OneNote剪贴板收集器.gif) diff --git a/Modules/CLX-Brainstorm.ahk b/Modules/CLX-Brainstorm.ahk index 6a0dbd8..d4718bf 100644 --- a/Modules/CLX-Brainstorm.ahk +++ b/Modules/CLX-Brainstorm.ahk @@ -33,6 +33,8 @@ return #if brainstorming esc:: stop_brainstorm() + `:: stop_brainstorm() + #if diff --git a/README.md b/README.md index c31bfcc..13edbe7 100644 --- a/README.md +++ b/README.md @@ -276,17 +276,6 @@ Enhance keyboard operations for OneNote 2016 - 2019, conveniently use the keyboa 1. When making a journal entry, first add a date tag to the note's title with `Alt + T` (for future search), then use `Win + Shift + N` globally to search for all notes with today's tag in OneNote, conveniently retrieving your today's: romance journal, training log, daily - - -### Screen Rotate - -Instructions - -1. Open a window in OneNote 2016 and title it "Clipboard Collection." -2. When you copy something using Ctrl + C, it will automatically be recorded in OneNote. -3. As shown in the image - ![Plugin - OneNote Clipboard Collector.gif](./docs/media/插件-OneNote剪贴板收集器.gif) - ### iFlytek Input Method Floating Window Plugin