├── .gitattributes ├── .gitignore ├── CapsLock+.ahk ├── LICENSE ├── README_zh-CN.md ├── capslock+icon.ico ├── language ├── English.ahk ├── Simplified_Chinese.ahk ├── Traditional_Chinese.ahk └── lang_func.ahk ├── lib ├── lib_bindWins.ahk ├── lib_clQ.ahk ├── lib_clTab.ahk ├── lib_functions.ahk ├── lib_init.ahk ├── lib_jsEval.ahk ├── lib_json.ahk ├── lib_keysFunction.ahk ├── lib_keysSet.ahk ├── lib_loadAnimation.ahk ├── lib_mathBoard.ahk ├── lib_mouseSpeed.ahk ├── lib_settings.ahk ├── lib_winJump.ahk ├── lib_winTransparent.ahk ├── lib_ydTrans.ahk └── sha256.ahk ├── loadScript ├── debug.html └── scriptDemo.js ├── readme.md └── userAHK ├── demo.ahk ├── main.ahk └── translate.ahk /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | * text eol=crlf 4 | 5 | 6 | *.ico binary 7 | 8 | # Custom for Visual Studio 9 | *.cs diff=csharp 10 | 11 | # Standard to msysgit 12 | *.doc diff=astextplain 13 | *.DOC diff=astextplain 14 | *.docx diff=astextplain 15 | *.DOCX diff=astextplain 16 | *.dot diff=astextplain 17 | *.DOT diff=astextplain 18 | *.pdf diff=astextplain 19 | *.PDF diff=astextplain 20 | *.rtf diff=astextplain 21 | *.RTF diff=astextplain 22 | # 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ========================= 2 | # Add myself 3 | # ========================= 4 | 5 | /CapsLock+run 6 | /CapsLock icon 7 | /old_version 8 | /img 9 | /clgif 10 | /.vscode 11 | /wb/node_modules 12 | # ignore files 13 | CapsLock+hotString.ini 14 | CapsLock+winsInfo.ini 15 | CapsLock+settings.ini 16 | CapsLock+winsInfosRecorder.ini 17 | CapsLock+settingsDemo.ini 18 | youdaoApiKey.ahk 19 | gain.md 20 | 21 | # Windows image file caches 22 | Thumbs.db 23 | ehthumbs.db 24 | 25 | # Folder config file 26 | Desktop.ini 27 | 28 | # Recycle Bin used on file shares 29 | $RECYCLE.BIN/ 30 | 31 | # Windows Installer files 32 | *.cab 33 | *.msi 34 | *.msm 35 | *.msp 36 | 37 | # Windows shortcuts 38 | *.lnk 39 | 40 | # ========================= 41 | # Operating System Files 42 | # ========================= 43 | 44 | # OSX 45 | # ========================= 46 | 47 | .DS_Store 48 | .AppleDouble 49 | .LSOverride 50 | 51 | # Thumbnails 52 | ._* 53 | 54 | # Files that might appear on external disk 55 | .Spotlight-V100 56 | .Trashes 57 | 58 | # Directories potentially created on remote AFP share 59 | .AppleDB 60 | .AppleDesktop 61 | Network Trash Folder 62 | Temporary Items 63 | .apdisk 64 | -------------------------------------------------------------------------------- /CapsLock+.ahk: -------------------------------------------------------------------------------- 1 | #SingleInstance force 2 | 3 | ; If the script is not elevated, relaunch as administrator and kill current instance: 4 | full_command_line := DllCall("GetCommandLine", "str") 5 | if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)")) 6 | { 7 | try ; leads to having the script re-launching itself as administrator 8 | { 9 | if A_IsCompiled 10 | Run *RunAs "%A_ScriptFullPath%" /restart 11 | else 12 | Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%" 13 | } 14 | ExitApp 15 | } 16 | 17 | IfExist, capslock+icon.ico 18 | { 19 | ;freezing icon 20 | menu, TRAY, Icon, capslock+icon.ico, , 1 21 | } 22 | Menu, Tray, Icon,,, 1 23 | 24 | SetStoreCapslockMode, Off 25 | 26 | global CLversion:="Version: 3.3.0.0 | 2023-10-22`n`nCopyright Junkai Chen" 27 | 28 | global cClipboardAll ;capslock+ clipboard 29 | global caClipboardAll ;capslock+alt clipboard 30 | global sClipboardAll ;system clipboard 31 | global whichClipboardNow ;0 system clipboard; 1 capslock+ clipboard; 2 capslock+alt clipboard 32 | ; global clipSaveArr=[] 33 | allowRunOnClipboardChange:=true 34 | 35 | 36 | #Include lib 37 | #Include lib_init.ahk ;The beginning of all things 38 | 39 | ; language 40 | #include ..\language\lang_func.ahk 41 | #include ..\language\Simplified_Chinese.ahk 42 | #include ..\language\English.ahk 43 | ; #include ..\language\Traditional_Chinese.ahk 44 | ; /language 45 | 46 | #include lib_keysFunction.ahk 47 | #include lib_keysSet.ahk 48 | ; #include lib_ahkExec.ahk 49 | ; #include lib_scriptDemo.ahk 50 | ; #include lib_fileMethods.ahk 51 | 52 | #include lib_settings.ahk ;get the settings from capslock+settings.ini 53 | #Include lib_clQ.ahk ;capslock+Q 54 | #Include lib_ydTrans.ahk ;capslock+T translate 55 | #Include lib_clTab.ahk 56 | #Include lib_functions.ahk ;public functions 57 | #Include lib_bindWins.ahk ;capslock+` 1~8, windows bind 58 | #Include lib_winJump.ahk 59 | #Include lib_winTransparent.ahk 60 | #Include lib_mouseSpeed.ahk 61 | #Include lib_mathBoard.ahk 62 | #include lib_loadAnimation.ahk 63 | 64 | 65 | ;change dir 66 | #include ..\userAHK 67 | #include *i main.ahk 68 | 69 | #MaxHotkeysPerInterval 500 70 | #NoEnv 71 | ; #WinActivateForce 72 | Process Priority,,High 73 | 74 | 75 | start: 76 | 77 | ;-----------------START----------------- 78 | global ctrlZ, CapsLock2, CapsLock 79 | 80 | Capslock:: 81 | ;ctrlZ: Capslock+Z undo / redo flag 82 | ;Capslock: Capslock 键状态标记,按下是1,松开是0 83 | ;Capslock2: 是否使用过 Capslock+ 功能标记,使用过会清除这个变量 84 | ctrlZ:=CapsLock2:=CapsLock:=1 85 | 86 | SetTimer, setCapsLock2, -300 ; 300ms 犹豫操作时间 87 | 88 | settimer, changeMouseSpeed, 50 ;暂时修改鼠标速度 89 | 90 | KeyWait, Capslock 91 | CapsLock:="" ;Capslock最优先置空,来关闭 Capslock+ 功能的触发 92 | if CapsLock2 93 | { 94 | if keyset.press_caps 95 | { 96 | try 97 | runFunc(keyset.press_caps) 98 | } 99 | else 100 | { 101 | SetCapsLockState, % GetKeyState("CapsLock","T") ? "Off" : "On" 102 | } 103 | ; sendinput, {esc} 104 | } 105 | CapsLock2:="" 106 | 107 | ; 108 | if(winTapedX!=-1) 109 | { 110 | winsSort(winTapedX) 111 | } 112 | return 113 | 114 | 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /README_zh-CN.md: -------------------------------------------------------------------------------- 1 | [English](readme.md) | 中文 2 | 3 | --- 4 | 5 | master 分支:v3.0+ 6 | 7 | v2 分支:v2.x 8 | 9 | [官网(说明文档)](https://capslox.com/capslock-plus/) 10 | 11 | 12 | ## 怎么运行Capslock+的源码? 13 | 1. 下载 [AutoHotkey (v1.1.+)](http://www.ahkscript.org/),并安装。 14 | 2. 从 GitHub 下载 Capslock+ 源码。 15 | 3. 运行`Capslock+.ahk`。 16 | 17 | ## 怎么修改某个热键为自定义功能? 18 | 1. 在 `/userAHK/main.ahk`,编写自定义的按键功能函数,例如 `keyFunc_example1` 19 | 2. 在 `CapsLock+settings.ini` 的 [Keys] 字段下添加设置按键设置,例如: 20 | `caps_f7=keyFunc_example1` 21 | 3. 保存后重载 Capslock+ (Capslock+F5) 22 | 4. 之后再按下 `CapsLock+F7` 就可以触发该函数。 23 | 24 | * 为了避免按键设置会调到内部函数,所以规定了所有函数以`keyfunc_`开头 25 | 26 | 下面提供一个例子: 27 | 28 | ### 把 Capslock+Q 替换成 Listary 29 | 有同学跟我吐槽`qbar`太弱鸡,让我参考`WOX`,`Listary`等把`qbar`写得厉害一点,但我觉得`qbar`就是够用就好,如果有更高的需求那就直接用它们代替`qbar`吧。以`Listary`为例子,`Listary`虽然强大,但是个人觉得跟`qbar`比有两个不足的地方: 30 | 31 | 1. 我觉得 Listary 的默认热键不如 `Capslock+Q` 顺手 32 | 2. 不能将选中的文字直接填入 33 | 34 | 那我们可以这样做来解决这两个问题: 35 | 36 | 1. 把下面代码复制到`/userAHK/main.ahk`里: 37 | ```ahk 38 | keyfunc_listary(){ 39 | ; 获取选中的文字 40 | selText:=getSelText() 41 | 42 | ; 发送 win+F 按键(Listary默认的呼出快捷键),呼出Listary 43 | sendinput, #{f} 44 | 45 | ; 等待 Listary 输入框打开 46 | winwait, ahk_exe Listary.exe, , 0.5 47 | 48 | ; 如果有选中文字的话 49 | if(selText){ 50 | ; 在选中的字前面加上"gg ",使用 google 搜索 51 | selText:="gg " . selText 52 | 53 | ; 输出刚才复制的文字,并按一下`home`键将光标移到开头,以方便加入其它关键词 54 | sendinput, %selText%{home} 55 | } 56 | } 57 | ``` 58 | 59 | 2. 在`CapsLock+settings.ini` `[keys]`设置:`caps_q=keyfunc_listary()`,保存,按下`CapsLock+F5`重载,搞定。 60 | 61 | ## 怎么修改原有的功能? 62 | `CapsLock+.ahk`是入口文件,其他所有依赖文件都扔`/lib`里了,各文件说明如下: 63 | 64 | |文件|说明| 65 | |:---|:---| 66 | |lib_bindWins.ahk|窗口绑定| 67 | |lib_clQ.ahk|qbar| 68 | |lib_clTab.ahk|CapsLock+Tab| 69 | |lib_functions.ahk|一些依赖函数| 70 | |lib_init.ahk|各种初始化从这里开始| 71 | |lib_jsEval.ahk|调用ie引擎实现的计算功能,计算板和Caps+Tab的计算功能都用到| 72 | |lib_json.ahk|json库| 73 | |lib_keysFunction.ahk|几乎所有按键功能都在这实现| 74 | |lib_keysSet.ahk|热键布局| 75 | |lib_language.ahk|程序用到的字符串放到这| 76 | |lib_loadAnimation.ahk|程序加载动画| 77 | |lib_mathBoard.ahk|计算板| 78 | |lib_mouseSpeed.ahk|鼠标变速| 79 | |lib_settings.ahk|Capslock+settings.ini设置项提取| 80 | |lib_ydTrans.ahk|翻译| 81 | 82 | -------------------------------------------------------------------------------- /capslock+icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wo52616111/capslock-plus/7ec530ff10a9d41230e9211353fbeadb36bb7c2d/capslock+icon.ico -------------------------------------------------------------------------------- /language/Simplified_Chinese.ahk: -------------------------------------------------------------------------------- 1 | language_Simplified_Chinese: 2 | ; lib\lib_bindWins.ahk 3 | global lang_bw_noWIRini:="CapsLock+winsInfosRecorder.ini 不存在" 4 | 5 | ; lib_clq.ahk 6 | global lang_clq_addIni:="确定将以下字符串简写成 {replace0},并记录到 {replace1}?" 7 | global lang_clq_existing:="{replace0}`n已存在于 {replace1},确定用以下设置覆盖?" 8 | global lang_clq_qrunFileNotExist:="QRun中存在以下记录,而对应文件(文件夹)不存在,是否删除该设置?" 9 | global lang_clq_noCmd:="没有该命令" 10 | global lang_clq_emptyFolder:="<空文件夹>" 11 | 12 | ; ydTrans.ahk 13 | global lang_yd_translating:="翻译中... (如果网络太差,翻译请求会暂时阻塞程序,稍等就好)" 14 | global lang_yd_name:="有道翻译" 15 | global lang_yd_needKey:="缺少有道翻译API的key,有道翻译无法使用" 16 | global lang_yd_fileNotExist:="文件(文件夹)不存在" 17 | global lang_yd_errorNoNet:="发送异常,可能是网络已断开" 18 | global lang_yd_errorTooLong:="部分句子过长" 19 | global lang_yd_errorNoResults:="无词典结果" 20 | global lang_yd_errorTextTooLong:="要翻译的文本过长" 21 | global lang_yd_errorCantTrans:="无法进行有效的翻译" 22 | global lang_yd_errorLangType:="不支持的语言类型" 23 | global lang_yd_errorKeyInvalid:="无效的key" 24 | global lang_yd_errorSpendingLimit:="已达到今日消费上限,或者请求长度超过今日可消费字符数" 25 | global lang_yd_errorNoFunds:="帐户余额不足" 26 | global lang_yd_trans:="------------------------------------有道翻译------------------------------------" 27 | global lang_yd_dict:="------------------------------------有道词典------------------------------------" 28 | global lang_yd_phrase:="--------------------------------------短语--------------------------------------" 29 | global lang_yd_free_key_unavailable_warning:="有道翻译已经不再提供免费的翻译 API,现在只能使用收费 API(新账号有试用额度),请参考 CapsLock+settingsDemo.ini 文件中 [TTranslate] 部分的说明设置密钥后使用翻译功能。" 30 | 31 | global lang_settingsFileContent:="" 32 | lang_settingsFileContent= 33 | ( 34 | ;------------ Encoding: UTF-16 ------------ 35 | ;请对照 CapsLock+settingsDemo.ini 来配置相关设置 36 | [Global] 37 | 38 | loadScript=scriptDemo.js 39 | 40 | [QSearch] 41 | 42 | [QRun] 43 | 44 | [QWeb] 45 | 46 | [TabHotString] 47 | 48 | [QStyle] 49 | 50 | [TTranslate] 51 | 52 | [Keys] 53 | 54 | ) 55 | global lang_settingsDemoFileContent_1:="" 56 | global lang_settingsDemoFileContent_2:="" 57 | lang_settingsDemoFileContent_1= 58 | ( 59 | ;------------ Encoding: UTF-16 ------------ 60 | ; # CapsLock+ 设置样本 61 | ; - ******请务必阅读以下说明:****** 62 | 63 | ; - **这里的设置是只读的,仅作说明参考,不要修改这里的设置(修改了也无效),需要自定义设置请在 CapsLock+settings.ini 中的对应段名中作添加修改 64 | ; 例如,需要开启开机自启动,请在 CapsLock+settings.ini 的 [Global] 下添加:autostart=1,并保存 65 | 66 | ; - "[]"里面是段名,不能修改 67 | ; - 各段下所有设置的格式都为:键名=键值,每行一个 68 | ; - 虽然 QSearch,QRun 和 QWeb 是不同的段,理论上它们的键名可以重复,但请不要这样设置,否则 +Q 的快速启动功能会无法区分 69 | ; - 分号开头的是注释行,注释行不影响设置,就像这几行 70 | ; - 以下把 Capslock+Q 弹出的输入框称为 "Qbar" 71 | 72 | 73 | ;---------------------------------------------------------------- 74 | ; ## 全局设置 75 | [Global] 76 | ;是否开机自启动,1为是,0为否(默认)。 77 | autostart=0 78 | 79 | ;热键布局方案,可选值: 80 | ;- capslock_plus Capslock+ 3.0 之前的布局 81 | ;- capslox(默认) Capslock+ 3.0 之后的布局 82 | default_hotkey_scheme=capslox 83 | 84 | ;需要加载的 JavaScript 文件,以逗号分隔,文件应放在与 Capslock+ 程序同文件夹下的 loadScript 文件夹。 85 | ;Capslock+ 将会按照顺序加载,加载完后 +Tab 可以使用里面的函数 86 | ;在本设置不为空时,启动 Capslock+ 时将自动创建 loadScript 文件夹,以及位于文件夹中的 debug.html 和 scriptDemo.js 文件 87 | loadScript=myScript1.js,myScript2.js, myScript3.js , myScript4.js 88 | 89 | ;按下 Capslock+LAlt 键时,临时改变鼠标速度,范围是1~20。不设置的话默认3 90 | ;可以用 Capslock+LAlt+鼠标滚轮上 / 下快速设置这个值 91 | mouseSpeed=3 92 | 93 | ;是否允许独立剪贴板功能,1为是(默认),0为否 94 | allowClipboard=1 95 | 96 | ;是否开启程序加载动画,1是(默认),0否 97 | loadingAnimation=1 98 | 99 | ;---------------------------------------------------------------- 100 | ; ## Qbar搜索指令设置 101 | 102 | ; - 除default外的键名为搜索指令,该指令会按对应的搜索链接搜索关键词,例如: 103 | ; 这里设置了"bd=https://www.baidu.com/s?wd={q}",可以在 Qbar 输入"bd capslock+"来百度搜索关键词"capslock+" 104 | ; (不过bd这个指令已经自带,不需要设置,但可以通过将bd设置成别的链接来替换成别的搜索) 105 | 106 | ; - default为不输入任何指令时将使用的搜索 107 | 108 | ; - 键名可以自定义,如果下列例子中键名对应的键值没有被修改,Capslock+将保留相应的搜索指令 109 | 110 | ; - 每个网站的搜索链接(这里的键值)都不一样,可以尝试这样获取(不保证准确): 111 | ; 1. 打开需要获取搜索链接的网站 112 | ; 2. 在搜索栏输入任意字符,例如"capslockplus",搜索(有没有搜索出结果无所谓) 113 | ; 3. 在跳转后的地址栏中找到刚刚输入的字符,找到刚才搜索的字符并替换成"{q}"(不包括引号),得到搜索链接(替换后地址栏上的所有字符) 114 | 115 | ; - 可以使用 " ->search " 来添加一条设置到[QSearch] 116 | 117 | ; - 可以在键名的右边加上 (0~n个空格) 来作为备注提示 118 | 119 | [QSearch] 120 | 121 | default=https://www.baidu.com/s?wd={q} 122 | bd=https://www.baidu.com/s?wd={q} 123 | g =https://www.google.com/search?q={q} 124 | tb =http://s.taobao.com/search?q={q} 125 | wk=https://zh.wikipedia.org/w/index.php?search={q} 126 | m=https://developer.mozilla.org/zh-CN/search?q={q} 127 | 128 | 129 | ;---------------------------------------------------------------- 130 | ; ## Qbar 快速打开文件(文件夹)设置 131 | 132 | ; - 在这里添加一条设置后,就可以在 Qbar 用键名快速打开对应键值设置的文件或文件夹,例如: 133 | ; 这里设置了"exp=E:\expFolder\example.exe",在 Qbar 输入"exp",回车后会打开"E:\expFolder\example.exe"这个文件 134 | 135 | ; - 可以通过 Qbar 的 " -> " 指令快速添加一项设置,例如:在 Qbar 输入"exp2 -> E:\expFolder2\example2.exe"(" -> "两边各有一个空格),确认后将会在这里添加一项"exp2=E:\expFolder2\example2.exe" 136 | 137 | ; - 如果 " -> " 无法正确识别文件路径而把设置记录到了[QWeb]或[TabHotString],可以使用 " ->run " 来强制记录到[QRun] 138 | 139 | ; - 选中文件(文件夹)后,按 +Q ,可以将路径填入 Qbar ,那么,你想记录一个文件来快速打开,就可以这么操作: 140 | ; 1. 选中该文件 141 | ; 2. 按下 Capslock+Q,弹出的输入框内自动填入了该文件的路径 142 | ; 3. 在路径的最前面加上"xxx -> " 143 | ; 4. 按下 Enter 键,确认记录 144 | 145 | ; - 可以在键名的右边加上 (0~n个空格) 来作为备注提示 146 | 147 | ; - 可以设置以管理员启动程序,以及启动程序的参数, 148 | ; 需要设置的话程序路径需要用 " (引号)引起来,左边加上 *RunAs 将用管理员权限启动,右边带上启动参数 149 | 150 | [QRun] 151 | ;一般状态 152 | ie1=C:\Program Files\Internet Explorer\iexplore.exe 153 | 154 | ;管理员权限打开 155 | ie2=*runas "C:\Program Files\Internet Explorer\iexplore.exe" 156 | 157 | ;全屏打开 158 | ie3 ="C:\Program Files\Internet Explorer\iexplore.exe" -k 159 | 160 | ;管理员权限,全屏打开 161 | ie4=*runas "C:\Program Files\Internet Explorer\iexplore.exe" -k 162 | 163 | 164 | 165 | ;---------------------------------------------------------------- 166 | ; ## Qbar 快速打开网页设置 167 | 168 | ; - 在这里添加一条设置后,可以在 Qbar 用键名快速打开对应键值设置的链接,例如: 169 | ; 这里设置了"cldocs=https://capslox.com/capslock-plus",在 Qbar 输入"cldocs",回车后会用默认浏览器打开"https://capslox.com/capslock-plus" 170 | 171 | ; - 可以通过 Qbar 的 " -> " 指令快速添加一项设置,例如:在 Qbar 输入"cl+ -> https://capslox.com/capslock-plus"(" -> "两边各有一个空格),确认后将会在这里添加一项"cl+=https://capslox.com/capslock-plus" 172 | 173 | ; - 如果 " -> " 无法正确识别网址而把设置记录到了[QRun]或[TabHotString],可以使用 " ->web " 来强制记录到[QWeb] 174 | 175 | ; - 选中网址后,按 +Q ,可以将网址填入 Qbar ,那么,你想记录一个网址来快速打开,就可以这么操作: 176 | ; 1. 选中该网址 177 | ; 2. 按下 Capslock+Q,弹出的输入框内自动填入了该网址 178 | ; 3. 在路径的最前面加上"xxx -> " 179 | ; 4. 按下 Enter 键,确认记录 180 | 181 | ; - 可以在键名的右边加上 (0~n个空格) 来作为备注提示 182 | 183 | [QWeb] 184 | cldocs=https://capslox.com/capslock-plus 185 | 186 | 187 | 188 | ;----------------------------------------------------------------; 189 | ; ## TabScript 的字符替换设置 190 | 191 | ; - Capslock+Tab会将紧靠光标左边的匹配某键名的字符替换成对应键值的字符,例如: 192 | ; 这里设置了"@=capslock-plus@cjkis.me",在任意地方输入"@",然后按下"Capslock+Tab","@"将替换成"capslock-plus@cjkis.me" 193 | 194 | ; - 这里的优先级高于CapsLock+Tab的计算功能,例如: 195 | ; 这里设置了1+1=3,那么输入1+1后CapsLock+Tab,1+1会被替换成3而不是2 196 | 197 | ; - 可以通过 Qbar 的 " -> " 指令快速添加一项设置,例如:在 Qbar 输入 "tel -> 15012345678" ,确认后将会在这里添加一项 "tel=15012345678" 198 | 199 | ; - 如果作为键值的字符串是类似网址或文件(夹)路径的格式,例如:"ccc -> com.com.com", " -> " 指令很可能会将它判定为网址或文件(夹)而把设置记录到了[QRun]或[QWeb],可以使用 " ->str " 来强制记录到[TabHotString] 200 | 201 | ; - 选中文字后,按 +Q ,可以将文字填入 Qbar ,那么,你想记录一段文字,就可以这么操作: 202 | ; 1. 选中该文字 203 | ; 2. 按下 Capslock+Q,弹出的输入框内自动填入了该文字 204 | ; 3. 在路径的最前面加上"xxx -> " 205 | ; 4. 按下 Enter 键,确认记录 206 | 207 | [TabHotString] 208 | clp=capslockplus 209 | 210 | ;---------------------------------------------------------------- 211 | ; ## Qbar 的样式设置 212 | 213 | [QStyle] 214 | ;边框颜色 215 | ;指定16种HTML基础颜色之一或6位的RGB颜色值(0x前缀可以省略)。例如:red、ffffaa、FFFFAA、0xFFFFAA。下面的颜色设置也一样。 216 | borderBackgroundColor=red 217 | 218 | ;边框四角的圆角程度,0为直角 219 | borderRadius=9 220 | 221 | ;文字输入框背景颜色 222 | textBackgroundColor=green 223 | 224 | ;输入文字颜色 225 | textColor=ffffff 226 | 227 | ;输入文字字体 228 | ;editFontName=Consolas bold 229 | textFontName=Hiragino Sans GB W6 230 | 231 | ;输入文字大小 232 | textFontSize=12 233 | 234 | ;提示列表字体 235 | listFontName=consolas 236 | 237 | ;提示列表字体大小 238 | listFontSize=10 239 | 240 | ;提示列表背景颜色 241 | listBackgroundColor=blue 242 | 243 | ;提示列表文字颜色 244 | listColor=0x000000 245 | 246 | ;提示列表行数 247 | listCount=5 248 | 249 | ;提示列表每行高度 250 | lineHeight=19 251 | 252 | ;进度条颜色 253 | progressColor=0x00cc99 254 | 255 | ;----------------------------------------------------------------; 256 | ; ## +T翻译设置 257 | 258 | [TTranslate] 259 | ;有道api接口 260 | ;翻译功能通过调用有道的api实现。 261 | 262 | ;收费版api申请网址: https://ai.youdao.com/console/#/ 263 | ;有道翻译 API 入门指南: https://ai.youdao.com/doc.s#guide 264 | 265 | ;翻译 API 类型,目前只能为 1 266 | ;0: 免费版有道 API(已不可使用,有道翻译不再提供) 267 | ;1: 收费版有道 API(默认值) 268 | apiType=1 269 | 270 | ;收费版申请的参数 271 | 272 | ;应用ID 273 | appPaidID=xxx 274 | 275 | ;应用密钥 276 | appPaidKey=xxx 277 | 278 | ;曾经 Capslock+ 可以选择使用免费版或收费版的有道 API 来提供翻译功能,现在有道已经不再提供免费版 API, 279 | ;只能使用收费版的 API,以下与免费版 API 相关的参数已经废弃,如果你的设置文件中有使用,请删除掉。 280 | ;apiKey=xxx 281 | ;keyFrom=xxx 282 | 283 | ;----------------------------------------------------------------; 284 | 285 | ) 286 | 287 | lang_settingsDemoFileContent_2= 288 | ( 289 | ; ## 按键功能设置 290 | 291 | ; - 可设置的按键组合有: 292 | ; Capslock + F1~F12 293 | ; Capslock + 0~9 294 | ; Capslock + a~z 295 | ; Capslock + `-=[]\;',./ 296 | ; Capslock + Backspace, Tab, Enter, Space, RAlt 297 | ; Capslock + LALt + F1~F12 298 | ; Capslock + LALt + 0~9 299 | ; Capslock + LALt + a~z 300 | ; Capslock + LALt + `-=[]\;',./ 301 | ; Capslock + LALt + Backspace, Tab, Enter, Space, RAlt 302 | ; Capslock + Win + 0~9 303 | 304 | ; - 以下设置键名是按键组合名,键值是对应功能,所有支持的功能都在下面 305 | 306 | [Keys] 307 | ;短按 Caps Lock -> 发送 Esc 308 | ;press_caps=keyFunc_esc 309 | 310 | ;短按 Caps Lock -> 切换大小写 311 | press_caps=keyFunc_toggleCapsLock 312 | 313 | ;Capslock+A -> 光标向左移动一个单词 314 | caps_a=keyFunc_moveWordLeft 315 | 316 | ;Capslock+B -> 光标向下移动 10 行 317 | caps_b=keyFunc_moveDown(10) 318 | 319 | ;独立剪贴板 1 的复制 320 | caps_c=keyFunc_copy_1 321 | 322 | ;光标向下移动 323 | caps_d=keyFunc_moveDown 324 | 325 | ;光标向上移动 326 | caps_e=keyFunc_moveUp 327 | 328 | ;光标向右移动 329 | caps_f=keyFunc_moveRight 330 | 331 | ;光标向右移动一个单词 332 | caps_g=keyFunc_moveWordRight 333 | 334 | ;向左选中一个单词 335 | caps_h=keyFunc_selectWordLeft 336 | 337 | ;向上选中 338 | caps_i=keyFunc_selectUp 339 | 340 | ;向左选中 341 | caps_j=keyFunc_selectLeft 342 | 343 | ;向下选中 344 | caps_k=keyFunc_selectDown 345 | 346 | ;向右选中 347 | caps_l=keyFunc_selectRight 348 | 349 | ;向下选中 10 行 350 | caps_m=keyFunc_selectDown(10) 351 | 352 | ;向右选中一个单词 353 | caps_n=keyFunc_selectWordRight 354 | 355 | ;选中至行末 356 | caps_o=keyFunc_selectEnd 357 | 358 | ;光标移动到行首 359 | caps_p=keyFunc_home 360 | 361 | ; QBar 362 | caps_q=keyFunc_qbar 363 | 364 | ;delete 365 | caps_r=keyFunc_delete 366 | 367 | ;光标向左移动 368 | caps_s=keyFunc_moveLeft 369 | 370 | caps_t=keyFunc_doNothing 371 | 372 | ;选中至行首 373 | caps_u=keyFunc_selectHome 374 | 375 | ;独立剪贴板 1 的粘贴 376 | caps_v=keyFunc_paste_1 377 | 378 | ;backspace 379 | caps_w=keyFunc_backspace 380 | 381 | ;独立剪贴板 1 的剪切 382 | caps_x=keyFunc_cut_1 383 | 384 | ;向上选中 10 行 385 | caps_y=keyFunc_selectUp(10) 386 | 387 | caps_z=keyFunc_doNothing 388 | 389 | caps_backquote=keyFunc_doNothing 390 | 391 | ;Capslock+0~9 -> 激活绑定窗口 0~9 392 | caps_1=keyFunc_winbind_activate(1) 393 | 394 | caps_2=keyFunc_winbind_activate(2) 395 | 396 | caps_3=keyFunc_winbind_activate(3) 397 | 398 | caps_4=keyFunc_winbind_activate(4) 399 | 400 | caps_5=keyFunc_winbind_activate(5) 401 | 402 | caps_6=keyFunc_winbind_activate(6) 403 | 404 | caps_7=keyFunc_winbind_activate(7) 405 | 406 | caps_8=keyFunc_winbind_activate(8) 407 | 408 | caps_9=keyFunc_winbind_activate(9) 409 | 410 | caps_0=keyFunc_winbind_activate(10) 411 | 412 | caps_minus=keyFunc_qbar_upperFolderPath 413 | 414 | caps_equal=keyFunc_qbar_lowerFolderPath 415 | 416 | ;删除光标所在一行 417 | caps_backspace=keyFunc_deleteLine 418 | 419 | ;TabScript 420 | caps_tab=keyFunc_tabScript 421 | 422 | ;删除至行首 423 | caps_leftSquareBracket=keyFunc_deleteToLineBeginning 424 | 425 | caps_rightSquareBracket=keyFunc_doNothing 426 | 427 | caps_backslash=keyFunc_doNothing 428 | 429 | ;Capslock+; -> end 430 | caps_semicolon=keyFunc_end 431 | 432 | caps_quote=keyFunc_doNothing 433 | 434 | ;换行——无论光标是否在行末 435 | caps_enter=keyFunc_enterWherever 436 | 437 | ;选中当前单词 438 | caps_comma=keyFunc_selectCurrentWord 439 | 440 | ;向右选中单词 441 | caps_dot=keyFunc_selectWordRight 442 | 443 | ;删除至行尾 444 | caps_slash=keyFunc_deleteToLineEnd 445 | 446 | ;Capslock+Space -> enter 447 | caps_space=keyFunc_enter 448 | 449 | ;Capslock+RAlt -> 无 450 | caps_right_alt=keyFunc_doNothing 451 | 452 | ;打开 Capslock+ 首页 453 | caps_f1=keyFunc_openCpasDocs 454 | 455 | ;Math Board 456 | caps_f2=keyFunc_mathBoard 457 | 458 | ;有道翻译 459 | caps_f3=keyFunc_translate 460 | 461 | ;窗口透明 462 | caps_f4=keyFunc_winTransparent 463 | 464 | ;重载 Capslock+ 465 | caps_f5=keyFunc_reload 466 | 467 | ;窗口置顶 468 | caps_f6=keyFunc_winPin 469 | 470 | caps_f7=keyFunc_doNothing 471 | 472 | caps_f8=keyFunc_getJSEvalString 473 | 474 | caps_f9=keyFunc_doNothing 475 | 476 | caps_f10=keyFunc_doNothing 477 | 478 | caps_f11=keyFunc_doNothing 479 | 480 | ;打开 / 关闭独立剪贴板 481 | caps_f12=keyFunc_switchClipboard 482 | 483 | ;--------------------LAlt-------------------- 484 | 485 | ;Capslock+LAlt+A -> 向左移 3 个单词 486 | caps_lalt_a=keyFunc_moveWordLeft(3) 487 | 488 | ;下移 30 次 489 | caps_lalt_b=keyFunc_moveDown(30) 490 | 491 | ;独立剪贴板 2 的复制 492 | caps_lalt_c=keyFunc_copy_2 493 | 494 | ;下移 3 次 495 | caps_lalt_d=keyFunc_moveDown(3) 496 | 497 | ;上移 3 次 498 | caps_lalt_e=keyFunc_moveUp(3) 499 | 500 | ;右移 5 次 501 | caps_lalt_f=keyFunc_moveRight(5) 502 | 503 | ;右移 3 个单词 504 | caps_lalt_g=keyFunc_moveWordRight(3) 505 | 506 | ;向左选中 3 个单词 507 | caps_lalt_h=keyFunc_selectWordLeft(3) 508 | 509 | ;向上选中 3 次 510 | caps_lalt_i=keyFunc_selectUp(3) 511 | 512 | ;向左选中 5 个字符 513 | caps_lalt_j=keyFunc_selectLeft(5) 514 | 515 | ;向下选中 3 次 516 | caps_lalt_k=keyFunc_selectDown(3) 517 | 518 | ;向右选中 5 个字符 519 | caps_lalt_l=keyFunc_selectRight(5) 520 | 521 | ;向下选中 30 次 522 | caps_lalt_m=keyFunc_selectDown(30) 523 | 524 | ;向右选中 3 个单词 525 | caps_lalt_n=keyFunc_selectWordRight(3) 526 | 527 | ;选中至页尾 528 | caps_lalt_o=keyFunc_selectToPageEnd 529 | 530 | ;移动至页首 531 | caps_lalt_p=keyFunc_moveToPageBeginning 532 | 533 | caps_lalt_q=keyFunc_doNothing 534 | 535 | ;向前删除单词 536 | caps_lalt_r=keyFunc_forwardDeleteWord 537 | 538 | ;左移 5 次 539 | caps_lalt_s=keyFunc_moveLeft(5) 540 | 541 | ;上移 30 次 542 | caps_lalt_t=keyFunc_moveUp(30) 543 | 544 | ;选中至页首 545 | caps_lalt_u=keyFunc_selectToPageBeginning 546 | 547 | ;独立剪贴板 2 的粘贴 548 | caps_lalt_v=keyFunc_paste_2 549 | 550 | ;删除单词 551 | caps_lalt_w=keyFunc_deleteWord 552 | 553 | ;独立剪贴板 2 的 剪切 554 | caps_lalt_x=keyFunc_cut_2 555 | 556 | ;向上选中 30 次 557 | caps_lalt_y=keyFunc_selectUp(30) 558 | 559 | caps_lalt_z=keyFunc_doNothing 560 | 561 | caps_lalt_backquote=keyFunc_doNothing 562 | 563 | caps_lalt_1=keyFunc_winbind_binding(1) 564 | 565 | caps_lalt_2=keyFunc_winbind_binding(2) 566 | 567 | caps_lalt_3=keyFunc_winbind_binding(3) 568 | 569 | caps_lalt_4=keyFunc_winbind_binding(4) 570 | 571 | caps_lalt_5=keyFunc_winbind_binding(5) 572 | 573 | caps_lalt_6=keyFunc_winbind_binding(6) 574 | 575 | caps_lalt_7=keyFunc_winbind_binding(7) 576 | 577 | caps_lalt_8=keyFunc_winbind_binding(8) 578 | 579 | caps_lalt_9=keyFunc_winbind_binding(9) 580 | 581 | caps_lalt_0=keyFunc_winbind_binding(10) 582 | 583 | caps_lalt_minus=keyFunc_doNothing 584 | 585 | caps_lalt_equal=keyFunc_doNothing 586 | 587 | ;删除全部 588 | caps_lalt_backspace=keyFunc_deleteAll 589 | 590 | caps_lalt_tab=keyFunc_doNothing 591 | 592 | ;删除至页首 593 | caps_lalt_leftSquareBracket=keyFunc_deleteToPageBeginning 594 | 595 | ;Capslock+LAlt+] 596 | caps_lalt_rightSquareBracket=keyFunc_doNothing 597 | 598 | ;Capslock+LAlt+\ 599 | caps_lalt_backslash=keyFunc_doNothing 600 | 601 | ;移动至页尾 602 | caps_lalt_semicolon=keyFunc_moveToPageEnd 603 | 604 | caps_lalt_quote=keyFunc_doNothing 605 | 606 | caps_lalt_enter=keyFunc_doNothing 607 | 608 | ;选中当前行 609 | caps_lalt_comma=caps_comma=keyFunc_selectCurrentLine 610 | 611 | ;向右选中 3 个单词 612 | caps_lalt_dot=keyFunc_selectWordRight(3) 613 | 614 | ;删除至页尾 615 | caps_lalt_slash=keyFunc_deleteToPageEnd 616 | 617 | caps_lalt_space=keyFunc_doNothing 618 | 619 | caps_lalt_ralt=keyFunc_doNothing 620 | 621 | caps_lalt_f1=keyFunc_doNothing 622 | 623 | caps_lalt_f2=keyFunc_doNothing 624 | 625 | caps_lalt_f3=keyFunc_doNothing 626 | 627 | caps_lalt_f4=keyFunc_doNothing 628 | 629 | caps_lalt_f5=keyFunc_doNothing 630 | 631 | caps_lalt_f6=keyFunc_doNothing 632 | 633 | caps_lalt_f7=keyFunc_doNothing 634 | 635 | caps_lalt_f8=keyFunc_doNothing 636 | 637 | caps_lalt_f9=keyFunc_doNothing 638 | 639 | caps_lalt_f10=keyFunc_doNothing 640 | 641 | caps_lalt_f11=keyFunc_doNothing 642 | 643 | caps_lalt_f12=keyFunc_doNothing 644 | 645 | caps_lalt_wheelUp=keyFunc_doNothing 646 | 647 | caps_lalt_wheelDown=keyFunc_doNothing 648 | 649 | ; CapsLock + Windows + 0~9 -> 绑定窗口 0~9 650 | caps_win_1=keyFunc_winbind_binding(1) 651 | 652 | caps_win_2=keyFunc_winbind_binding(2) 653 | 654 | caps_win_3=keyFunc_winbind_binding(3) 655 | 656 | caps_win_4=keyFunc_winbind_binding(4) 657 | 658 | caps_win_5=keyFunc_winbind_binding(5) 659 | 660 | caps_win_6=keyFunc_winbind_binding(6) 661 | 662 | caps_win_7=keyFunc_winbind_binding(7) 663 | 664 | caps_win_8=keyFunc_winbind_binding(8) 665 | 666 | caps_win_9=keyFunc_winbind_binding(9) 667 | 668 | caps_win_0=keyFunc_winbind_binding(10) 669 | 670 | 671 | ;----------------其他功能---------------- 672 | 673 | ; 用指定的字符包裹选定的文本,或输出指定的字符 674 | ; 例如: 675 | ; 676 | ; "..." 677 | ; caps_quote=keyFunc_doubleChar(""") 678 | ; 679 | ; (...) 680 | ; caps_9=keyFunc_doubleChar((,)) 681 | ; 682 | ; {...} 683 | ; caps_leftSquareBracket=keyFunc_doubleChar({,}) 684 | ; 685 | ; [...] 686 | ; caps_rightSquareBracket=keyFunc_doubleChar([,]) 687 | ; 688 | keyFunc_doubleChar 689 | 690 | ;上一首 691 | keyFunc_mediaPrev 692 | 693 | ;暂停 / 播放 694 | keyFunc_mediaPlayPause 695 | 696 | ;音量增大 697 | keyFunc_volumeUp 698 | 699 | ;音量减小 700 | keyFunc_volumeDown 701 | 702 | ;静音 703 | keyFunc_volumeMute 704 | 705 | ; 鼠标左键点击 706 | keyfunc_click_left 707 | 708 | ; 鼠标右键点击 709 | keyfunc_click_right 710 | 711 | ; 移动鼠标(长按可加快移动速度) 712 | keyfunc_mouse_up 713 | 714 | keyfunc_mouse_down 715 | 716 | keyfunc_mouse_left 717 | 718 | keyfunc_mouse_right 719 | 720 | ; 滚轮上滑 721 | keyfunc_wheel_up 722 | 723 | ; 滚轮下滑 724 | keyfunc_wheel_down 725 | 726 | ) 727 | global lang_winsInfosRecorderIniInit:="" 728 | lang_winsInfosRecorderIniInit= 729 | ( 730 | ;------------ Encoding: UTF-16 ------------ 731 | ;这里记录着窗口的数据,不要手动修改本文件内容,点下右上角的"X"就好。 732 | 733 | [0] 734 | bindType= 735 | class_0= 736 | exe_0= 737 | id_0= 738 | [1] 739 | bindType= 740 | class_0= 741 | exe_0= 742 | id_0= 743 | [2] 744 | bindType= 745 | class_0= 746 | exe_0= 747 | id_0= 748 | [3] 749 | bindType= 750 | class_0= 751 | exe_0= 752 | id_0= 753 | [4] 754 | bindType= 755 | class_0= 756 | exe_0= 757 | id_0= 758 | [5] 759 | bindType= 760 | class_0= 761 | exe_0= 762 | id_0= 763 | [6] 764 | bindType= 765 | class_0= 766 | exe_0= 767 | id_0= 768 | [7] 769 | bindType= 770 | class_0= 771 | exe_0= 772 | id_0= 773 | [8] 774 | bindType= 775 | class_0= 776 | exe_0= 777 | id_0= 778 | ) 779 | 780 | ; keysFunction.ahk 781 | global lang_kf_getDebugText:="" 782 | lang_kf_getDebugText= 783 | ( 784 | 供 TabScript 调试用字符串 785 | 点击"OK"将它复制到剪贴板 786 | ) 787 | return 788 | -------------------------------------------------------------------------------- /language/Traditional_Chinese.ahk: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /language/lang_func.ahk: -------------------------------------------------------------------------------- 1 | getSystemLanguage(){ 2 | languageCode_0436 = Afrikaans 3 | languageCode_041c = Albanian 4 | languageCode_0401 = Arabic_Saudi_Arabia 5 | languageCode_0801 = Arabic_Iraq 6 | languageCode_0c01 = Arabic_Egypt 7 | languageCode_0401 = Arabic_Saudi_Arabia 8 | languageCode_0801 = Arabic_Iraq 9 | languageCode_0c01 = Arabic_Egypt 10 | languageCode_1001 = Arabic_Libya 11 | languageCode_1401 = Arabic_Algeria 12 | languageCode_1801 = Arabic_Morocco 13 | languageCode_1c01 = Arabic_Tunisia 14 | languageCode_2001 = Arabic_Oman 15 | languageCode_2401 = Arabic_Yemen 16 | languageCode_2801 = Arabic_Syria 17 | languageCode_2c01 = Arabic_Jordan 18 | languageCode_3001 = Arabic_Lebanon 19 | languageCode_3401 = Arabic_Kuwait 20 | languageCode_3801 = Arabic_UAE 21 | languageCode_3c01 = Arabic_Bahrain 22 | languageCode_4001 = Arabic_Qatar 23 | languageCode_042b = Armenian 24 | languageCode_042c = Azeri_Latin 25 | languageCode_082c = Azeri_Cyrillic 26 | languageCode_042d = Basque 27 | languageCode_0423 = Belarusian 28 | languageCode_0402 = Bulgarian 29 | languageCode_0403 = Catalan 30 | languageCode_0404 = Chinese_Taiwan 31 | languageCode_0804 = Chinese_PRC 32 | languageCode_0c04 = Chinese_Hong_Kong 33 | languageCode_1004 = Chinese_Singapore 34 | languageCode_1404 = Chinese_Macau 35 | languageCode_041a = Croatian 36 | languageCode_0405 = Czech 37 | languageCode_0406 = Danish 38 | languageCode_0413 = Dutch_Standard 39 | languageCode_0813 = Dutch_Belgian 40 | languageCode_0409 = English_United_States 41 | languageCode_0809 = English_United_Kingdom 42 | languageCode_0c09 = English_Australian 43 | languageCode_1009 = English_Canadian 44 | languageCode_1409 = English_New_Zealand 45 | languageCode_1809 = English_Irish 46 | languageCode_1c09 = English_South_Africa 47 | languageCode_2009 = English_Jamaica 48 | languageCode_2409 = English_Caribbean 49 | languageCode_2809 = English_Belize 50 | languageCode_2c09 = English_Trinidad 51 | languageCode_3009 = English_Zimbabwe 52 | languageCode_3409 = English_Philippines 53 | languageCode_0425 = Estonian 54 | languageCode_0438 = Faeroese 55 | languageCode_0429 = Farsi 56 | languageCode_040b = Finnish 57 | languageCode_040c = French_Standard 58 | languageCode_080c = French_Belgian 59 | languageCode_0c0c = French_Canadian 60 | languageCode_100c = French_Swiss 61 | languageCode_140c = French_Luxembourg 62 | languageCode_180c = French_Monaco 63 | languageCode_0437 = Georgian 64 | languageCode_0407 = German_Standard 65 | languageCode_0807 = German_Swiss 66 | languageCode_0c07 = German_Austrian 67 | languageCode_1007 = German_Luxembourg 68 | languageCode_1407 = German_Liechtenstein 69 | languageCode_0408 = Greek 70 | languageCode_040d = Hebrew 71 | languageCode_0439 = Hindi 72 | languageCode_040e = Hungarian 73 | languageCode_040f = Icelandic 74 | languageCode_0421 = Indonesian 75 | languageCode_0410 = Italian_Standard 76 | languageCode_0810 = Italian_Swiss 77 | languageCode_0411 = Japanese 78 | languageCode_043f = Kazakh 79 | languageCode_0457 = Konkani 80 | languageCode_0412 = Korean 81 | languageCode_0426 = Latvian 82 | languageCode_0427 = Lithuanian 83 | languageCode_042f = Macedonian 84 | languageCode_043e = Malay_Malaysia 85 | languageCode_083e = Malay_Brunei_Darussalam 86 | languageCode_044e = Marathi 87 | languageCode_0414 = Norwegian_Bokmal 88 | languageCode_0814 = Norwegian_Nynorsk 89 | languageCode_0415 = Polish 90 | languageCode_0416 = Portuguese_Brazilian 91 | languageCode_0816 = Portuguese_Standard 92 | languageCode_0418 = Romanian 93 | languageCode_0419 = Russian 94 | languageCode_044f = Sanskrit 95 | languageCode_081a = Serbian_Latin 96 | languageCode_0c1a = Serbian_Cyrillic 97 | languageCode_041b = Slovak 98 | languageCode_0424 = Slovenian 99 | languageCode_040a = Spanish_Traditional_Sort 100 | languageCode_080a = Spanish_Mexican 101 | languageCode_0c0a = Spanish_Modern_Sort 102 | languageCode_100a = Spanish_Guatemala 103 | languageCode_140a = Spanish_Costa_Rica 104 | languageCode_180a = Spanish_Panama 105 | languageCode_1c0a = Spanish_Dominican_Republic 106 | languageCode_200a = Spanish_Venezuela 107 | languageCode_240a = Spanish_Colombia 108 | languageCode_280a = Spanish_Peru 109 | languageCode_2c0a = Spanish_Argentina 110 | languageCode_300a = Spanish_Ecuador 111 | languageCode_340a = Spanish_Chile 112 | languageCode_380a = Spanish_Uruguay 113 | languageCode_3c0a = Spanish_Paraguay 114 | languageCode_400a = Spanish_Bolivia 115 | languageCode_440a = Spanish_El_Salvador 116 | languageCode_480a = Spanish_Honduras 117 | languageCode_4c0a = Spanish_Nicaragua 118 | languageCode_500a = Spanish_Puerto_Rico 119 | languageCode_0441 = Swahili 120 | languageCode_041d = Swedish 121 | languageCode_081d = Swedish_Finland 122 | languageCode_0449 = Tamil 123 | languageCode_0444 = Tatar 124 | languageCode_041e = Thai 125 | languageCode_041f = Turkish 126 | languageCode_0422 = Ukrainian 127 | languageCode_0420 = Urdu 128 | languageCode_0443 = Uzbek_Latin 129 | languageCode_0843 = Uzbek_Cyrillic 130 | languageCode_042a = Vietnamese 131 | 132 | ; https://www.autohotkey.com/boards/viewtopic.php?t=43376 133 | RegRead, systemLocale,HKEY_CURRENT_USER,Control Panel\International, Locale 134 | 135 | if(systemLocale) 136 | { 137 | systemLocale := SubStr(systemLocale, -3) 138 | } 139 | 140 | lang := languageCode_%systemLocale% 141 | ; msgbox, lang: %lang% 142 | 143 | if(lang) 144 | { 145 | return lang 146 | } else { 147 | return languageCode_%A_Language% 148 | } 149 | 150 | } 151 | 152 | isLangChinese() 153 | { 154 | ; msgbox, % getSystemLanguage() 155 | ; MsgBox, The system language key is %A_Language%, the locale key is %system_locale% 156 | return InStr(getSystemLanguage(), "Chinese") 157 | } 158 | 159 | isLangChinaChinese() 160 | { 161 | return getSystemLanguage() == "Chinese_PRC" 162 | } -------------------------------------------------------------------------------- /lib/lib_bindWins.ahk: -------------------------------------------------------------------------------- 1 | bindWinsInit: 2 | global winsInfos:={} 3 | global tapTimes:={1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,btn:-1} 4 | global winTapedX ;winTapedX用于判断多窗口绑定的切换是哪个按键的,在CapsLock松开后winsSort()用来判定一次窗口在窗口组的位置 5 | global lastActiveWinId ;在用窗口激活时,现在正在激活状态的窗口id 6 | ;标志有没获取过窗口信息,因为判断多次敲击需要等待时间, 7 | ;超时了才执行绑定程序,在等待时间中唤醒绑定窗口会造成绑定失败, 8 | ;所以增加一个标志,当唤醒窗口时,标志不假则立刻执行一次绑定程序 9 | global gettingWinInfo:=0 10 | 11 | initWinsInfos(n) 12 | { 13 | winsInfos[n]:={} 14 | winsInfos[n].class:={} 15 | winsInfos[n].exe:={} 16 | winsInfos[n].id:={} 17 | return 18 | } 19 | 20 | IfNotExist, CapsLock+winsInfosRecorder.ini 21 | { 22 | FileAppend, %lang_winsInfosRecorderIniInit%, CapsLock+winsInfosRecorder.ini, UTF-16 23 | } 24 | lang_winsInfosRecorderIniInit:="" 25 | 26 | IniRead, infosSections, CapsLock+winsInfosRecorder.ini, , , %A_Space% 27 | sectionArr:=StrSplit(infosSections,"`n") 28 | loop, % tapTimes.MaxIndex() ;+1:把索引从0开始换成1开始 29 | initWinsInfos(A_index) 30 | ; { 31 | ; _t:="group" . A_index-1 ;-1:把索引从1开始换成0开始 32 | ; winsInfos[_t]:={} 33 | ; winsInfos[_t].class:={} 34 | ; winsInfos[_t].exe:={} 35 | ; winsInfos[_t].id:={} 36 | ; } 37 | ;取出winsInfosRecorder.ini里的数据,数组存着 38 | for sectionKey,sectionValue in sectionArr 39 | { 40 | ;~ winsInfos[sectionValue].length:=0 41 | IniRead, infosKeys, CapsLock+winsInfosRecorder.ini, %sectionValue%, , %A_Space% 42 | infosKeys:=RegExReplace(infosKeys, "m`n)=.*$") 43 | keyArr:=StrSplit(infosKeys,"`n") 44 | for key,keyValue in keyArr 45 | { 46 | IniRead, infos, CapsLock+winsInfosRecorder.ini, %sectionValue%, %keyValue%, %A_Space% 47 | if(keyValue="bindType") ;如果是bindType则直接记录,否则是class,exe,id,再开多一维数组记录 48 | { 49 | winsInfos[sectionValue].bindType:=infos 50 | } 51 | else 52 | { 53 | ni:=StrSplit(keyValue, "_") ;name and id 54 | winsInfos[sectionValue][ni.1][ni.2]:=infos 55 | } 56 | } 57 | } 58 | 59 | return 60 | ;=function=start============================================================================ 61 | getWinInfo(btnx, bindType) 62 | { 63 | winId:=WinExist("A") ;获取id 64 | WinGetClass, winClass, ahk_id %winId% ;获取该id窗口的class 65 | WinGet, winExe, ProcessPath, ahk_id %winId% ;获取该id窗口的path 66 | infosGx:=winsInfos[btnx] ;记录到窗口绑定变量 67 | if(bindType==1) ;如果是单窗口绑定 68 | { 69 | ;~ if(winId==infosGx.id.0) ;如果重复绑定,不执行 70 | ;~ return 71 | infosGx.bindType:=1 72 | infosGx.id.0:=winId 73 | infosGx.class.0:=winClass 74 | infosGx.exe.0:=winExe 75 | IfExist, CapsLock+winsInfosRecorder.ini 76 | { 77 | IniWrite, 1, CapsLock+winsInfosRecorder.ini, %btnx%, bindType ;写入bindType到ini 78 | IniWrite, %winClass%, CapsLock+winsInfosRecorder.ini, %btnx%, class_0 ;写入class到ini 79 | IniWrite, %winExe%, CapsLock+winsInfosRecorder.ini, %btnx%, exe_0 ;写入path到ini 80 | IniWrite, %winId%, CapsLock+winsInfosRecorder.ini, %btnx%, id_0 ;写入id到ini 81 | } 82 | else 83 | { 84 | MsgBox, %lang_bw_noWIRini% 85 | return 86 | } 87 | loop, % infosGx.id.MaxIndex() ;除了第0个,其他都删掉 88 | { 89 | ;~ SendInput, % A_Index 90 | IniDelete, CapsLock+winsInfosRecorder.ini, %btnx%, class_%A_Index% 91 | IniDelete, CapsLock+winsInfosRecorder.ini, %btnx%, exe_%A_Index% 92 | IniDelete, CapsLock+winsInfosRecorder.ini, %btnx%, id_%A_Index% 93 | infosGx.class.remove(1) 94 | infosGx.exe.remove(1) 95 | infosGx.id.remove(1) 96 | } 97 | ;~ infosGx.length:=1 98 | return 99 | } 100 | 101 | else if(bindType==2) ;如果多窗口绑定 102 | { 103 | if(infosGx.bindType==3) ;如果现在的绑定模式是3,先清空,再绑上第一个窗口 104 | { 105 | infosGx.class.0:=winClass 106 | infosGx.exe.0:=winExe 107 | infosGx.id.0:=winId 108 | 109 | IniWrite, %winClass%, CapsLock+winsInfosRecorder.ini, %btnx%, class_0 ;写入class到ini 110 | IniWrite, %winExe%, CapsLock+winsInfosRecorder.ini, %btnx%, exe_0 ;写入path到ini 111 | IniWrite, %winId%, CapsLock+winsInfosRecorder.ini, %btnx%, id_0 ;写入id到ini 112 | 113 | loop, % infosGx.id.MaxIndex() ;除了第0个,其他都删掉 114 | { 115 | IniDelete, CapsLock+winsInfosRecorder.ini, %btnx%, class_%A_Index% 116 | IniDelete, CapsLock+winsInfosRecorder.ini, %btnx%, exe_%A_Index% 117 | IniDelete, CapsLock+winsInfosRecorder.ini, %btnx%, id_%A_Index% 118 | infosGx.class.remove(1) 119 | infosGx.exe.remove(1) 120 | infosGx.id.remove(1) 121 | } 122 | infosGx.bindType:=1 123 | } 124 | else ;否则就是模式1或2,直接在现有窗口基础上添加就行 125 | { 126 | index:=infosGx.id.MaxIndex()+1 127 | loop, % index ;查重,如果是已有的窗口,不添加 128 | { 129 | if(winId==infosGx.id[A_Index-1]) 130 | return 131 | } 132 | ;~ SendInput, % index 133 | infosGx.class.insert(winClass) 134 | infosGx.exe.insert(winExe) 135 | infosGx.id.insert(winId) 136 | 137 | IniWrite, %winClass%, CapsLock+winsInfosRecorder.ini, %btnx%, class_%index% ;写入class到ini 138 | IniWrite, %winExe%, CapsLock+winsInfosRecorder.ini, %btnx%, exe_%index% ;写入path到ini 139 | IniWrite, %winId%, CapsLock+winsInfosRecorder.ini, %btnx%, id_%index% ;写入id到ini 140 | 141 | infosGx.bindType:=2 142 | } 143 | IniWrite, 2, CapsLock+winsInfosRecorder.ini, %btnx%, bindType ;写入bindType到ini 144 | } 145 | 146 | else if(bindType==3) ;如果单程序全窗口绑定 147 | { 148 | infosGx.bindType:=3 149 | WinGet, winList, List, ahk_class %winClass% ahk_exe %winExe% 150 | uselessLength:=infosGx.id.MaxIndex()+1-winList ;多余无用的数据有多少条(原本的-新增的) 151 | infosGx.class.0:=winClass 152 | infosGx.exe.0:=winExe 153 | loop, % winList ;全部id分配到变量里 154 | { 155 | infosGx.id[A_Index-1]:=winList%A_Index% 156 | } 157 | IniWrite, %winClass%, CapsLock+winsInfosRecorder.ini, %btnx%, class_0 ;写入class到ini 158 | IniWrite, %winExe%, CapsLock+winsInfosRecorder.ini, %btnx%, exe_0 ;写入path到ini 159 | loop, % winList ;全部id写到ini里, 不知道写入会不会造成程序等待,所以和分配变量分开两个loop进行 160 | { 161 | index:=A_Index-1 162 | IniWrite, % winList%A_Index%, CapsLock+winsInfosRecorder.ini, %btnx%, id_%index% ;写入id到ini 163 | } 164 | loop, % uselessLength ;除了前面刚刚写入的,其他有多的话都删掉 165 | { 166 | index:=winList+uselessLength-A_Index 167 | ;~ SendInput, % index 168 | infosGx.class.remove(index) 169 | infosGx.exe.remove(index) 170 | infosGx.id.remove(index) 171 | IniDelete, CapsLock+winsInfosRecorder.ini, %btnx%, class_%index% 172 | IniDelete, CapsLock+winsInfosRecorder.ini, %btnx%, exe_%index% 173 | IniDelete, CapsLock+winsInfosRecorder.ini, %btnx%, id_%index% 174 | } 175 | IniWrite, 3, CapsLock+winsInfosRecorder.ini, %btnx%, bindType ;写入bindType到ini 176 | ;~ infosGx.length:=winList 177 | } 178 | return 179 | } 180 | 181 | 182 | activateWinAction(btnx) 183 | { 184 | ;如果正在获取窗口信息,立刻执行窗口绑定程序 185 | if(gettingWinInfo) 186 | gosub, doGetWinInfo 187 | 188 | infosGx:=winsInfos[btnx] 189 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;如果该按键上只绑了一个窗口 190 | 191 | if(infosGx.bindType==1) 192 | { 193 | 194 | tempId:=infosGx.id.0 195 | IfWinNotExist, ahk_id %tempId% 196 | { 197 | tempClass:=infosGx.class.0 198 | tempExe:=infosGx.exe.0 199 | WinGet, tempId, ID, ahk_exe %tempExe% ahk_class %tempClass% 200 | if(tempId) 201 | { 202 | IniWrite, %tempId%, CapsLock+winsInfosRecorder.ini, % btnx , id_0 203 | } 204 | Else 205 | { 206 | IfExist, %tempExe% 207 | { 208 | Run, %tempExe% 209 | } 210 | Return 211 | } 212 | } 213 | IfWinActive, ahk_id %tempId% 214 | { 215 | WinMinimize, ahk_id %tempId% 216 | if(lastActiveWinId!="" && lastActiveWinId!=tempId) 217 | WinActivate, ahk_id %lastActiveWinId% 218 | return 219 | } 220 | 221 | lastActiveWinId:=WinExist("A") 222 | WinActivate, ahk_id %tempId% 223 | return 224 | } 225 | ;;;;;;;;;;;;如果该按键上绑了多个独立窗口 226 | if(infosGx.bindType==2) 227 | { 228 | winTapedX:=btnx ;将按下标记设置为当前按键 229 | 230 | ;变量中的窗口被关掉的清除掉 231 | maxIndex:=infosGx.id.MaxIndex() 232 | loop, % maxIndex+1 233 | { 234 | index:=maxIndex+1-A_Index 235 | tempId:=infosGx.id[index] 236 | IfWinNotExist, ahk_id %tempId% 237 | { 238 | infosGx.class.remove(index) 239 | infosGx.exe.remove(index) 240 | infosGx.id.remove(index) 241 | IniDelete, CapsLock+winsInfosRecorder.ini, %btnx%, class_%index% 242 | IniDelete, CapsLock+winsInfosRecorder.ini, %btnx%, exe_%index% 243 | IniDelete, CapsLock+winsInfosRecorder.ini, %btnx%, id_%index% 244 | } 245 | } 246 | 247 | ;如果绑定组中只剩一个窗口,自动转换成bindType1 248 | if(infosGx.id.MaxIndex()=0) 249 | { 250 | IniWrite, 1, CapsLock+winsInfosRecorder.ini, %btnx%, bindType ;写入bindType到ini 251 | infosGx.bindType:=1 252 | tempId:=infosGx.id.0 253 | IfWinActive, ahk_id %tempId% 254 | { 255 | WinMinimize, ahk_id %tempId% 256 | return 257 | } 258 | WinActivate, ahk_id %tempId% 259 | return 260 | } 261 | 262 | ;判断当前激活窗口id是否id组中的一个,是的话,激活它的下一个窗口,都不是的话,激活第一个 263 | actWinId:=WinExist("A") 264 | loop, % infosGx.id.MaxIndex()+1 265 | { 266 | if(infosGx.id[A_Index-1]=actWinId) 267 | { 268 | if(A_index-1=infosGx.id.MaxIndex()) ;如果最后一个窗口才是激活的,那就激活第一个窗口 269 | { 270 | tempId:=infosGx.id.0 271 | WinActivate, ahk_id %tempId% 272 | return 273 | } 274 | tempId:=infosGx.id[A_index] 275 | WinActivate, ahk_id %tempId% 276 | return 277 | } 278 | } 279 | tempId:=infosGx.id.0 280 | WinActivate, ahk_id %tempId% 281 | return 282 | } 283 | 284 | if(infosGx.bindType==3) ;如果该按键绑定了某程序所有窗口 285 | { 286 | winTapedX:=btnx ;将按下标记设置为当前按键 287 | tempClass:=infosGx.class.0 288 | tempExe:=infosGx.exe.0 289 | 290 | ;变量中的窗口被关掉的清除掉 291 | maxIndex:=infosGx.id.MaxIndex() 292 | loop, % maxIndex+1 293 | { 294 | index:=maxIndex+1-A_Index 295 | tempId:=infosGx.id[index] 296 | IfWinNotExist, ahk_id %tempId% 297 | { 298 | infosGx.id.remove(index) 299 | } 300 | } 301 | 302 | ;判断现有的某程序的窗口是否增加,有的话添加到变量中 303 | WinGet, winList, List, ahk_class %tempClass% ahk_exe %tempExe% 304 | loop, % winList 305 | { 306 | idx:=winList%A_index% 307 | isExist:=0 308 | loop, % infosGx.id.MaxIndex()+1 309 | { 310 | if(idx=infosGx.id[A_index-1]) 311 | { 312 | isExist:=1 313 | break 314 | } 315 | } 316 | if(!isExist) 317 | { 318 | infosGx.id.insert(idx) 319 | } 320 | } 321 | 322 | ;如果当前没有该程序的任何窗口,启动程序 323 | if(infosGx.id.MaxIndex()="") 324 | { 325 | IfExist, %tempExe% 326 | { 327 | Run, %tempExe% 328 | } 329 | Return 330 | } 331 | ;if only one windows 332 | else if(infosGx.id.MaxIndex()=0) 333 | { 334 | tempId:=infosGx.id.0 335 | IfWinActive, ahk_id %tempId% 336 | { 337 | WinMinimize, ahk_id %tempId% 338 | return 339 | } 340 | WinActivate, ahk_id %tempId% 341 | return 342 | } 343 | 344 | ;判断当前激活窗口id是否id组中的一个,是的话,激活它的下一个窗口,都不是的话,激活第一个 345 | actWinId:=WinExist("A") 346 | loop, % infosGx.id.MaxIndex()+1 347 | { 348 | if(infosGx.id[A_Index-1]=actWinId) 349 | { 350 | if(A_index-1=infosGx.id.MaxIndex()) ;如果最后一个窗口才是激活的,那就激活第一个窗口 351 | { 352 | tempId:=infosGx.id.0 353 | WinActivate, ahk_id %tempId% 354 | return 355 | } 356 | tempId:=infosGx.id[A_index] 357 | WinActivate, ahk_id %tempId% 358 | return 359 | } 360 | } 361 | tempId:=infosGx.id.0 362 | WinActivate, ahk_id %tempId% 363 | return 364 | } 365 | } 366 | 367 | ;当放开CapsLock后,对窗口排序,当前激活的窗口排到窗口组的第一位 368 | winsSort(btnx) 369 | { 370 | infosGx:=winsInfos[btnx] 371 | loop, % infosGx.id.MaxIndex()+1 372 | { 373 | actWinId:=WinExist("A") 374 | if(infosGx.id[A_Index-1]=actWinId) 375 | { 376 | ;~ MsgBox, % infosGx.id[A_Index-1] 377 | infosGx.id.insert(0,infosGx.id.remove(A_index-1)) ;将当前激活窗口移到窗口组第一个 378 | } 379 | } 380 | winTapedX:=-1 ;重置标记 381 | return 382 | } 383 | 384 | 385 | tapTimes(btnx) ;判断敲击次数,绑定按键的入口函数,判断完敲击次数会调用doGetWinInfo,再调用getWinInfo 386 | { 387 | gettingWinInfo:=1 388 | SetTimer, doGetWinInfo, -500 389 | tapTimes.tapBtn:=btnx ;记录按下了哪个按键 390 | if(tapTimes["btn" . btnx]<1) 391 | { 392 | tapTimes["btn" . btnx]:=1 393 | } 394 | if(A_ThisHotkey = A_PriorHotkey && A_TimeSincePriorHotkey < 500) 395 | { 396 | if(tapTimes["btn" . btnx]<2) 397 | { 398 | tapTimes["btn" . btnx]:=2 399 | } 400 | else 401 | { 402 | tapTimes["btn" . btnx]:=3 403 | ;~ gosub, doGetWinInfo 404 | } 405 | } 406 | return 407 | } 408 | 409 | 410 | 411 | doGetWinInfo: 412 | SetTimer, doGetWinInfo, Off 413 | winBtnx:=tapTimes.tapBtn 414 | tTapTimesx:=tapTimes["btn" . winBtnx] 415 | if(tTapTimesx>0&&winBtnx>-1) 416 | { 417 | getWinInfo(winBtnx, tTapTimesx) 418 | ;~ SendInput, % winBtnx . "@" . tTapTimesx0@2 419 | } 420 | tapTimes["btn" . winBtnx]:=0 ;重置敲击次数 421 | tapTimes.tapBtn:=-1 ;重置winBtnx 422 | gettingWinInfo:=0 423 | return 424 | 425 | ;=function=end============================================================================ -------------------------------------------------------------------------------- /lib/lib_clTab.ahk: -------------------------------------------------------------------------------- 1 | #include lib_jsEval.ahk 2 | 3 | ;if autoMatch=1, match mathematical expressions from inputStr 4 | ;if autoMatch=0, to identify inputStr as mathematical expressions 5 | clCalculate(inputStr,ByRef result,autoMatch:=0,isScratch:=0) ;46494*234-(123+234/3)+123*3/2+5= 6 | { 7 | if(autoMatch){ 8 | ;精确匹配四则运算和幂运算回合表达式 strRegEx:="i)\(*-?\d*\.?\d+\)*(\s?([-+*/]|\*\*)\s?\(*-?\d*\.?\d+\)*)*\s*(\$(b|h|x|)(\d*[eEgG]?))?\s?=?\s?$" 9 | ;模糊匹配所有算式 10 | ; strRegEx0:="S)``.+$" 11 | ; this RegEx is for monsterEval 12 | ; strRegEx:="S)(\w*\d*(\(.*\))?\s?:=|\w*?\(|\$(b|h|x|)(\d*[eEgG]?)|\d+|[\+\-'~!]|(pi|PI|[eE])\s?[-+*/]+)[\d\w\(\)\-\+\*/'!~\^\?\$:=;><|&\s%\.]*$" 13 | ; this RegEx is for jsEval 14 | strRegEx:="\S*$" 15 | foundPos:=RegExMatch(inputStr, "(``)(.*)", calStr) 16 | if(!foundPos) 17 | foundPos:=RegExMatch(inputStr, strRegEx, calStr) 18 | else 19 | calStr:=LTrim(calStr, "``") 20 | 21 | if(foundPos){ 22 | inputStr:=SubStr(inputStr,1,foundPos-1) 23 | 24 | }else{ 25 | return inputStr 26 | } 27 | 28 | }else{ 29 | calStr:=inputStr 30 | inputStr:="" 31 | } 32 | 33 | eqSignPos:=RegExMatch(calStr, " ?= ?$", eqSign) 34 | if(eqSignPos) 35 | StringMid, calStr2, calStr, % eqSignPos-1, , L 36 | else 37 | calStr2:=calStr 38 | 39 | 40 | 41 | ; 如果在计算板,则修复js的浮点计算错误 42 | ; e.g. 0.1+0.2=0.30000000000000004 43 | ; 函数体在 lib/lib_jsEval.ahk 44 | 45 | if(isScratch) 46 | result:=eval("fixFloatCalcRudely(" . calStr2 . ")") 47 | else if(CLSets.global.javascriptOriginalReturn) ; 如果.ini设置了javascriptOriginalReturn=1,则返回原js结果 48 | result:=eval(calStr2) 49 | else 50 | result:=eval("fixFloatCalcRudely(" . calStr2 . ")") 51 | 52 | 53 | if(result="") 54 | result:="?" 55 | 56 | if(isScratch){ 57 | if(eqSignPos){ 58 | inputStr .= calStr2 . eqSign . result 59 | }else{ 60 | inputStr .= calStr2 . "=" . result 61 | } 62 | }else if(eqSignPos){ 63 | inputStr .= calStr2 . eqSign . result 64 | }else{ 65 | inputStr .= result 66 | } 67 | 68 | return inputStr 69 | } 70 | 71 | tabAction() 72 | { 73 | ClipboardOld:=ClipboardAll 74 | selText:=getSelText() 75 | 76 | if(selText) 77 | { 78 | ; 让caps+tab支持这样: 79 | ; o.type = obj.type||''; 80 | ; ->sort() 81 | ; 选中以上两行再caps+tab,等价于: 82 | ;sort("o.type = obj.type||'';") 83 | selText:=strSelected2Script(selText) 84 | 85 | Clipboard := clCalculate(selText,calResult) 86 | } 87 | else 88 | { 89 | Clipboard:="" 90 | SendInput, +{Home} 91 | sleep, 10 ;make sure text is selecting 92 | SendInput, ^{c} 93 | ClipWait, 0.1 94 | if(!ErrorLevel) 95 | { 96 | if(!CLhotString()) 97 | { 98 | ; text2Script:=strSelected2Script(Clipboard) 99 | ; if(text2Script != Clipboard) 100 | ; Clipboard := clCalculate(text2Script,calResult) 101 | ; else 102 | Clipboard := clCalculate(Clipboard,calResult,1) 103 | } 104 | } 105 | } 106 | SendInput, ^{v} 107 | Sleep, 200 108 | Clipboard:=ClipboardOld 109 | return calResult 110 | } 111 | 112 | -------------------------------------------------------------------------------- /lib/lib_functions.ahk: -------------------------------------------------------------------------------- 1 | ;为了避免在IDE里Ctrl+C会复制一行,写个函数来获取 2 | getSelText_testVersion() 3 | { 4 | ClipboardOld:=ClipboardAll 5 | Clipboard:="" 6 | SendInput, +{Left}^{c}+{Right} 7 | ClipWait, 0.1 8 | if(!ErrorLevel) 9 | { 10 | selText:=Clipboard 11 | Clipboard:=ClipboardOld 12 | ;~ MsgBox, % "@" . Asc(selText) . "@" 13 | ;~ MsgBox, % StrLen(selText) 14 | if(Asc(selText)!=13&&StrLen(selText)>1) 15 | { 16 | return SubStr(selText, 2) 17 | } 18 | else 19 | { 20 | return 21 | } 22 | } 23 | Clipboard:=ClipboardOld 24 | return 25 | } 26 | 27 | 28 | getSelText() 29 | { 30 | ClipboardOld:=ClipboardAll 31 | Clipboard:="" 32 | SendInput, ^{insert} 33 | ClipWait, 0.1 34 | if(!ErrorLevel) 35 | { 36 | selText:=Clipboard 37 | Clipboard:=ClipboardOld 38 | StringRight, lastChar, selText, 1 39 | if(Asc(lastChar)!=10) ;如果最后一个字符是换行符,就认为是在IDE那复制了整行,不要这个结果 40 | { 41 | return selText 42 | } 43 | } 44 | Clipboard:=ClipboardOld 45 | return 46 | } 47 | 48 | UTF8encode(str) ;UTF8转码 49 | { 50 | SetFormat, integer, h 51 | returnStr:="" 52 | StrCap := StrPut(str, "CP65001") 53 | VarSetCapacity(UTF8String, StrCap) 54 | StrPut(str, &UTF8String, "CP65001") 55 | 56 | Loop, % StrCap - 1 ;StrPut 返回的长度中包含末尾的字符串截止符,因此必须减 1。 57 | { 58 | returnStr .= "%"SubStr(NumGet(UTF8String, A_Index - 1, "UChar"), 3) ; 逐字节获取,去除开头的“0x”后在前面加上"%"连接起来。 59 | } 60 | ;~ MsgBox, % returnStr ; 显示“E4B8AD”,前面附加“0x”就变成十六进制了。 61 | return returnStr 62 | } 63 | 64 | URLencode(str) ;用于链接的话只要符号转换就行。需要全部转换的,用UTF8encode() 65 | { 66 | local arr1:=["!","#","$","&","'","(",")","*","+",",",":",";","=","?","@","[","]"], ;"/", 67 | arr2:=["%21","%23","%24","%26","%27","%28","%29","%2a","%2b","%2c","%3a","%3b","%3d","%3f","%40","%5b","%5d"] ;"%2f", 68 | 69 | loop, % arr1.MaxIndex() 70 | { 71 | StringReplace, str, str, % arr1[A_Index], % arr2[A_Index], All 72 | } 73 | ; MsgBox, % str 74 | return str 75 | } 76 | 77 | 78 | checkStrType(str, fuzzy:=0) 79 | { 80 | if(!FileExist(str)) 81 | { 82 | ; msgbox, % str 83 | if(RegExMatch(str,"iS)^((https?:\/\/)|www\.)([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?|(https?:\/\/)?([\da-z\.-]+)\.(com|net|org)(\W[\/\w \.-]*)*\/?$")) 84 | return "web" 85 | } 86 | if(RegExMatch(str, "i)^ftp://")) 87 | return "ftp" 88 | else 89 | { 90 | if(fuzzy) 91 | return "fileOrFolder" 92 | if(RegExMatch(str,"iS)^[a-z]:\\.+\..+$")) 93 | return "file" 94 | if(RegExMatch(str,"iS)^[a-z]:\\[^.]*$")) 95 | return "folder" 96 | } 97 | return "unknown" 98 | } 99 | 100 | ;winset, region窗口切割功能在放大了屏幕后(也就是dpi改变)不会改变,这里用来修复这个问题 101 | ; 100%dpi:96 102 | ; 125%dpi:120 103 | ; 150%dpi:144 104 | ; 200%dpi:192 105 | ; 250%dpi:240 106 | ; 300%dpi:288 107 | ; 400%dpi:384 108 | ; 500%dpi:480 109 | fixDpi(num) 110 | { 111 | ;msgbox, % Ceil(1/96*A_ScreenDPI) 112 | t:=Ceil(num/96*A_ScreenDPI) 113 | if(A_ScreenDPI>96 && A_ScreenDPI<=120) ;125% 114 | t+=1 115 | if(A_ScreenDPI>120 && A_ScreenDPI<=144) ;150 116 | t+=1 117 | if(A_ScreenDPI>144 && A_ScreenDPI<=192) ;200% 118 | t+=2 119 | if(A_ScreenDPI>192 && A_ScreenDPI<=240) ;250 120 | t+=3 121 | if(A_ScreenDPI>240 && A_ScreenDPI<=288) ;300% 122 | t+=4 123 | if(A_ScreenDPI>288) ; && A_ScreenDPI<=384 >=400% 124 | t+=6 125 | return t 126 | } 127 | 128 | 129 | 130 | ;保存设置到settings.ini 131 | setSettings(sec,key,val) 132 | { 133 | IniWrite, % val, CapsLock+settings.ini, %sec%, % key 134 | } 135 | 136 | ;显示一个信息 137 | showMsg(msg,t:=2000) 138 | { 139 | ToolTip, % msg 140 | t:=-t 141 | settimer, clearToolTip, % t 142 | } 143 | 144 | clearToolTip: 145 | ToolTip 146 | return 147 | 148 | 149 | ;提取Set里QRun的信息 150 | ;返回文件路径,runStr为供run运行的字符串,ifAdmin是否管理员权限运行,param程序运行参数 151 | extractSetStr(str, ByRef runStr:="", ByRef ifAdmin:=false, ByRef param:="") 152 | { 153 | str:=Trim(str, " `t") 154 | 155 | ;如果有系统变量,替换成实际路径 156 | if(!RegExMatch(str, "^%(\w+)%", str0Match)) 157 | RegExMatch(str, "(?<=(?:'|""))%(\w+)%", str0Match) 158 | if(str0Match1) 159 | { 160 | EnvGet, _t, % str0Match1 161 | StringReplace, str, str, % str0Match, % _t 162 | } 163 | 164 | ;没有引号且文件存在,例:C:\Program Files\Internet Explorer\iexplore.exe 165 | ;或者是ftp路径 166 | if(FileExist(str)||RegExMatch(str, "^ftp://")) 167 | { 168 | runStr:=str 169 | return str 170 | } 171 | 172 | 173 | ;有引号且文件存在,例:"C:\Program Files\Internet Explorer\iexplore.exe" 174 | RegExMatch(str, "^('|"")(.*)\1$", strMatch) 175 | if(FileExist(strMatch2)||RegExMatch(str, "^ftp://")) 176 | { 177 | runStr:=str 178 | return strMatch2 179 | } 180 | 181 | RegExMatch(str, "('|"")(.*)\1", strMatch) 182 | if(FileExist(strMatch2)) 183 | { 184 | runStr:=strMatch 185 | ;判断是否管理员权限 186 | strArr:=StrSplit(str, strMatch) 187 | arr1:=Trim(strArr[1]) 188 | arr2:=Trim(strArr[2]) 189 | 190 | if(RegExMatch(arr1,"i)^\*RunAs$")) 191 | { 192 | ifAdmin:=true 193 | runStr:="*RunAs " . runStr 194 | } 195 | ;如果有参数 196 | if(arr2) 197 | { 198 | param:=arr2 199 | runStr:=runStr . " " . arr2 200 | } 201 | return strMatch2 202 | } 203 | return 204 | } 205 | 206 | alert(str) 207 | { 208 | msgbox, % str 209 | return 210 | } 211 | 212 | ;将set.ini里的QRun字符串转换成run使用的字符串 213 | ;如果文件(夹)不存在,会返回空 214 | set2Run(str) 215 | { 216 | runStr:="" 217 | extractSetStr(str, runStr) 218 | ; msgbox, % runStr 219 | return runStr 220 | } 221 | 222 | ;用来修复 excel 里复制一整行(列)会报错的问题 223 | ;弹出这个 gui 再进行赋值操作,然后回去 224 | foolGui(switch=1){ 225 | 226 | if !switch 227 | { 228 | Gui, foolgui:Destroy 229 | return 230 | } 231 | 232 | Gui, foolgui: -Caption +E0x80000 +LastFound +OwnDialogs +Owner 233 | Gui, foolgui: Show, NA, foolgui 234 | WinActivate, foolgui 235 | } 236 | 237 | clipSaver(clipX) 238 | { 239 | global 240 | if(WinActive("ahk_exe EXCEL.EXE")) 241 | { 242 | foolgui() 243 | if(clipX="s") 244 | sClipboardAll:=ClipboardAll 245 | else if(clipX="c") 246 | cClipboardAll:=ClipboardAll 247 | else ; if(clipX="ca") 248 | caClipboardAll:=ClipboardAll 249 | foolgui(0) 250 | } 251 | else 252 | { 253 | if(clipX="s") 254 | sClipboardAll:=ClipboardAll 255 | else if(clipX="c") 256 | cClipboardAll:=ClipboardAll 257 | else ; if(clipX="ca") 258 | caClipboardAll:=ClipboardAll 259 | } 260 | } 261 | 262 | ;字符串中的特殊字符转义 263 | ; escapeCharForString(str){ 264 | ; ; StringReplace, str, str, ``, ````, All 265 | ; ; StringReplace, str, str, ", `"`", All 266 | ; StringReplace, str, str, \", ", All 267 | ; StringReplace, str, str, \', ', All 268 | ; StringReplace, str, str, \\, \, All 269 | 270 | ; return str 271 | ; } 272 | 273 | ;运行函数字符串,被运行的函数的参数只接收字符串,参数分割按 CSV 方式 274 | ; 最多支持3个参数 275 | runFunc(str){ 276 | ;如果只给了函数名,没有括号,当做是不传参直接调用函数 277 | if(!RegExMatch(Trim(str), "\)$")) 278 | { 279 | %str%() 280 | return 281 | } 282 | if(RegExMatch(str, "(\w+)\((.*)\)$", match)) 283 | { 284 | func:=Func(match1) 285 | 286 | if(!match2) 287 | { 288 | func.() 289 | return 290 | } 291 | ; msgbox, % "match2" . match2 292 | ; pos := 1, params:=[] 293 | ; While pos := RegExMatch(match2, "(?:""((?:[^""\\]|\\.)*)"")|(?:'((?:[^'\\]|\\.)*)')", matchB, pos+StrLen(matchB)) 294 | ; { 295 | ; if(matchB1) 296 | ; params.insert(matchB1) 297 | ; else if(match2) 298 | ; params.insert(matchB2) 299 | ; } 300 | 301 | ; parmasLen:=params.MaxIndex() 302 | 303 | params:={} 304 | loop, Parse, match2, CSV 305 | { 306 | params.insert(A_LoopField) 307 | } 308 | 309 | parmasLen:=params.MaxIndex() 310 | 311 | if(parmasLen==1) 312 | { 313 | func.(params[1]) 314 | return 315 | } 316 | if(parmasLen==2) 317 | { 318 | func.(params[1],params[2]) 319 | return 320 | } 321 | if(parmasLen==3) 322 | { 323 | func.(params[1],params[2],params[3]) 324 | return 325 | } 326 | } 327 | } 328 | 329 | 330 | 331 | 332 | ; 例子: 当您按下 Win+C 时隐藏鼠标光标. 再次按下 Win+C 显示. 333 | ; 此脚本来自 www.autohotkey.com/forum/topic6107.html 334 | SystemCursor(OnOff:=1) ; 初始化 = "I","Init"; 隐藏 = 0,"Off"; 切换 = -1,"T","Toggle"; 显示 = 其他 335 | { 336 | static AndMask, XorMask, $, h_cursor 337 | ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; 系统指针 338 | , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 ; 空白指针 339 | , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13 ; 默认指针的句柄 340 | if (OnOff = "Init" or OnOff = "I" or $ = "") ; 在请求或首此调用时进行初始化 341 | { 342 | $ = h ; 活动的默认指针 343 | VarSetCapacity( h_cursor,4444, 1 ) 344 | VarSetCapacity( AndMask, 32*4, 0xFF ) 345 | VarSetCapacity( XorMask, 32*4, 0 ) 346 | system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650 347 | StringSplit c, system_cursors, `, 348 | Loop %c0% 349 | { 350 | h_cursor := DllCall( "LoadCursor", "Ptr",0, "Ptr",c%A_Index% ) 351 | h%A_Index% := DllCall( "CopyImage", "Ptr",h_cursor, "UInt",2, "Int",0, "Int",0, "UInt",0 ) 352 | b%A_Index% := DllCall( "CreateCursor", "Ptr",0, "Int",0, "Int",0 353 | , "Int",32, "Int",32, "Ptr",&AndMask, "Ptr",&XorMask ) 354 | } 355 | } 356 | if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T")) 357 | $ = b ; 使用空白指针 358 | else 359 | $ = h ; 使用保存的指针 360 | 361 | Loop %c0% 362 | { 363 | h_cursor := DllCall( "CopyImage", "Ptr",%$%%A_Index%, "UInt",2, "Int",0, "Int",0, "UInt",0 ) 364 | DllCall( "SetSystemCursor", "Ptr",h_cursor, "UInt",c%A_Index% ) 365 | } 366 | } 367 | -------------------------------------------------------------------------------- /lib/lib_init.ahk: -------------------------------------------------------------------------------- 1 | ;~ 初始化段,也就是自动运行段,所有需要自动运行的代码放这里,然后放到程序最开头 2 | SetTimer, initAll, -400 ;等个100毫秒,等待其他文件的include都完成 3 | 4 | return 5 | 6 | initAll: 7 | Suspend, On ;挂起所有热键 8 | 9 | IniRead, loadingAnimation, CapsLock+settings.ini, Global, loadingAnimation, 1 10 | IniRead, language, CapsLock+settings.ini, Global, language, 0 11 | 12 | if(loadingAnimation != "0") 13 | gosub, showLoading 14 | 15 | ;------------ language ----------- 16 | ; language:=CLsets.global.language 17 | 18 | ; 字符串初始化,这个要第一个运行 19 | ; if(language and IsLabel("language_" . language)) 20 | ; gosub, language_%language% 21 | ; else if(getSystemLanguage() == "Chinese_PRC") 22 | ; gosub, language_Simplified_Chinese 23 | ; else if(getSystemLanguage() == "Chinese_Hong_Kong" or getSystemLanguage() == "Chinese_Taiwan") 24 | ; gosub, language_Traditional_Chinese 25 | ; else 26 | ; gosub, language_English 27 | 28 | 29 | if(isLangChinese()) 30 | { 31 | gosub, language_Simplified_Chinese 32 | } else { 33 | gosub, language_English 34 | } 35 | ;------------ /language ----------- 36 | 37 | gosub, settingsInit ;初始化设置 38 | 39 | 40 | gosub, bindWinsInit 41 | 42 | gosub, jsEval_init 43 | setTimer, youdaoApiInit, -1 ;初始化翻译api 44 | gosub, getDefaultBrowser 45 | 46 | global needInitQ:=1 ;+q初始化标志位 47 | CLq() ;初始化+q 48 | 49 | setTimer, mouseSpeedInit, -1 50 | Suspend, Off 51 | 52 | if(loadingAnimation != "0") 53 | gosub, hideLoading 54 | 55 | return 56 | 57 | getDefaultBrowser: 58 | global defaultBrowser 59 | ;获取默认浏览器图标,QWeb的listview用 60 | RegRead, defaultBrowser, HKCU, SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice, ProgId 61 | RegRead, defaultBrowser, HKLM, SOFTWARE\Classes\%defaultBrowser%\shell\open\command 62 | RegExMatch(defaultBrowser, "[a-zA-Z]:\\[\s\S]*\.exe", defaultBrowser) 63 | ;~ MsgBox, % defaultBrowser 64 | if(defaultBrowser="") 65 | defaultBrowser:="C:\Program Files (x86)\Internet Explorer\IExplore.exe" 66 | return 67 | -------------------------------------------------------------------------------- /lib/lib_jsEval.ahk: -------------------------------------------------------------------------------- 1 | jsEval_init: 2 | ;comObjError(0) ;关闭 com 对象的报错 3 | gosub, scriptDemoInit 4 | ; 使用ie11引擎实现计算功能,经测试,如果自带引擎低于11,会自动使用自带的最新引擎 5 | FixIE(11) 6 | 7 | global obj:=ComObjCreate("HTMLfile") 8 | 9 | ;---load javascript--- 10 | 11 | ;build-in script 12 | buildInScript= 13 | ( LTrim 14 | 37 | ) 38 | obj.write(buildInScript) 39 | buildInScript:="" 40 | 41 | ;custom script 42 | ifexist, loadScript 43 | { 44 | jsfiles:=StrSplit(CLSets.Global.loadScript, ",", " `t") 45 | loop, % jsfiles.MaxIndex() 46 | { 47 | obj.write("") 53 | } 54 | } 55 | return 56 | 57 | 58 | eval(exp) 59 | { 60 | global obj 61 | exp:=escapeString(exp) 62 | 63 | obj.write("") 64 | return inStr(cabbage:=obj.body.innerText, "body") ? "ERROR" : cabbage 65 | } 66 | 67 | escapeString(string){ 68 | ;escape http://www.w3school.com.cn/js/js_special_characters.asp 69 | string:=regExReplace(string, "('|""|&|\\|\\n|\\r|\\t|\\b|\\f)", "\$1") 70 | 71 | ;replace all newline character to '\n' 72 | string:=regExReplace(string, "\R", "\n") 73 | return string 74 | } 75 | 76 | 77 | strSelected2Script(selText){ 78 | ; 允许这样使用caps+tab: 79 | ; o.type = obj.type||''; 80 | ; ->sort() 81 | ; 等价于: 82 | ;sort("o.type = obj.type||'';") 83 | ; funcArr:={} 84 | 85 | ; regex:="(?:((?(3)\s*|\R*)->\s*([\w.]*(\((?>'[^'\\]*(?:\\.[^'\\]*)*'|""[^""\\]*(?:\\.[^""\\]*)*""|[^""'()]++|(?3))*\)))))+\s*\z" 86 | regex:="\R[ \t]*?\..+\(.*\)\s*$" 87 | 88 | matchFuncPos:=RegExMatch(selText, regex, funcMatch) 89 | 90 | if(matchFuncPos) 91 | { 92 | selText := SubStr(selText,1,matchFuncPos) 93 | 94 | selText := escapeString(selText) 95 | 96 | selText := "'" . selText . "'" . RegExReplace(funcMatch, "(^\s*)|(\s*$)") 97 | ; regex:="(\s*->\s*([\w.]+\((?>'[^'\\]*(?:\\.[^'\\]*)*'|""[^""\\]*(?:\\.[^""\\]*)*""|[^""'()]++|(?1))*\)))$" 98 | ; loop 99 | ; { 100 | 101 | ; sliceFuncPos:=RegExMatch(funcMatch, regex, sliceFuncMatch) 102 | ; if(sliceFuncPos) 103 | ; { 104 | ; funcArr.Insert(sliceFuncMatch2) 105 | ; funcMatch := SubStr(funcMatch,1,sliceFuncPos-1) 106 | ; } 107 | ; else 108 | ; break 109 | ; } 110 | 111 | } 112 | 113 | ; if(funcArr.MaxIndex()) 114 | ; { 115 | ; ;just the innermost need escape char and quotes 116 | ; selText := escapeString(selText) 117 | ; funcNow := funcArr.Remove() 118 | ; ; msgbox, % "funcNow" . funcNow 119 | ; if(RegExMatch(funcNow, "\(\S+\)")) 120 | ; selText := RegExReplace(funcNow, "\(", "('" . selText . "',") 121 | ; else 122 | ; selText := RegExReplace(funcNow, "\(", "('" . selText . "'") 123 | ; loop, % funcArr.MaxIndex() 124 | ; { 125 | ; funcNow := funcArr.Remove() 126 | ; if(RegExMatch(funcNow, "\(\S+\)")) 127 | ; selText := RegExReplace(funcNow, "\(", "(" . selText . ",") 128 | ; else 129 | ; selText := RegExReplace(funcNow, "\(", "(" . selText) 130 | ; msgbox, % selText 131 | ; } 132 | ; } 133 | ; msgbox, % selText 134 | return selText 135 | } 136 | 137 | FixIE(Version=0, ExeName="") 138 | { 139 | static Key := "Software\Microsoft\Internet Explorer" 140 | . "\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION" 141 | , Versions := {7:7000, 8:8888, 9:9999, 10:10001, 11:11001} 142 | 143 | if Versions.HasKey(Version) 144 | Version := Versions[Version] 145 | 146 | 147 | if !ExeName 148 | { 149 | if A_IsCompiled 150 | ExeName := A_ScriptName 151 | else 152 | SplitPath, A_AhkPath, ExeName 153 | } 154 | 155 | RegRead, PreviousValue, HKCU, %Key%, %ExeName% 156 | ; msgbox, % PreviousValue . "#" . Version 157 | if (Version = "") 158 | RegDelete, HKCU, %Key%, %ExeName% 159 | else if(PreviousValue != Version) 160 | RegWrite, REG_DWORD, HKCU, %Key%, %ExeName%, %Version% 161 | 162 | ; msgbox, % Version 163 | return PreviousValue 164 | } 165 | 166 | 167 | scriptDemoInit: 168 | ;init scriptDemo 169 | if(CLSets.Global.loadScript) 170 | { 171 | IfNotExist, loadScript 172 | { 173 | FileCreateDir, loadScript 174 | } 175 | IfNotExist, loadScript\scriptDemo.js 176 | { 177 | ; FileAppend, %scriptDemoJS%, loadScript\scriptDemo.js, UTF-8-RAW 178 | FileInstall, loadScript\scriptDemo.js, loadScript\scriptDemo.js 179 | } 180 | else 181 | { 182 | FileGetTime, setDemoModifyTime, loadScript\scriptDemo.js 183 | FileGetTime, thisScriptModifyTime, %A_ScriptName% 184 | 185 | thisScriptModifyTime -= setDemoModifyTime, S 186 | if(thisScriptModifyTime > 0) ;如果主程序文件比较新,那就是更新过,那就覆盖一遍 187 | { 188 | ; FileDelete, loadScript\scriptDemo.js 189 | ; FileAppend, %scriptDemoJS%, loadScript\scriptDemo.js, UTF-8-RAW 190 | FileInstall, loadScript\scriptDemo.js, loadScript\scriptDemo.js, 1 191 | } 192 | } 193 | IfNotExist, loadScript\debug.html 194 | { 195 | ; FileAppend, %debugHTML%, loadScript\debug.html, UTF-8-RAW 196 | FileInstall, loadScript\debug.html, loadScript\debug.html 197 | } 198 | } 199 | return -------------------------------------------------------------------------------- /lib/lib_json.ahk: -------------------------------------------------------------------------------- 1 | /** 2 | * Lib: JSON.ahk 3 | * JSON lib for AutoHotkey. 4 | * Version: 5 | * v2.1.3 [updated 04/18/2016 (MM/DD/YYYY)] 6 | * License: 7 | * WTFPL [http://wtfpl.net/] 8 | * Requirements: 9 | * Latest version of AutoHotkey (v1.1+ or v2.0-a+) 10 | * Installation: 11 | * Use #Include JSON.ahk or copy into a function library folder and then 12 | * use #Include 13 | * Links: 14 | * GitHub: - https://github.com/cocobelgica/AutoHotkey-JSON 15 | * Forum Topic - http://goo.gl/r0zI8t 16 | * Email: - cocobelgica gmail com 17 | */ 18 | 19 | 20 | /** 21 | * Class: JSON 22 | * The JSON object contains methods for parsing JSON and converting values 23 | * to JSON. Callable - NO; Instantiable - YES; Subclassable - YES; 24 | * Nestable(via #Include) - NO. 25 | * Methods: 26 | * Load() - see relevant documentation before method definition header 27 | * Dump() - see relevant documentation before method definition header 28 | */ 29 | class JSON 30 | { 31 | /** 32 | * Method: Load 33 | * Parses a JSON string into an AHK value 34 | * Syntax: 35 | * value := JSON.Load( text [, reviver ] ) 36 | * Parameter(s): 37 | * value [retval] - parsed value 38 | * text [in, ByRef] - JSON formatted string 39 | * reviver [in, opt] - function object, similar to JavaScript's 40 | * JSON.parse() 'reviver' parameter 41 | */ 42 | class Load extends JSON.Functor 43 | { 44 | Call(self, ByRef text, reviver:="") 45 | { 46 | this.rev := IsObject(reviver) ? reviver : false 47 | ; Object keys(and array indices) are temporarily stored in arrays so that 48 | ; we can enumerate them in the order they appear in the document/text instead 49 | ; of alphabetically. Skip if no reviver function is specified. 50 | this.keys := this.rev ? {} : false 51 | 52 | static quot := Chr(34), bashq := "\" . quot 53 | , json_value := quot . "{[01234567890-tfn" 54 | , json_value_or_array_closing := quot . "{[]01234567890-tfn" 55 | , object_key_or_object_closing := quot . "}" 56 | 57 | key := "" 58 | is_key := false 59 | root := {} 60 | stack := [root] 61 | next := json_value 62 | pos := 0 63 | 64 | while ((ch := SubStr(text, ++pos, 1)) != "") { 65 | if InStr(" `t`r`n", ch) 66 | continue 67 | if !InStr(next, ch, 1) 68 | this.ParseError(next, text, pos) 69 | 70 | holder := stack[1] 71 | is_array := holder.IsArray 72 | 73 | if InStr(",:", ch) { 74 | next := (is_key := !is_array && ch == ",") ? quot : json_value 75 | 76 | } else if InStr("}]", ch) { 77 | ObjRemoveAt(stack, 1) 78 | next := stack[1]==root ? "" : stack[1].IsArray ? ",]" : ",}" 79 | 80 | } else { 81 | if InStr("{[", ch) { 82 | ; Check if Array() is overridden and if its return value has 83 | ; the 'IsArray' property. If so, Array() will be called normally, 84 | ; otherwise, use a custom base object for arrays 85 | static json_array := Func("Array").IsBuiltIn || ![].IsArray ? {IsArray: true} : 0 86 | 87 | ; sacrifice readability for minor(actually negligible) performance gain 88 | (ch == "{") 89 | ? ( is_key := true 90 | , value := {} 91 | , next := object_key_or_object_closing ) 92 | ; ch == "[" 93 | : ( value := json_array ? new json_array : [] 94 | , next := json_value_or_array_closing ) 95 | 96 | ObjInsertAt(stack, 1, value) 97 | 98 | if (this.keys) 99 | this.keys[value] := [] 100 | 101 | } else { 102 | if (ch == quot) { 103 | i := pos 104 | while (i := InStr(text, quot,, i+1)) { 105 | value := StrReplace(SubStr(text, pos+1, i-pos-1), "\\", "\u005c") 106 | 107 | static tail := A_AhkVersion<"2" ? 0 : -1 108 | if (SubStr(value, tail) != "\") 109 | break 110 | } 111 | 112 | if (!i) 113 | this.ParseError("'", text, pos) 114 | 115 | value := StrReplace(value, "\/", "/") 116 | , value := StrReplace(value, bashq, quot) 117 | , value := StrReplace(value, "\b", "`b") 118 | , value := StrReplace(value, "\f", "`f") 119 | , value := StrReplace(value, "\n", "`n") 120 | , value := StrReplace(value, "\r", "`r") 121 | , value := StrReplace(value, "\t", "`t") 122 | 123 | pos := i ; update pos 124 | 125 | i := 0 126 | while (i := InStr(value, "\",, i+1)) { 127 | if !(SubStr(value, i+1, 1) == "u") 128 | this.ParseError("\", text, pos - StrLen(SubStr(value, i+1))) 129 | 130 | uffff := Abs("0x" . SubStr(value, i+2, 4)) 131 | if (A_IsUnicode || uffff < 0x100) 132 | value := SubStr(value, 1, i-1) . Chr(uffff) . SubStr(value, i+6) 133 | } 134 | 135 | if (is_key) { 136 | key := value, next := ":" 137 | continue 138 | } 139 | 140 | } else { 141 | value := SubStr(text, pos, i := RegExMatch(text, "[\]\},\s]|$",, pos)-pos) 142 | 143 | static number := "number", integer :="integer" 144 | if value is %number% 145 | { 146 | if value is %integer% 147 | value += 0 148 | } 149 | else if (value == "true" || value == "false") 150 | value := %value% + 0 151 | else if (value == "null") 152 | value := "" 153 | else 154 | ; we can do more here to pinpoint the actual culprit 155 | ; but that's just too much extra work. 156 | this.ParseError(next, text, pos, i) 157 | 158 | pos += i-1 159 | } 160 | 161 | next := holder==root ? "" : is_array ? ",]" : ",}" 162 | } ; If InStr("{[", ch) { ... } else 163 | 164 | is_array? key := ObjPush(holder, value) : holder[key] := value 165 | 166 | if (this.keys && this.keys.HasKey(holder)) 167 | this.keys[holder].Push(key) 168 | } 169 | 170 | } ; while ( ... ) 171 | 172 | return this.rev ? this.Walk(root, "") : root[""] 173 | } 174 | 175 | ParseError(expect, ByRef text, pos, len:=1) 176 | { 177 | static quot := Chr(34), qurly := quot . "}" 178 | 179 | line := StrSplit(SubStr(text, 1, pos), "`n", "`r").Length() 180 | col := pos - InStr(text, "`n",, -(StrLen(text)-pos+1)) 181 | msg := Format("{1}`n`nLine:`t{2}`nCol:`t{3}`nChar:`t{4}" 182 | , (expect == "") ? "Extra data" 183 | : (expect == "'") ? "Unterminated string starting at" 184 | : (expect == "\") ? "Invalid \escape" 185 | : (expect == ":") ? "Expecting ':' delimiter" 186 | : (expect == quot) ? "Expecting object key enclosed in double quotes" 187 | : (expect == qurly) ? "Expecting object key enclosed in double quotes or object closing '}'" 188 | : (expect == ",}") ? "Expecting ',' delimiter or object closing '}'" 189 | : (expect == ",]") ? "Expecting ',' delimiter or array closing ']'" 190 | : InStr(expect, "]") ? "Expecting JSON value or array closing ']'" 191 | : "Expecting JSON value(string, number, true, false, null, object or array)" 192 | , line, col, pos) 193 | 194 | static offset := A_AhkVersion<"2" ? -3 : -4 195 | throw Exception(msg, offset, SubStr(text, pos, len)) 196 | } 197 | 198 | Walk(holder, key) 199 | { 200 | value := holder[key] 201 | if IsObject(value) { 202 | for i, k in this.keys[value] { 203 | ; check if ObjHasKey(value, k) ?? 204 | v := this.Walk(value, k) 205 | if (v != JSON.Undefined) 206 | value[k] := v 207 | else 208 | ObjDelete(value, k) 209 | } 210 | } 211 | 212 | return this.rev.Call(holder, key, value) 213 | } 214 | } 215 | 216 | /** 217 | * Method: Dump 218 | * Converts an AHK value into a JSON string 219 | * Syntax: 220 | * str := JSON.Dump( value [, replacer, space ] ) 221 | * Parameter(s): 222 | * str [retval] - JSON representation of an AHK value 223 | * value [in] - any value(object, string, number) 224 | * replacer [in, opt] - function object, similar to JavaScript's 225 | * JSON.stringify() 'replacer' parameter 226 | * space [in, opt] - similar to JavaScript's JSON.stringify() 227 | * 'space' parameter 228 | */ 229 | class Dump extends JSON.Functor 230 | { 231 | Call(self, value, replacer:="", space:="") 232 | { 233 | this.rep := IsObject(replacer) ? replacer : "" 234 | 235 | this.gap := "" 236 | if (space) { 237 | static integer := "integer" 238 | if space is %integer% 239 | Loop, % ((n := Abs(space))>10 ? 10 : n) 240 | this.gap .= " " 241 | else 242 | this.gap := SubStr(space, 1, 10) 243 | 244 | this.indent := "`n" 245 | } 246 | 247 | return this.Str({"": value}, "") 248 | } 249 | 250 | Str(holder, key) 251 | { 252 | value := holder[key] 253 | 254 | if (this.rep) 255 | value := this.rep.Call(holder, key, ObjHasKey(holder, key) ? value : JSON.Undefined) 256 | 257 | if IsObject(value) { 258 | ; Check object type, skip serialization for other object types such as 259 | ; ComObject, Func, BoundFunc, FileObject, RegExMatchObject, Property, etc. 260 | static type := A_AhkVersion<"2" ? "" : Func("Type") 261 | if (type ? type.Call(value) == "Object" : ObjGetCapacity(value) != "") { 262 | if (this.gap) { 263 | stepback := this.indent 264 | this.indent .= this.gap 265 | } 266 | 267 | is_array := value.IsArray 268 | ; Array() is not overridden, rollback to old method of 269 | ; identifying array-like objects. Due to the use of a for-loop 270 | ; sparse arrays such as '[1,,3]' are detected as objects({}). 271 | if (!is_array) { 272 | for i in value 273 | is_array := i == A_Index 274 | until !is_array 275 | } 276 | 277 | str := "" 278 | if (is_array) { 279 | Loop, % value.Length() { 280 | if (this.gap) 281 | str .= this.indent 282 | 283 | v := this.Str(value, A_Index) 284 | str .= (v != "") ? v . "," : "null," 285 | } 286 | } else { 287 | colon := this.gap ? ": " : ":" 288 | for k in value { 289 | v := this.Str(value, k) 290 | if (v != "") { 291 | if (this.gap) 292 | str .= this.indent 293 | 294 | str .= this.Quote(k) . colon . v . "," 295 | } 296 | } 297 | } 298 | 299 | if (str != "") { 300 | str := RTrim(str, ",") 301 | if (this.gap) 302 | str .= stepback 303 | } 304 | 305 | if (this.gap) 306 | this.indent := stepback 307 | 308 | return is_array ? "[" . str . "]" : "{" . str . "}" 309 | } 310 | 311 | } else ; is_number ? value : "value" 312 | return ObjGetCapacity([value], 1)=="" ? value : this.Quote(value) 313 | } 314 | 315 | Quote(string) 316 | { 317 | static quot := Chr(34), bashq := "\" . quot 318 | 319 | if (string != "") { 320 | string := StrReplace(string, "\", "\\") 321 | ; , string := StrReplace(string, "/", "\/") ; optional in ECMAScript 322 | , string := StrReplace(string, quot, bashq) 323 | , string := StrReplace(string, "`b", "\b") 324 | , string := StrReplace(string, "`f", "\f") 325 | , string := StrReplace(string, "`n", "\n") 326 | , string := StrReplace(string, "`r", "\r") 327 | , string := StrReplace(string, "`t", "\t") 328 | 329 | static rx_escapable := A_AhkVersion<"2" ? "O)[^\x20-\x7e]" : "[^\x20-\x7e]" 330 | while RegExMatch(string, rx_escapable, m) 331 | string := StrReplace(string, m.Value, Format("\u{1:04x}", Ord(m.Value))) 332 | } 333 | 334 | return quot . string . quot 335 | } 336 | } 337 | 338 | /** 339 | * Property: Undefined 340 | * Proxy for 'undefined' type 341 | * Syntax: 342 | * undefined := JSON.Undefined 343 | * Remarks: 344 | * For use with reviver and replacer functions since AutoHotkey does not 345 | * have an 'undefined' type. Returning blank("") or 0 won't work since these 346 | * can't be distnguished from actual JSON values. This leaves us with objects. 347 | * Replacer() - the caller may return a non-serializable AHK objects such as 348 | * ComObject, Func, BoundFunc, FileObject, RegExMatchObject, and Property to 349 | * mimic the behavior of returning 'undefined' in JavaScript but for the sake 350 | * of code readability and convenience, it's better to do 'return JSON.Undefined'. 351 | * Internally, the property returns a ComObject with the variant type of VT_EMPTY. 352 | */ 353 | Undefined[] 354 | { 355 | get { 356 | static empty := {}, vt_empty := ComObject(0, &empty, 1) 357 | return vt_empty 358 | } 359 | } 360 | 361 | class Functor 362 | { 363 | __Call(method, ByRef arg, args*) 364 | { 365 | ; When casting to Call(), use a new instance of the "function object" 366 | ; so as to avoid directly storing the properties(used across sub-methods) 367 | ; into the "function object" itself. 368 | if IsObject(method) 369 | return (new this).Call(method, arg, args*) 370 | else if (method == "") 371 | return (new this).Call(arg, args*) 372 | } 373 | } 374 | } -------------------------------------------------------------------------------- /lib/lib_keysFunction.ahk: -------------------------------------------------------------------------------- 1 | ; keys functions start------------- 2 | ; 所有按键对应功能都放在这,为防止从set.ini通过按键设置调用到非按键功能函数, 3 | ; 规定函数以"keyFunc_"开头 4 | 5 | keyFunc_doNothing(){ 6 | return 7 | } 8 | 9 | keyFunc_test(){ 10 | MsgBox, , , testing, 1 11 | return 12 | } 13 | 14 | keyFunc_send(p){ 15 | sendinput, % p 16 | return 17 | } 18 | 19 | keyFunc_run(p){ 20 | run, % p 21 | return 22 | } 23 | 24 | keyFunc_toggleCapsLock(){ 25 | SetCapsLockState, % GetKeyState("CapsLock","T") ? "Off" : "On" 26 | return 27 | } 28 | 29 | keyFunc_mouseSpeedIncrease(){ 30 | global 31 | mouseSpeed+=1 32 | if(mouseSpeed>20) 33 | { 34 | mouseSpeed:=20 35 | } 36 | showMsg("mouse speed: " . mouseSpeed, 1000) 37 | setSettings("Global","mouseSpeed",mouseSpeed) 38 | return 39 | } 40 | 41 | 42 | keyFunc_mouseSpeedDecrease(){ 43 | global 44 | mouseSpeed-=1 45 | if(mouseSpeed<1) 46 | { 47 | mouseSpeed:=1 48 | } 49 | showMsg("mouse speed: " . mouseSpeed, 1000) 50 | setSettings("Global","mouseSpeed",mouseSpeed) 51 | return 52 | } 53 | 54 | 55 | keyFunc_moveLeft(i:=1){ 56 | SendInput, {left %i%} 57 | return 58 | } 59 | 60 | 61 | keyFunc_moveRight(i:=1){ 62 | SendInput, {right %i%} 63 | Return 64 | } 65 | 66 | 67 | keyFunc_moveUp(i:=1){ 68 | global 69 | if(WinActive("ahk_id" . GuiHwnd)) 70 | { 71 | ControlFocus, , ahk_id %LV_show_Hwnd% 72 | SendInput, {Up %i%} 73 | Sleep, 5 74 | ControlFocus, , ahk_id %editHwnd% 75 | } 76 | else 77 | SendInput,{up %i%} 78 | Return 79 | } 80 | 81 | 82 | keyFunc_moveDown(i:=1){ 83 | global 84 | if(WinActive("ahk_id" . GuiHwnd)) 85 | { 86 | ControlFocus, , ahk_id %LV_show_Hwnd% 87 | SendInput, {Down %i%} 88 | Sleep, 5 89 | ControlFocus, , ahk_id %editHwnd% 90 | } 91 | else 92 | SendInput,{down %i%} 93 | Return 94 | } 95 | 96 | 97 | keyFunc_moveWordLeft(i:=1){ 98 | SendInput,^{Left %i%} 99 | Return 100 | } 101 | 102 | 103 | keyFunc_moveWordRight(i:=1){ 104 | SendInput,^{Right %i%} 105 | Return 106 | } 107 | 108 | 109 | keyFunc_backspace(){ 110 | SendInput,{backspace} 111 | Return 112 | } 113 | 114 | 115 | keyFunc_delete(){ 116 | SendInput,{delete} 117 | Return 118 | } 119 | 120 | keyFunc_deleteAll(){ 121 | SendInput, ^{a}{delete} 122 | Return 123 | } 124 | 125 | keyFunc_deleteWord(){ 126 | SendInput, +^{left} 127 | SendInput, {delete} 128 | Return 129 | } 130 | 131 | 132 | keyFunc_forwardDeleteWord(){ 133 | SendInput, +^{right} 134 | SendInput, {delete} 135 | Return 136 | } 137 | 138 | 139 | keyFunc_translate(){ 140 | global 141 | selText:=getSelText() 142 | if(selText) 143 | { 144 | ydTranslate(selText) 145 | } 146 | else 147 | { 148 | ClipboardOld:=ClipboardAll 149 | Clipboard:="" 150 | SendInput, ^{Left}^+{Right}^{insert} 151 | ClipWait, 0.05 152 | selText:=Clipboard 153 | ydTranslate(selText) 154 | Clipboard:=ClipboardOld 155 | } 156 | SetTimer, setTransGuiActive, -400 157 | Return 158 | } 159 | 160 | 161 | keyFunc_end(){ 162 | SendInput,{End} 163 | Return 164 | } 165 | 166 | 167 | keyFunc_home(){ 168 | SendInput,{Home} 169 | Return 170 | } 171 | 172 | 173 | keyFunc_moveToPageBeginning(){ 174 | SendInput, ^{Home} 175 | Return 176 | } 177 | 178 | 179 | keyFunc_moveToPageEnd(){ 180 | SendInput, ^{End} 181 | Return 182 | } 183 | 184 | keyFunc_deleteLine(){ 185 | SendInput,{End}+{home}{bs} 186 | Return 187 | } 188 | 189 | keyFunc_deleteToLineBeginning(){ 190 | SendInput,+{Home}{bs} 191 | Return 192 | } 193 | 194 | keyFunc_deleteToLineEnd(){ 195 | SendInput,+{End}{bs} 196 | Return 197 | } 198 | 199 | keyFunc_deleteToPageBeginning(){ 200 | SendInput,+^{Home}{bs} 201 | Return 202 | } 203 | 204 | keyFunc_deleteToPageEnd(){ 205 | SendInput,+^{End}{bs} 206 | Return 207 | } 208 | 209 | keyFunc_enterWherever(){ 210 | SendInput,{End}{Enter} 211 | Return 212 | } 213 | 214 | keyFunc_esc(){ 215 | SendInput, {Esc} 216 | Return 217 | } 218 | 219 | keyFunc_enter(){ 220 | SendInput, {Enter} 221 | Return 222 | } 223 | 224 | ;双字符 225 | keyFunc_doubleChar(char1,char2:=""){ 226 | if(char2=="") 227 | { 228 | char2:=char1 229 | } 230 | charLen:=StrLen(char2) 231 | selText:=getSelText() 232 | ClipboardOld:=ClipboardAll 233 | if(selText) 234 | { 235 | Clipboard:=char1 . selText . char2 236 | SendInput, +{insert} 237 | } 238 | else 239 | { 240 | Clipboard:=char1 . char2 241 | SendInput, +{insert} 242 | ; prevent the left input from interrupting the paste (may occur in vscode) 243 | ; fact: tests show that 50ms is not enough 244 | Sleep, 75 245 | SendInput, {left %charLen%} 246 | } 247 | Sleep, 100 248 | Clipboard:=ClipboardOld 249 | Return 250 | } 251 | 252 | keyFunc_sendChar(char){ 253 | ClipboardOld:=ClipboardAll 254 | Clipboard:=char 255 | SendInput, +{insert} 256 | Sleep, 50 257 | Clipboard:=ClipboardOld 258 | return 259 | } 260 | 261 | keyFunc_doubleAngle(){ 262 | if(!keyFunc_qbar_upperFolderPath()) 263 | keyFunc_doubleChar("<",">") 264 | return 265 | } 266 | 267 | keyFunc_pageUp(){ 268 | global 269 | if(WinActive("ahk_id" . GuiHwnd)) 270 | { 271 | ControlFocus, , ahk_id %LV_show_Hwnd% 272 | SendInput, {PgUp} 273 | ControlFocus, , ahk_id %editHwnd% 274 | } 275 | else 276 | SendInput, {PgUp} 277 | return 278 | } 279 | 280 | 281 | keyFunc_pageDown(){ 282 | global 283 | if(WinActive("ahk_id" . GuiHwnd)) 284 | { 285 | ControlFocus, , ahk_id %LV_show_Hwnd% 286 | SendInput, {PgDn} 287 | ControlFocus, , ahk_id %editHwnd% 288 | } 289 | else 290 | SendInput, {PgDn} 291 | Return 292 | } 293 | 294 | ;页面向上移动一页,光标不动 295 | keyFunc_pageMoveUp(){ 296 | SendInput, ^{PgUp} 297 | return 298 | } 299 | 300 | ;页面向下移动一页,光标不动 301 | keyFunc_pageMoveDown(){ 302 | SendInput, ^{PgDn} 303 | return 304 | } 305 | 306 | keyFunc_switchClipboard(){ 307 | global 308 | if(CLsets.global.allowClipboard) 309 | { 310 | CLsets.global.allowClipboard:="0" 311 | setSettings("Global","allowClipboard","0") 312 | showMsg("Clipboard OFF",1500) 313 | } 314 | else 315 | { 316 | CLsets.global.allowClipboard:="1" 317 | setSettings("Global","allowClipboard","1") 318 | showMsg("Clipboard ON",1500) 319 | } 320 | return 321 | } 322 | 323 | 324 | keyFunc_pasteSystem(){ 325 | global 326 | 327 | ; ; 328 | ; 禁止 OnClipboardChange 运行,防止 Clipboard:=sClipboardAll 重复执行,导致偶尔会粘贴出空白 329 | ; if(!CLsets.global.allowClipboard) ;禁用剪贴板功能 330 | ; { 331 | ; CapsLock2:="" 332 | ; return 333 | ; } 334 | if (whichClipboardNow!=0) 335 | { 336 | allowRunOnClipboardChange:=false 337 | Clipboard:=sClipboardAll 338 | whichClipboardNow:=0 339 | } 340 | SendInput, ^{v} 341 | return 342 | } 343 | 344 | 345 | keyFunc_cut_1(){ 346 | global 347 | if(CLsets.global.allowClipboard="0") ;禁用剪贴板功能 348 | { 349 | CapsLock2:="" 350 | return 351 | } 352 | 353 | ClipboardOld:=ClipboardAll 354 | Clipboard:="" 355 | SendInput, ^{x} 356 | ClipWait, 0.1 357 | if (ErrorLevel) 358 | { 359 | SendInput,{home}+{End}^{x} 360 | ClipWait, 0.1 361 | } 362 | if (!ErrorLevel) 363 | { 364 | ;cClipboardAll:=ClipboardAll 365 | clipSaver("c") 366 | whichClipboardNow:=1 367 | } 368 | else 369 | { 370 | Clipboard:=ClipboardOld 371 | } 372 | Return 373 | } 374 | 375 | 376 | keyFunc_copy_1(){ 377 | global 378 | if(CLsets.global.allowClipboard="0") ;禁用剪贴板功能 379 | { 380 | CapsLock2:="" 381 | return 382 | } 383 | 384 | ClipboardOld:=ClipboardAll 385 | Clipboard:="" 386 | SendInput, ^{insert} 387 | ClipWait, 0.1 388 | if (ErrorLevel) 389 | { 390 | SendInput,{home}+{End}^{insert}{End} 391 | ClipWait, 0.1 392 | } 393 | if (!ErrorLevel) 394 | { 395 | ; cClipboardAll:=ClipboardAll 396 | clipSaver("c") 397 | whichClipboardNow:=1 398 | } 399 | else 400 | { 401 | Clipboard:=ClipboardOld 402 | } 403 | return 404 | } 405 | 406 | 407 | keyFunc_paste_1(){ 408 | global 409 | if(CLsets.global.allowClipboard="0") ;禁用剪贴板功能 410 | { 411 | CapsLock2:="" 412 | return 413 | } 414 | 415 | if (whichClipboardNow!=1) 416 | { 417 | Clipboard:=cClipboardAll 418 | whichClipboardNow:=1 419 | } 420 | SendInput, ^{v} 421 | Return 422 | } 423 | 424 | 425 | keyFunc_undoRedo(){ 426 | global 427 | if(ctrlZ) 428 | { 429 | SendInput, ^{z} 430 | ctrlZ:="" 431 | } 432 | Else 433 | { 434 | SendInput, ^{y} 435 | ctrlZ:=1 436 | } 437 | Return 438 | } 439 | 440 | 441 | keyFunc_cut_2(){ 442 | global 443 | if(CLsets.global.allowClipboard="0") ;禁用剪贴板功能 444 | { 445 | CapsLock2:="" 446 | return 447 | } 448 | 449 | ClipboardOld:=ClipboardAll 450 | Clipboard:="" 451 | SendInput, ^{x} 452 | ClipWait, 0.1 453 | if (ErrorLevel) 454 | { 455 | SendInput,{home}+{End}^{x} 456 | ClipWait, 0.1 457 | } 458 | if (!ErrorLevel) 459 | { 460 | ; caClipboardAll:=ClipboardAll 461 | clipSaver("ca") 462 | whichClipboardNow:=2 463 | } 464 | else 465 | { 466 | Clipboard:=ClipboardOld 467 | } 468 | Return 469 | } 470 | 471 | 472 | keyFunc_copy_2(){ 473 | global 474 | if(CLsets.global.allowClipboard="0") ;禁用剪贴板功能 475 | { 476 | CapsLock2:="" 477 | return 478 | } 479 | 480 | ClipboardOld:=ClipboardAll 481 | Clipboard:="" 482 | SendInput, ^{insert} 483 | ClipWait, 0.1 484 | if (ErrorLevel) 485 | { 486 | SendInput,{home}+{End}^{insert}{End} 487 | ClipWait, 0.1 488 | } 489 | if (!ErrorLevel) 490 | { 491 | ; caClipboardAll:=ClipboardAll 492 | clipSaver("ca") 493 | whichClipboardNow:=2 494 | } 495 | else 496 | { 497 | Clipboard:=ClipboardOld 498 | } 499 | return 500 | } 501 | 502 | 503 | keyFunc_paste_2(){ 504 | global 505 | if(CLsets.global.allowClipboard="0") ;禁用剪贴板功能 506 | { 507 | CapsLock2:="" 508 | return 509 | } 510 | 511 | if (whichClipboardNow!=2) 512 | { 513 | Clipboard:=caClipboardAll 514 | whichClipboardNow:=2 515 | } 516 | SendInput, ^{v} 517 | Return 518 | } 519 | 520 | 521 | keyFunc_qbar(){ 522 | global 523 | SetTimer, setCLqActive, 50 524 | ;先关闭所有Caps热键,然后再打开 525 | ;防止其他功能在 qbar 出来这段时间因为输入文字而被触发 526 | CapsLock:=CapsLock2:="" 527 | CLq() 528 | CapsLock:=1 529 | return 530 | 531 | setCLqActive: 532 | IfWinExist, ahk_id %GuiHwnd% 533 | { 534 | SetTimer, ,Off 535 | WinActivate, ahk_id %GuiHwnd% 536 | } 537 | return 538 | } 539 | 540 | 541 | keyFunc_tabPrve(){ 542 | SendInput, ^+{tab} 543 | return 544 | } 545 | 546 | 547 | keyFunc_tabNext(){ 548 | SendInput, ^{tab} 549 | return 550 | } 551 | 552 | 553 | keyFunc_jumpPageTop(){ 554 | SendInput, ^{Home} 555 | return 556 | } 557 | 558 | 559 | keyFunc_jumpPageBottom(){ 560 | SendInput, ^{End} 561 | return 562 | } 563 | 564 | 565 | keyFunc_selectUp(i:=1){ 566 | SendInput, +{Up %i%} 567 | return 568 | } 569 | 570 | 571 | keyFunc_selectDown(i:=1){ 572 | SendInput, +{Down %i%} 573 | return 574 | } 575 | 576 | 577 | keyFunc_selectLeft(i:=1){ 578 | SendInput, +{Left %i%} 579 | return 580 | } 581 | 582 | 583 | keyFunc_selectRight(i:=1){ 584 | SendInput, +{Right %i%} 585 | return 586 | } 587 | 588 | 589 | keyFunc_selectHome(){ 590 | SendInput, +{Home} 591 | return 592 | } 593 | 594 | 595 | keyFunc_selectEnd(){ 596 | SendInput, +{End} 597 | return 598 | } 599 | 600 | keyFunc_selectToPageBeginning(){ 601 | SendInput, +^{Home} 602 | return 603 | } 604 | 605 | 606 | keyFunc_selectToPageEnd(){ 607 | SendInput, +^{End} 608 | return 609 | } 610 | 611 | 612 | keyFunc_selectCurrentWord(){ 613 | SendInput, ^{Left} 614 | SendInput, +^{Right} 615 | return 616 | } 617 | 618 | 619 | keyFunc_selectCurrentLine(){ 620 | SendInput, {Home} 621 | SendInput, +{End} 622 | return 623 | } 624 | 625 | 626 | keyFunc_selectWordLeft(i:=1){ 627 | SendInput, +^{Left %i%} 628 | return 629 | } 630 | 631 | 632 | keyFunc_selectWordRight(i:=1){ 633 | SendInput, +^{Right %i%} 634 | return 635 | } 636 | 637 | ;页面移动一行,光标不动 638 | keyFunc_pageMoveLineUp(i:=1){ 639 | SendInput, ^{Up %i%} 640 | return 641 | } 642 | 643 | 644 | keyFunc_pageMoveLineDown(i:=1){ 645 | SendInput, ^{Down %i%} 646 | return 647 | } 648 | 649 | 650 | 651 | keyFunc_getJSEvalString(){ 652 | global 653 | ClipboardOld:=ClipboardAll 654 | Clipboard:="" 655 | SendInput, ^{insert} ; 656 | ClipWait, 0.1 657 | if(!ErrorLevel) 658 | { 659 | result:=escapeString(Clipboard) 660 | inputbox, result,,%lang_kf_getDebugText%,,,,,,,, % result 661 | if(!ErrorLevel) 662 | { 663 | Clipboard:=result 664 | 665 | return 666 | } 667 | } 668 | Sleep, 200 669 | Clipboard:=ClipboardOld 670 | return 671 | } 672 | 673 | 674 | keyFunc_tabScript(){ 675 | tabAction() 676 | Return 677 | } 678 | 679 | 680 | keyFunc_openCpasDocs(){ 681 | if(isLangChinese()) 682 | { 683 | Run, https://capslox.com/capslock-plus 684 | } else { 685 | Run, https://capslox.com/capslock-plus/en.html 686 | } 687 | return 688 | } 689 | 690 | 691 | keyFunc_mediaPrev(){ 692 | SendInput, {Media_Prev} 693 | return 694 | } 695 | 696 | 697 | keyFunc_mediaNext(){ 698 | SendInput, {Media_Next} 699 | return 700 | } 701 | 702 | 703 | keyFunc_mediaPlayPause(){ 704 | SendInput, {Media_Play_Pause} 705 | return 706 | } 707 | 708 | 709 | keyFunc_volumeUp(){ 710 | SendInput, {Volume_Up} 711 | return 712 | } 713 | 714 | 715 | keyFunc_volumeDown(){ 716 | SendInput, {Volume_Down} 717 | return 718 | } 719 | 720 | 721 | keyFunc_volumeMute(){ 722 | SendInput, {Volume_Mute} 723 | return 724 | } 725 | 726 | 727 | keyFunc_reload(){ 728 | MsgBox, , , reload, 0.5 729 | Reload 730 | return 731 | } 732 | 733 | keyFunc_send_dot(){ 734 | if(!keyFunc_qbar_lowerFolderPath()) 735 | SendInput, {U+002e} 736 | return 737 | } 738 | 739 | ;qbar中跳到上层文件路径 740 | keyFunc_qbar_upperFolderPath(){ 741 | global 742 | if(!WinActive("ahk_id" . GuiHwnd)) 743 | { 744 | return 745 | } 746 | if(LVlistsType=0) 747 | { 748 | 749 | return true 750 | } 751 | ControlGetText, editText, , ahk_id %editHwnd% 752 | ; if(historyIndex>1) 753 | ; historyIndex-- 754 | 755 | ; _t:=qbarPathHistory[historyIndex+1] 756 | ; if(_t=editText) 757 | ; { 758 | ; editText:=qbarPathHistory[historyIndex] 759 | ; } 760 | ; else 761 | ; editText:=_t 762 | qbarPathFuture.insert(editText) ;记录路径历史 763 | editText := RegExReplace(editText,"i)([^\\]*\\|[^\\]*)$") 764 | ; ifInsertHistory:=0 ;禁止记录地址 765 | ifClearFuture:=0 766 | ControlSetText, , %editText%, ahk_id %editHwnd% 767 | sendinput, {end} 768 | return true 769 | } 770 | 771 | ;qbar中跳到下层文件路径 772 | keyFunc_qbar_lowerFolderPath(){ 773 | global 774 | if(!WinActive("ahk_id" . GuiHwnd)) 775 | { 776 | return 777 | } 778 | ; ifInsertHistory:=0 ;禁止记录地址 779 | editText:=qbarPathFuture.remove() 780 | if(editText) 781 | { 782 | ifClearFuture:=0 783 | ControlSetText, , %editText%, ahk_id %editHwnd% 784 | sendinput, {end} 785 | } 786 | return true 787 | } 788 | 789 | ;winbind------------- 790 | keyFunc_winbind_activate(n){ 791 | global 792 | activateWinAction(n) 793 | return 794 | } 795 | 796 | 797 | keyFunc_winbind_binding(n){ 798 | global 799 | if(tapTimes[n]=="") 800 | initWinsInfos(n) 801 | tapTimes(n) 802 | return 803 | } 804 | 805 | 806 | keyFunc_winPin(){ 807 | _id:=WinExist("A") 808 | ; WinGet, ExStyle, ExStyle 809 | ; if (ExStyle & 0x8) 810 | ; { 811 | ; WinSet, AlwaysOnTop, Off 812 | ; WinSet, Transparent, Off 813 | ; 814 | ; return 815 | ; } 816 | WinSet, AlwaysOnTop 817 | ; WinSet, Transparent, 210 818 | return 819 | } 820 | 821 | 822 | keyFunc_goCjkPage(){ 823 | global 824 | run, http://cjkis.me 825 | return 826 | } 827 | 828 | ; 鼠标左键点击 829 | keyfunc_click_left(){ 830 | Click, Left 831 | } 832 | 833 | ; 鼠标右键点击 834 | keyfunc_click_right(){ 835 | Click, Right 836 | } 837 | 838 | ; 移动鼠标 839 | keyfunc_mouse_up(){ 840 | MouseMove, 0, -dynamic_speed(), 0, R 841 | } 842 | 843 | keyfunc_mouse_down(){ 844 | MouseMove, 0, dynamic_speed(), 0, R 845 | } 846 | 847 | keyfunc_mouse_left(){ 848 | MouseMove, -dynamic_speed(), 0, 0, R 849 | } 850 | 851 | keyfunc_mouse_right(){ 852 | MouseMove, dynamic_speed(), 0, 0, R 853 | } 854 | 855 | ; 上滑滚轮 856 | keyfunc_wheel_up(){ 857 | Send, {WheelUp 3} 858 | } 859 | 860 | ; 下滑滚轮 861 | keyfunc_wheel_down(){ 862 | Send, {Wheeldown 3} 863 | } 864 | 865 | 866 | ;keys functions end------------- 867 | 868 | 869 | ; 判断是否为连续点击,连续点击时指数增加移动速度 870 | ; init 初始单次移动距离 871 | ; a 加速度 872 | ; max 最大单次移动距离 873 | dynamic_speed(init:=10, a:=0.2, max:=80) 874 | { 875 | static N := 0 876 | if (A_ThisHotkey = A_PriorHotkey) and (A_TimeSincePriorHotkey < 300) 877 | N += a 878 | else 879 | N = 0 880 | return Min(Floor(init+Exp(N)), max) 881 | } 882 | 883 | 884 | ; testing area --- 885 | 886 | keyFunc_activateSideWin(UDLR){ 887 | activateSideWin(UDLR) 888 | } 889 | 890 | keyFunc_putWinToBottom(){ 891 | putWinToBottom() 892 | } 893 | 894 | keyFunc_winJumpIgnore(){ 895 | winJumpIgnore() 896 | } 897 | 898 | keyFunc_clearWinMinimizeStach(){ 899 | clearWinMinimizeStach() 900 | } 901 | 902 | keyFunc_popWinMinimizeStack(){ 903 | popWinMinimizeStack() 904 | } 905 | 906 | keyFunc_pushWinMinimizeStack(){ 907 | pushWinMinimizeStack() 908 | } 909 | 910 | keyFunc_unshiftWinMinimizeStack(){ 911 | unshiftWinMinimizeStack() 912 | } 913 | 914 | keyFunc_winTransparent(){ 915 | winTransparent() 916 | } -------------------------------------------------------------------------------- /lib/lib_keysSet.ahk: -------------------------------------------------------------------------------- 1 | ;如果没有在set.ini设置按键的话,就按这里的默认设置执行 2 | keysInit: 3 | global keyset:=CLSets.Keys 4 | 5 | 6 | if(!CLSets.global.default_hotkey_scheme) 7 | ; "capslox" | “capslock-plus” 8 | CLSets.global.default_hotkey_scheme:="capslox" 9 | 10 | if(CLSets.global.default_hotkey_scheme == "capslock_plus") { 11 | keySchemeInit_capslockPlus() 12 | } else { 13 | keySchemeInit_capslox() 14 | } 15 | 16 | return 17 | 18 | 19 | keySchemeInit_capslox(){ 20 | global 21 | 22 | if(!keyset.press_caps) 23 | keyset.press_caps:="keyFunc_toggleCapsLock" 24 | ; keyset.press_caps:="keyFunc_esc" 25 | 26 | if(!keyset.caps_a) 27 | keyset.caps_a:="keyFunc_moveWordLeft" 28 | if(!keyset.caps_b) 29 | keyset.caps_b:="keyFunc_moveDown(10)" 30 | if(!keyset.caps_c) 31 | keyset.caps_c:="keyFunc_copy_1" 32 | if(!keyset.caps_d) 33 | keyset.caps_d:="keyFunc_moveDown" 34 | if(!keyset.caps_e) 35 | keyset.caps_e:="keyFunc_moveUp" 36 | if(!keyset.caps_f) 37 | keyset.caps_f:="keyFunc_moveRight" 38 | if(!keyset.caps_g) 39 | keyset.caps_g:="keyFunc_moveWordRight" 40 | if(!keyset.caps_h) 41 | keyset.caps_h:="keyFunc_selectWordLeft" 42 | if(!keyset.caps_i) 43 | keyset.caps_i:="keyFunc_selectUp" 44 | if(!keyset.caps_j) 45 | keyset.caps_j:="keyFunc_selectLeft" 46 | if(!keyset.caps_k) 47 | keyset.caps_k:="keyFunc_selectDown" 48 | if(!keyset.caps_l) 49 | keyset.caps_l:="keyFunc_selectRight" 50 | if(!keyset.caps_m) 51 | keyset.caps_m:="keyFunc_doNothing" 52 | if(!keyset.caps_n) 53 | keyset.caps_n:="keyFunc_selectDown(10)" 54 | if(!keyset.caps_o) 55 | keyset.caps_o:="keyFunc_selectEnd" 56 | if(!keyset.caps_p) 57 | keyset.caps_p:="keyFunc_home" 58 | if(!keyset.caps_q) 59 | keyset.caps_q:="keyFunc_qbar" 60 | if(!keyset.caps_r) 61 | keyset.caps_r:="keyFunc_delete" 62 | if(!keyset.caps_s) 63 | keyset.caps_s:="keyFunc_moveLeft" 64 | if(!keyset.caps_t) 65 | keyset.caps_t:="keyFunc_moveUp(10)" 66 | if(!keyset.caps_u) 67 | keyset.caps_u:="keyFunc_selectHome" 68 | if(!keyset.caps_v) 69 | keyset.caps_v:="keyFunc_paste_1" 70 | if(!keyset.caps_w) 71 | keyset.caps_w:="keyFunc_backspace" 72 | if(!keyset.caps_x) 73 | keyset.caps_x:="keyFunc_cut_1" 74 | if(!keyset.caps_y) 75 | keyset.caps_y:="keyFunc_selectUp(10)" 76 | if(!keyset.caps_z) 77 | keyset.caps_z:="keyFunc_doNothing" 78 | 79 | if(!keyset.caps_backquote) 80 | keyset.caps_backquote:="keyFunc_doNothing" 81 | if(!keyset.caps_1) 82 | keyset.caps_1:="keyFunc_winbind_activate(1)" 83 | if(!keyset.caps_2) 84 | keyset.caps_2:="keyFunc_winbind_activate(2)" 85 | if(!keyset.caps_3) 86 | keyset.caps_3:="keyFunc_winbind_activate(3)" 87 | if(!keyset.caps_4) 88 | keyset.caps_4:="keyFunc_winbind_activate(4)" 89 | if(!keyset.caps_5) 90 | keyset.caps_5:="keyFunc_winbind_activate(5)" 91 | if(!keyset.caps_6) 92 | keyset.caps_6:="keyFunc_winbind_activate(6)" 93 | if(!keyset.caps_7) 94 | keyset.caps_7:="keyFunc_winbind_activate(7)" 95 | if(!keyset.caps_8) 96 | keyset.caps_8:="keyFunc_winbind_activate(8)" 97 | if(!keyset.caps_9) 98 | keyset.caps_9:="keyFunc_winbind_activate(9)" 99 | if(!keyset.caps_0) 100 | keyset.caps_0:="keyFunc_winbind_activate(10)" 101 | if(!keyset.caps_minus) 102 | keyset.caps_minus:="keyFunc_qbar_upperFolderPath" 103 | if(!keyset.caps_equal) 104 | keyset.caps_equal:="keyFunc_qbar_lowerFolderPath" 105 | if(!keyset.caps_backspace) 106 | keyset.caps_backspace:="keyFunc_deleteLine" 107 | if(!keyset.caps_tab) 108 | keyset.caps_tab:="keyFunc_tabScript" 109 | if(!keyset.caps_leftSquareBracket) 110 | keyset.caps_leftSquareBracket:="keyFunc_deleteToLineBeginning" 111 | if(!keyset.caps_rightSquareBracket) 112 | keyset.caps_rightSquareBracket:="keyFunc_doNothing" 113 | if(!keyset.caps_backslash) 114 | keyset.caps_backslash:="keyFunc_doNothing" 115 | if(!keyset.caps_semicolon) 116 | keyset.caps_semicolon:="keyFunc_end" 117 | if(!keyset.caps_quote) 118 | keyset.caps_quote:="keyFunc_doNothing" 119 | if(!keyset.caps_enter) 120 | keyset.caps_enter:="keyFunc_enterWherever" 121 | if(!keyset.caps_comma) 122 | keyset.caps_comma:="keyFunc_selectCurrentWord" 123 | if(!keyset.caps_dot) 124 | keyset.caps_dot:="keyFunc_selectWordRight" 125 | if(!keyset.caps_slash) 126 | keyset.caps_slash:="keyFunc_deleteToLineEnd" 127 | if(!keyset.caps_space) 128 | keyset.caps_space:="keyFunc_enter" 129 | if(!keyset.caps_ralt) 130 | keyset.caps_ralt:="keyFunc_doNothing" 131 | 132 | if(!keyset.caps_f1) 133 | keyset.caps_f1:="keyFunc_openCpasDocs" 134 | if(!keyset.caps_f2) 135 | keyset.caps_f2:="keyFunc_mathBoard" 136 | if(!keyset.caps_f3) 137 | keyset.caps_f3:="keyFunc_translate" 138 | if(!keyset.caps_f4) 139 | keyset.caps_f4:="keyFunc_winTransparent" 140 | if(!keyset.caps_f5) 141 | keyset.caps_f5:="keyFunc_reload" 142 | if(!keyset.caps_f6) 143 | keyset.caps_f6:="keyFunc_winPin" 144 | if(!keyset.caps_f7) 145 | keyset.caps_f7:="keyFunc_doNothing" 146 | if(!keyset.caps_f8) 147 | keyset.caps_f8:="keyFunc_getJSEvalString" 148 | if(!keyset.caps_f9) 149 | keyset.caps_f9:="keyFunc_doNothing" 150 | if(!keyset.caps_f10) 151 | keyset.caps_f10:="keyFunc_doNothing" 152 | if(!keyset.caps_f11) 153 | keyset.caps_f11:="keyFunc_doNothing" 154 | if(!keyset.caps_f12) 155 | keyset.caps_f12:="keyFunc_switchClipboard" 156 | 157 | ; LAlt-------------------------------------------- 158 | 159 | if(!keyset.caps_lalt_a) 160 | keyset.caps_lalt_a:="keyFunc_moveWordLeft(3)" 161 | if(!keyset.caps_lalt_b) 162 | keyset.caps_lalt_b:="keyFunc_moveDown(30)" 163 | if(!keyset.caps_lalt_c) 164 | keyset.caps_lalt_c:="keyFunc_copy_2" 165 | if(!keyset.caps_lalt_d) 166 | keyset.caps_lalt_d:="keyFunc_moveDown(3)" 167 | if(!keyset.caps_lalt_e) 168 | keyset.caps_lalt_e:="keyFunc_moveUp(3)" 169 | if(!keyset.caps_lalt_f) 170 | keyset.caps_lalt_f:="keyFunc_moveRight(5)" 171 | if(!keyset.caps_lalt_g) 172 | keyset.caps_lalt_g:="keyFunc_moveWordRight(3)" 173 | if(!keyset.caps_lalt_h) 174 | keyset.caps_lalt_h:="keyFunc_selectWordLeft(3)" 175 | if(!keyset.caps_lalt_i) 176 | keyset.caps_lalt_i:="keyFunc_selectUp(3)" 177 | if(!keyset.caps_lalt_j) 178 | keyset.caps_lalt_j:="keyFunc_selectLeft(5)" 179 | if(!keyset.caps_lalt_k) 180 | keyset.caps_lalt_k:="keyFunc_selectDown(3)" 181 | if(!keyset.caps_lalt_l) 182 | keyset.caps_lalt_l:="keyFunc_selectRight(5)" 183 | if(!keyset.caps_lalt_m) 184 | keyset.caps_lalt_m:="keyFunc_doNothing" 185 | if(!keyset.caps_lalt_n) 186 | keyset.caps_lalt_n:="keyFunc_selectDown(30)" 187 | if(!keyset.caps_lalt_o) 188 | keyset.caps_lalt_o:="keyFunc_selectToPageEnd" 189 | if(!keyset.caps_lalt_p) 190 | keyset.caps_lalt_p:="keyFunc_moveToPageBeginning" 191 | if(!keyset.caps_lalt_q) 192 | keyset.caps_lalt_q:="keyFunc_doNothing" 193 | if(!keyset.caps_lalt_r) 194 | keyset.caps_lalt_r:="keyFunc_forwardDeleteWord" 195 | if(!keyset.caps_lalt_s) 196 | keyset.caps_lalt_s:="keyFunc_moveLeft(5)" 197 | if(!keyset.caps_lalt_t) 198 | keyset.caps_lalt_t:="keyFunc_moveUp(30)" 199 | if(!keyset.caps_lalt_u) 200 | keyset.caps_lalt_u:="keyFunc_selectToPageBeginning" 201 | if(!keyset.caps_lalt_v) 202 | keyset.caps_lalt_v:="keyFunc_paste_2" 203 | if(!keyset.caps_lalt_w) 204 | keyset.caps_lalt_w:="keyFunc_deleteWord" 205 | if(!keyset.caps_lalt_x) 206 | keyset.caps_lalt_x:="keyFunc_cut_2" 207 | if(!keyset.caps_lalt_y) 208 | keyset.caps_lalt_y:="keyFunc_selectUp(30)" 209 | if(!keyset.caps_lalt_z) 210 | keyset.caps_lalt_z:="keyFunc_doNothing" 211 | 212 | if(!keyset.caps_lalt_backquote) 213 | keyset.caps_lalt_backquote:="keyFunc_doNothing" 214 | if(!keyset.caps_lalt_1) 215 | keyset.caps_lalt_1:="keyFunc_winbind_binding(1)" 216 | if(!keyset.caps_lalt_2) 217 | keyset.caps_lalt_2:="keyFunc_winbind_binding(2)" 218 | if(!keyset.caps_lalt_3) 219 | keyset.caps_lalt_3:="keyFunc_winbind_binding(3)" 220 | if(!keyset.caps_lalt_4) 221 | keyset.caps_lalt_4:="keyFunc_winbind_binding(4)" 222 | if(!keyset.caps_lalt_5) 223 | keyset.caps_lalt_5:="keyFunc_winbind_binding(5)" 224 | if(!keyset.caps_lalt_6) 225 | keyset.caps_lalt_6:="keyFunc_winbind_binding(6)" 226 | if(!keyset.caps_lalt_7) 227 | keyset.caps_lalt_7:="keyFunc_winbind_binding(7)" 228 | if(!keyset.caps_lalt_8) 229 | keyset.caps_lalt_8:="keyFunc_winbind_binding(8)" 230 | if(!keyset.caps_lalt_9) 231 | keyset.caps_lalt_9:="keyFunc_winbind_binding(9)" 232 | if(!keyset.caps_lalt_0) 233 | keyset.caps_lalt_0:="keyFunc_winbind_binding(10)" 234 | if(!keyset.caps_lalt_minus) 235 | keyset.caps_lalt_minus:="keyFunc_doNothing" 236 | if(!keyset.caps_lalt_equal) 237 | keyset.caps_lalt_equal:="keyFunc_doNothing" 238 | if(!keyset.caps_lalt_backspace) 239 | keyset.caps_lalt_backspace:="keyFunc_deleteAll" 240 | if(!keyset.caps_lalt_tab) 241 | keyset.caps_lalt_tab:="keyFunc_doNothing" 242 | if(!keyset.caps_lalt_leftSquareBracket) 243 | keyset.caps_lalt_leftSquareBracket:="keyFunc_deleteToPageBeginning" 244 | if(!keyset.caps_lalt_rightSquareBracket) 245 | keyset.caps_lalt_rightSquareBracket:="keyFunc_doNothing" 246 | if(!keyset.caps_lalt_backslash) 247 | keyset.caps_lalt_backslash:="keyFunc_doNothing" 248 | if(!keyset.caps_lalt_semicolon) 249 | keyset.caps_lalt_semicolon:="keyFunc_moveToPageEnd" 250 | if(!keyset.caps_lalt_quote) 251 | keyset.caps_lalt_quote:="keyFunc_doNothing" 252 | if(!keyset.caps_lalt_enter) 253 | keyset.caps_lalt_enter:="keyFunc_doNothing" 254 | if(!keyset.caps_lalt_comma) 255 | keyset.caps_lalt_comma:="keyFunc_selectCurrentLine" 256 | if(!keyset.caps_lalt_dot) 257 | keyset.caps_lalt_dot:="keyFunc_selectWordRight(3)" 258 | if(!keyset.caps_lalt_slash) 259 | keyset.caps_lalt_slash:="keyFunc_deleteToPageEnd" 260 | if(!keyset.caps_lalt_space) 261 | keyset.caps_lalt_space:="keyFunc_doNothing" 262 | if(!keyset.caps_lalt_ralt) 263 | keyset.caps_lalt_ralt:="keyFunc_doNothing" 264 | 265 | ;--------------------window------------------- 266 | if(!keyset.caps_win_1) 267 | keyset.caps_win_1:="keyFunc_winbind_binding(1)" 268 | if(!keyset.caps_win_2) 269 | keyset.caps_win_2:="keyFunc_winbind_binding(2)" 270 | if(!keyset.caps_win_3) 271 | keyset.caps_win_3:="keyFunc_winbind_binding(3)" 272 | if(!keyset.caps_win_4) 273 | keyset.caps_win_4:="keyFunc_winbind_binding(4)" 274 | if(!keyset.caps_win_5) 275 | keyset.caps_win_5:="keyFunc_winbind_binding(5)" 276 | if(!keyset.caps_win_6) 277 | keyset.caps_win_6:="keyFunc_winbind_binding(6)" 278 | if(!keyset.caps_win_7) 279 | keyset.caps_win_7:="keyFunc_winbind_binding(7)" 280 | if(!keyset.caps_win_8) 281 | keyset.caps_win_8:="keyFunc_winbind_binding(8)" 282 | if(!keyset.caps_win_9) 283 | keyset.caps_win_9:="keyFunc_winbind_binding(9)" 284 | if(!keyset.caps_win_0) 285 | keyset.caps_win_0:="keyFunc_winbind_binding(10)" 286 | 287 | ;--------------------other-------------------- 288 | 289 | if(!keyset.caps_lalt_wheelUp) 290 | keyset.caps_lalt_wheelUp:="keyFunc_mouseSpeedIncrease" 291 | if(!keyset.caps_lalt_wheelDown) 292 | keyset.caps_lalt_wheelDown:="keyFunc_mouseSpeedDecrease" 293 | 294 | return 295 | } 296 | 297 | 298 | 299 | ;---------------------------------------------------- 300 | keySchemeInit_capslockPlus(){ 301 | global 302 | 303 | if(!keyset.press_caps) 304 | keyset.press_caps:="keyFunc_toggleCapsLock" 305 | 306 | if(!keyset.caps_a) 307 | keyset.caps_a:="keyFunc_moveWordLeft" 308 | if(!keyset.caps_b) 309 | keyset.caps_b:="keyFunc_moveDown(5)" 310 | if(!keyset.caps_c) 311 | keyset.caps_c:="keyFunc_copy_1" 312 | if(!keyset.caps_d) 313 | keyset.caps_d:="keyFunc_moveDown" 314 | if(!keyset.caps_e) 315 | keyset.caps_e:="keyFunc_moveUp" 316 | if(!keyset.caps_f) 317 | keyset.caps_f:="keyFunc_moveRight" 318 | if(!keyset.caps_g) 319 | keyset.caps_g:="keyFunc_moveWordRight" 320 | if(!keyset.caps_h) 321 | keyset.caps_h:="keyFunc_selectWordLeft" 322 | if(!keyset.caps_i) 323 | keyset.caps_i:="keyFunc_selectUp" 324 | if(!keyset.caps_j) 325 | keyset.caps_j:="keyFunc_selectLeft" 326 | if(!keyset.caps_k) 327 | keyset.caps_k:="keyFunc_selectDown" 328 | if(!keyset.caps_l) 329 | keyset.caps_l:="keyFunc_selectRight" 330 | if(!keyset.caps_m) 331 | keyset.caps_m:="keyFunc_selectDown(5)" 332 | if(!keyset.caps_n) 333 | keyset.caps_n:="keyFunc_selectWordRight" 334 | if(!keyset.caps_o) 335 | keyset.caps_o:="keyFunc_selectEnd" 336 | if(!keyset.caps_p) 337 | keyset.caps_p:="keyFunc_home" 338 | if(!keyset.caps_q) 339 | keyset.caps_q:="keyFunc_qbar" 340 | if(!keyset.caps_r) 341 | keyset.caps_r:="keyFunc_delete" 342 | if(!keyset.caps_s) 343 | keyset.caps_s:="keyFunc_moveLeft" 344 | if(!keyset.caps_t) 345 | keyset.caps_t:="keyFunc_translate" 346 | if(!keyset.caps_u) 347 | keyset.caps_u:="keyFunc_selectHome" 348 | if(!keyset.caps_v) 349 | keyset.caps_v:="keyFunc_paste_1" 350 | if(!keyset.caps_w) 351 | keyset.caps_w:="keyFunc_backspace" 352 | if(!keyset.caps_x) 353 | keyset.caps_x:="keyFunc_cut_1" 354 | if(!keyset.caps_y) 355 | keyset.caps_y:="keyFunc_moveUp(5)" 356 | if(!keyset.caps_z) 357 | keyset.caps_z:="keyFunc_undoRedo" 358 | 359 | if(!keyset.caps_backquote) 360 | keyset.caps_backquote:="keyFunc_winbind_activate(9)" 361 | if(!keyset.caps_1) 362 | keyset.caps_1:="keyFunc_winbind_activate(1)" 363 | if(!keyset.caps_2) 364 | keyset.caps_2:="keyFunc_winbind_activate(2)" 365 | if(!keyset.caps_3) 366 | keyset.caps_3:="keyFunc_winbind_activate(3)" 367 | if(!keyset.caps_4) 368 | keyset.caps_4:="keyFunc_winbind_activate(4)" 369 | if(!keyset.caps_5) 370 | keyset.caps_5:="keyFunc_winbind_activate(5)" 371 | if(!keyset.caps_6) 372 | keyset.caps_6:="keyFunc_winbind_activate(6)" 373 | if(!keyset.caps_7) 374 | keyset.caps_7:="keyFunc_winbind_activate(7)" 375 | if(!keyset.caps_8) 376 | keyset.caps_8:="keyFunc_winbind_activate(8)" 377 | if(!keyset.caps_9) 378 | keyset.caps_9:="keyFunc_doubleChar((,))" 379 | if(!keyset.caps_0) 380 | keyset.caps_0:="keyFunc_selectUp(5)" 381 | if(!keyset.caps_minus) 382 | keyset.caps_minus:="keyFunc_pageUp" 383 | if(!keyset.caps_equal) 384 | keyset.caps_equal:="keyFunc_pageDown" 385 | if(!keyset.caps_backspace) 386 | keyset.caps_backspace:="keyFunc_deleteLine" 387 | if(!keyset.caps_tab) 388 | keyset.caps_tab:="keyFunc_tabScript" 389 | if(!keyset.caps_leftSquareBracket) 390 | keyset.caps_leftSquareBracket:="keyFunc_doubleChar({,})" 391 | if(!keyset.caps_rightSquareBracket) 392 | keyset.caps_rightSquareBracket:="keyFunc_doubleChar([,])" 393 | if(!keyset.caps_backslash) 394 | keyset.caps_backslash:="keyFunc_doNothing" 395 | if(!keyset.caps_semicolon) 396 | keyset.caps_semicolon:="keyFunc_end" 397 | if(!keyset.caps_quote) 398 | keyset.caps_quote:="keyFunc_doubleChar("""""""","""""""")" 399 | if(!keyset.caps_enter) 400 | keyset.caps_enter:="keyFunc_enterWherever" 401 | if(!keyset.caps_comma) 402 | keyset.caps_comma:="keyFunc_doubleAngle" 403 | if(!keyset.caps_dot) 404 | keyset.caps_dot:="keyFunc_send_dot" 405 | if(!keyset.caps_slash) 406 | keyset.caps_slash:="keyFunc_doNothing" 407 | if(!keyset.caps_space) 408 | keyset.caps_space:="keyFunc_enter" 409 | if(!keyset.caps_ralt) 410 | keyset.caps_ralt:="keyFunc_doNothing" 411 | 412 | if(!keyset.caps_f1) 413 | keyset.caps_f1:="keyFunc_openCpasDocs" 414 | if(!keyset.caps_f2) 415 | keyset.caps_f2:="keyFunc_mathBoard" 416 | if(!keyset.caps_f3) 417 | keyset.caps_f3:="keyFunc_mediaNext" 418 | if(!keyset.caps_f4) 419 | keyset.caps_f4:="keyFunc_winTransparent" 420 | if(!keyset.caps_f5) 421 | keyset.caps_f5:="keyFunc_reload" 422 | if(!keyset.caps_f6) 423 | keyset.caps_f6:="keyFunc_winPin" 424 | if(!keyset.caps_f7) 425 | keyset.caps_f7:="keyFunc_doNothing" 426 | if(!keyset.caps_f8) 427 | keyset.caps_f8:="keyFunc_getJSEvalString" 428 | if(!keyset.caps_f9) 429 | keyset.caps_f9:="keyFunc_doNothing" 430 | if(!keyset.caps_f10) 431 | keyset.caps_f10:="keyFunc_doNothing" 432 | if(!keyset.caps_f11) 433 | keyset.caps_f11:="keyFunc_doNothing" 434 | if(!keyset.caps_f12) 435 | keyset.caps_f12:="keyFunc_switchClipboard" 436 | 437 | ; LAlt-------------------------------------------- 438 | 439 | if(!keyset.caps_lalt_a) 440 | keyset.caps_lalt_a:="keyFunc_activateSideWin(fl)" 441 | if(!keyset.caps_lalt_b) 442 | keyset.caps_lalt_b:="keyFunc_pageMoveLineDown(5)" 443 | if(!keyset.caps_lalt_c) 444 | keyset.caps_lalt_c:="keyFunc_copy_2" 445 | if(!keyset.caps_lalt_d) 446 | keyset.caps_lalt_d:="keyFunc_activateSideWin(d)" 447 | if(!keyset.caps_lalt_e) 448 | keyset.caps_lalt_e:="keyFunc_activateSideWin(u)" 449 | if(!keyset.caps_lalt_f) 450 | keyset.caps_lalt_f:="keyFunc_activateSideWin(r)" 451 | if(!keyset.caps_lalt_g) 452 | keyset.caps_lalt_g:="keyFunc_activateSideWin(fr)" 453 | if(!keyset.caps_lalt_h) 454 | keyset.caps_lalt_h:="keyFunc_clearWinMinimizeStach" 455 | if(!keyset.caps_lalt_i) 456 | keyset.caps_lalt_i:="keyFunc_doNothing" 457 | if(!keyset.caps_lalt_j) 458 | keyset.caps_lalt_j:="keyFunc_pushWinMinimizeStack" 459 | if(!keyset.caps_lalt_k) 460 | keyset.caps_lalt_k:="keyFunc_unshiftWinMinimizeStack" 461 | if(!keyset.caps_lalt_l) 462 | keyset.caps_lalt_l:="keyFunc_popWinMinimizeStack" 463 | if(!keyset.caps_lalt_m) 464 | keyset.caps_lalt_m:="keyFunc_doNothing" 465 | if(!keyset.caps_lalt_n) 466 | keyset.caps_lalt_n:="keyFunc_doNothing" 467 | if(!keyset.caps_lalt_o) 468 | keyset.caps_lalt_o:="keyFunc_doNothing" 469 | if(!keyset.caps_lalt_p) 470 | keyset.caps_lalt_p:="keyFunc_doNothing" 471 | if(!keyset.caps_lalt_q) 472 | keyset.caps_lalt_q:="keyFunc_activateSideWin(c)" 473 | if(!keyset.caps_lalt_r) 474 | keyset.caps_lalt_r:="keyFunc_tabNext" 475 | if(!keyset.caps_lalt_s) 476 | keyset.caps_lalt_s:="keyFunc_activateSideWin(l)" 477 | if(!keyset.caps_lalt_t) 478 | keyset.caps_lalt_t:="keyFunc_doNothing" 479 | if(!keyset.caps_lalt_u) 480 | keyset.caps_lalt_u:="keyFunc_doNothing" 481 | if(!keyset.caps_lalt_v) 482 | keyset.caps_lalt_v:="keyFunc_paste_2" 483 | if(!keyset.caps_lalt_w) 484 | keyset.caps_lalt_w:="keyFunc_tabPrve" 485 | if(!keyset.caps_lalt_x) 486 | keyset.caps_lalt_x:="keyFunc_cut_2" 487 | if(!keyset.caps_lalt_y) 488 | keyset.caps_lalt_y:="keyFunc_pageMoveLineUp(5)" 489 | if(!keyset.caps_lalt_z) 490 | keyset.caps_lalt_z:="keyFunc_putWinToBottom" 491 | 492 | if(!keyset.caps_lalt_backquote) 493 | keyset.caps_lalt_backquote:="keyFunc_winbind_binding(9)" 494 | if(!keyset.caps_lalt_1) 495 | keyset.caps_lalt_1:="keyFunc_winbind_binding(1)" 496 | if(!keyset.caps_lalt_2) 497 | keyset.caps_lalt_2:="keyFunc_winbind_binding(2)" 498 | if(!keyset.caps_lalt_3) 499 | keyset.caps_lalt_3:="keyFunc_winbind_binding(3)" 500 | if(!keyset.caps_lalt_4) 501 | keyset.caps_lalt_4:="keyFunc_winbind_binding(4)" 502 | if(!keyset.caps_lalt_5) 503 | keyset.caps_lalt_5:="keyFunc_winbind_binding(5)" 504 | if(!keyset.caps_lalt_6) 505 | keyset.caps_lalt_6:="keyFunc_winbind_binding(6)" 506 | if(!keyset.caps_lalt_7) 507 | keyset.caps_lalt_7:="keyFunc_winbind_binding(7)" 508 | if(!keyset.caps_lalt_8) 509 | keyset.caps_lalt_8:="keyFunc_winbind_binding(8)" 510 | if(!keyset.caps_lalt_9) 511 | keyset.caps_lalt_9:="keyFunc_doNothing" 512 | if(!keyset.caps_lalt_0) 513 | keyset.caps_lalt_0:="keyFunc_doNothing" 514 | if(!keyset.caps_lalt_minus) 515 | keyset.caps_lalt_minus:="keyFunc_jumpPageTop" 516 | if(!keyset.caps_lalt_equal) 517 | keyset.caps_lalt_equal:="keyFunc_jumpPageBottom" 518 | if(!keyset.caps_lalt_backspace) 519 | keyset.caps_lalt_backspace:="keyFunc_backspace" 520 | if(!keyset.caps_lalt_tab) 521 | keyset.caps_lalt_tab:="keyFunc_doNothing" 522 | if(!keyset.caps_lalt_leftSquareBracket) 523 | keyset.caps_lalt_leftSquareBracket:="keyFunc_doNothing" 524 | if(!keyset.caps_lalt_rightSquareBracket) 525 | keyset.caps_lalt_rightSquareBracket:="keyFunc_doNothing" 526 | if(!keyset.caps_lalt_backslash) 527 | keyset.caps_lalt_backslash:="keyFunc_doNothing" 528 | if(!keyset.caps_lalt_semicolon) 529 | keyset.caps_lalt_semicolon:="keyFunc_doNothing" 530 | if(!keyset.caps_lalt_quote) 531 | keyset.caps_lalt_quote:="keyFunc_doNothing" 532 | if(!keyset.caps_lalt_enter) 533 | keyset.caps_lalt_enter:="keyFunc_doNothing" 534 | if(!keyset.caps_lalt_comma) 535 | keyset.caps_lalt_comma:="keyFunc_doNothing" 536 | if(!keyset.caps_lalt_dot) 537 | keyset.caps_lalt_dot:="keyFunc_doNothing" 538 | if(!keyset.caps_lalt_slash) 539 | keyset.caps_lalt_slash:="keyFunc_doNothing" 540 | if(!keyset.caps_lalt_space) 541 | keyset.caps_lalt_space:="keyFunc_doNothing" 542 | if(!keyset.caps_lalt_ralt) 543 | keyset.caps_lalt_ralt:="keyFunc_doNothing" 544 | 545 | 546 | 547 | ;--------------------other-------------------- 548 | 549 | if(!keyset.caps_lalt_wheelUp) 550 | keyset.caps_lalt_wheelUp:="keyFunc_mouseSpeedIncrease" 551 | if(!keyset.caps_lalt_wheelDown) 552 | keyset.caps_lalt_wheelDown:="keyFunc_mouseSpeedDecrease" 553 | 554 | 555 | 556 | return 557 | } -------------------------------------------------------------------------------- /lib/lib_loadAnimation.ahk: -------------------------------------------------------------------------------- 1 | showLoading: 2 | ;~ global 3 | ;~ LoadingChar:=["—","/","|","\"] 4 | ;~ LoadingChar:=["1","2","3","4","5","6","7","8"] 5 | LoadingChar:=[ "_('<------" 6 | ," _('=-----" 7 | ," _('<-----" 8 | ," _('=----" 9 | ," _('<----" 10 | ," _('=---" 11 | ," _('<---" 12 | ," _('=--" 13 | ," _('<--" 14 | ," _('=-" 15 | ," _('<-" 16 | ," _(*=" 17 | ,"------_(*=" 18 | ,"------_(^<" 19 | ,"------_(^<" 20 | ,"------ | " 21 | ,"------>')_" 22 | ,"-----=')_ " 23 | ,"----->')_ " 24 | ,"----=')_ " 25 | ,"---->')_ " 26 | ,"---=')_ " 27 | ,"--->')_ " 28 | ,"--=')_ " 29 | ,"-->')_ " 30 | ,"-=')_ " 31 | ,"->')_ " 32 | ,"=*)_ " 33 | ,"=*)_------" 34 | ,">^)_------" 35 | ,">^)_------" 36 | ," | ------"] 37 | ; LoadingChar:=[ "=---------" 38 | ; ,"-=--------" 39 | ; ,"--=-------" 40 | ; ,"---=------" 41 | ; ,"----=-----" 42 | ; ,"-----=----" 43 | ; ,"------=---" 44 | ; ,"-------=--" 45 | ; ,"--------=-" 46 | ; ,"---------=" 47 | ; ,"--------=-" 48 | ; ,"-------=--" 49 | ; ,"------=---" 50 | ; ,"-----=----" 51 | ; ,"----=-----" 52 | ; ,"---=------" 53 | ; ,"--=-------" 54 | ; ,"-=--------"] 55 | Gui, LoadingGui:new, HwndLoadingGuiHwnd -Caption +AlwaysOnTop +Owner 56 | Gui, Font, S12 C0x555555, Lucida Console ;后备字体 57 | Gui, Font, S12 C0x555555, Fixedsys ;后备字体 58 | Gui, Font, S12 C0x555555, Courier New ;后备字体 59 | Gui, Font, S12 C0x555555, Source Code Pro ;后备字体 60 | Gui, Font, S12 C0x555555, Consolas 61 | Gui, Add, Text, HwndLoadingTextHwnd H20 W100 Center,% LoadingChar[1] 62 | Gui, Color, ffffff, ffffff 63 | Gui, LoadingGui:Show, Center NA 64 | ;~ WinSet, TransColor, ffffff, ahk_id %LoadingGuiHwnd% 65 | WinSet, Transparent, 230, ahk_id %LoadingGuiHwnd% 66 | charIndex:=1 67 | loadingCharMaxIndex:=LoadingChar._MaxIndex() 68 | SetTimer, changeLoadingChar, 250, 777 ;优先级777 69 | return 70 | 71 | 72 | hideLoading: 73 | SetTimer, changeLoadingChar, Off 74 | Gui, LoadingGui:Destroy 75 | return 76 | 77 | 78 | changeLoadingChar: 79 | charIndex:=Mod(charIndex, loadingCharMaxIndex)+1 80 | ControlSetText, , % LoadingChar[charIndex], ahk_id %LoadingTextHwnd% 81 | return 82 | 83 | 84 | -------------------------------------------------------------------------------- /lib/lib_mathBoard.ahk: -------------------------------------------------------------------------------- 1 | /* 2 | 计算板 3 | */ 4 | keyFunc_mathBoard(){ 5 | ClipboardOld:=ClipboardAll 6 | Clipboard:="" 7 | SendInput, ^{c} ; 8 | ClipWait, 0.1 9 | if(!ErrorLevel) 10 | { 11 | result:=clCalculate(Clipboard,res, , 1) 12 | if(res="?") 13 | result:="" 14 | } 15 | IfWinExist, Math Board 16 | { 17 | ControlSetText, , %result%, ahk_id %CalcEditHwnd% 18 | WinActivate, ahk_id %CalcGui% 19 | 20 | sendinput, {end} 21 | } 22 | else 23 | { 24 | Gui, mathBoard:new, hwndCalcGui, Math Board 25 | Gui mathBoard:+LabelmathBoard_ 26 | Gui, +AlwaysOnTop -Border +Caption -Disabled -LastFound -MaximizeBox -OwnDialogs +Resize +SysMenu -Theme -ToolWindow 27 | Gui, Font, s12 w400, consolas 28 | ; Gui, Font, s12 w400, Source Code Pro 29 | Gui, Add, Edit, x-2 y0 h403 w604 -Wrap hwndCalcEditHwnd, %result% 30 | Gui, Show, h400 w600 31 | sendinput, {end} 32 | } 33 | 34 | Sleep, 200 35 | 36 | Clipboard:=ClipboardOld 37 | CapsLock2:="" 38 | return 39 | } 40 | mathBoard_Size: 41 | WinGetPos, , ,mathBoard_W , mathBoard_H, ahk_id %CalcGui% 42 | ; msgbox, % mathBoard_W . "#" . mathBoard_H 43 | edit_w:=mathBoard_W-12 44 | edit_h:=mathBoard_H-37 45 | GuiControl, Move, %CalcEditHwnd%, w%edit_w% h%edit_h% 46 | return 47 | 48 | mathBoard_Close: 49 | mathBoard_Escape: 50 | Gui, Cancel 51 | return 52 | 53 | ;-----------------------in calculator GUI start------------- 54 | #if WinActive("Math Board") && GetKeyState("CapsLock","T") 55 | u::sendinput, {7} 56 | i::sendinput, {8} 57 | o::sendinput, {9} 58 | j::sendinput, {4} 59 | k::sendinput, {5} 60 | l::sendinput, {6} 61 | m::sendinput, {1} 62 | ,::sendinput, {2} 63 | .::sendinput, {3} 64 | space::sendinput, {0} 65 | RAlt::sendinput, {U+002e} 66 | `;::sendinput, {U+002b} 67 | '::sendinput, {U+002d} 68 | p::sendinput, {U+002a} 69 | /::sendinput, {U+002f} 70 | [::sendinput, {U+002f} 71 | return 72 | 73 | #IF WinActive("Math Board") 74 | +u::sendinput, {7} 75 | +i::sendinput, {8} 76 | +o::sendinput, {9} 77 | +j::sendinput, {4} 78 | +k::sendinput, {5} 79 | +l::sendinput, {6} 80 | +m::sendinput, {1} 81 | +,::sendinput, {2} 82 | +.::sendinput, {3} 83 | +space::sendinput, {0} 84 | +RAlt::sendinput, {U+002e} 85 | +`;::sendinput, {U+002b} 86 | +'::sendinput, {U+002d} 87 | +p::sendinput, {U+002a} 88 | +/::sendinput, {U+002f} 89 | +[::sendinput, {U+002f} 90 | 91 | 92 | NumpadEnter:: 93 | enter:: 94 | ClipboardOld:=ClipboardAll 95 | Clipboard:="" 96 | 97 | SendInput, +{Home} 98 | Sleep, 10 99 | SendInput, ^{c} 100 | ClipWait, 0.1 101 | if(!ErrorLevel) 102 | { 103 | if(RegExMatch(Clipboard,"(?<=:\=).*;$",calResult)) 104 | { 105 | clCalculate(Clipboard,calResult,0,1) 106 | SendInput, {End}{Enter} 107 | } 108 | else if(RegExMatch(Clipboard,"(?<=\=)[\deE\+\-\.a-fA-f]+$",calResult)) 109 | { 110 | sendinput, {End}{Enter} 111 | } 112 | else 113 | { 114 | Clipboard := clCalculate(Clipboard,calResult,0,1) 115 | SendInput, ^{v} 116 | Sleep, 200 117 | } 118 | } 119 | ; } 120 | 121 | 122 | Clipboard:=ClipboardOld 123 | return 124 | 125 | ^NumpadEnter:: 126 | ^enter:: 127 | sendinput, {enter} 128 | return 129 | 130 | +NumpadEnter:: 131 | +enter:: 132 | ClipboardOld:=ClipboardAll 133 | Clipboard:="" 134 | SendInput, +{Home} 135 | Sleep, 10 136 | SendInput, ^{c} 137 | ClipWait, 0.1 138 | if(!ErrorLevel) 139 | { 140 | if(RegExMatch(Clipboard,"(?<=\=)(?20) 14 | { 15 | mouseSpeed:=20 16 | setSettings("Global","mouseSpeed",mouseSpeed) 17 | } 18 | return 19 | 20 | ;改变鼠标速度 21 | changeMouseSpeed: 22 | { 23 | if(GetKeyState("LAlt", "P")) 24 | { 25 | ; 获取鼠标当前的速度以便稍后恢复: 26 | DllCall("SystemParametersInfo", UInt, SPI_GETMOUSESPEED, UInt, 0, UIntP, OrigMouseSpeed, UInt, 0) 27 | settimer, stopChangeMouseSpeed, 50 28 | ; 在倒数第3个参数中设置速度 (范围为 1-20): 29 | ; sendinput, % origmouseSpeed 30 | DllCall("SystemParametersInfo", UInt, SPI_SETMOUSESPEED, UInt, 0, Ptr, mouseSpeed, UInt, 0) 31 | settimer, changeMouseSpeed, off 32 | } 33 | ;如果Capslock松开 34 | if(!Capslock) 35 | { 36 | settimer, changeMouseSpeed, off 37 | } 38 | return 39 | } 40 | 41 | stopChangeMouseSpeed: 42 | if(!GetKeyState("LAlt", "P") || !Capslock) 43 | { 44 | settimer, stopChangeMouseSpeed, off 45 | ; sendinput, aaa%OrigMouseSpeed% 46 | DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, Ptr, OrigMouseSpeed, UInt, 0) ; 恢复原来的速度. 47 | if(Capslock) ;如果放开alt的时候caps还没放开,就再回去changeMouseSpeed继续监视Alt有没再次按下 48 | { 49 | settimer, changeMouseSpeed, 50 50 | } 51 | } 52 | return -------------------------------------------------------------------------------- /lib/lib_settings.ahk: -------------------------------------------------------------------------------- 1 | /* 2 | 提出settings.ini的设置信息 3 | 4 | ini demo: 5 | diko(Korean Dict)=http://cndic.naver.com/search/all?q={q} 6 | CLSets object Demo: 7 | CLSets.QRun= 8 | { 9 | diko:{ //键值,排除掉括号里面的 10 | fullKey:"diko(Korean Dict)", //全名键值 11 | setValue:"http://cndic.naver.com/search/all?q={q}", 12 | iconIndex:17; //icon索引 13 | } 14 | } 15 | */ 16 | settingsInit: 17 | global settingsModifyTime ;设置文件的修改时间 18 | global CLSets:={} ;保存Capslock+settings.ini的各种设置 19 | CLSets.length:={} ;保存settings.ini中每个字段的关键词数量 20 | global setsChanges:={} ;保存哪些设置经过改变 21 | ;set.ini 里面所有字段名,有更新必须修改这里,否则会无法获取 22 | global iniSections:=["Global","QSearch","QRun","QWeb","TabHotString","QStyle","TTranslate","Keys"] 23 | FileGetTime, settingsModifyTime, CapsLock+settings.ini 24 | 25 | ;init CapsLock+settingsDemo.ini and CapsLock+settings.ini 26 | IfNotExist, CapsLock+settingsDemo.ini 27 | { 28 | FileAppend, %lang_settingsDemoFileContent_1%, CapsLock+settingsDemo.ini, UTF-16 29 | FileAppend, %lang_settingsDemoFileContent_2%, CapsLock+settingsDemo.ini, UTF-16 30 | FileSetAttrib, +R, CapsLock+settingsDemo.ini 31 | } 32 | else 33 | { 34 | FileGetTime, setDemoModifyTime, CapsLock+settingsDemo.ini 35 | IfExist, language 36 | { 37 | FileGetTime, thisScriptModifyTime, language 38 | } 39 | else 40 | { 41 | FileGetTime, thisScriptModifyTime, %A_ScriptName% 42 | } 43 | 44 | thisScriptModifyTime -= setDemoModifyTime, S 45 | if(thisScriptModifyTime > 0) ;如果主程序文件比较新,那就是更新过,那就覆盖一遍 46 | { 47 | FileSetAttrib, -R, CapsLock+settingsDemo.ini 48 | FileDelete, CapsLock+settingsDemo.ini 49 | FileAppend, %lang_settingsDemoFileContent_1%, CapsLock+settingsDemo.ini, UTF-16 50 | FileAppend, %lang_settingsDemoFileContent_2%, CapsLock+settingsDemo.ini, UTF-16 51 | FileSetAttrib, +R, CapsLock+settingsDemo.ini 52 | } 53 | } 54 | IfNotExist, CapsLock+settings.ini 55 | { 56 | FileAppend, %lang_settingsFileContent%, CapsLock+settings.ini, UTF-16 57 | } 58 | lang_settingsDemoFileContent_1:="" 59 | lang_settingsDemoFileContent_2:="" 60 | lang_settingsFileContent:="" 61 | ; IniRead, settingsSections, CapsLock+settings.ini, , , %A_Space% 62 | ; sectionArr:=StrSplit(settingsSections,"`n") 63 | for key,sectionValue in iniSections 64 | { 65 | setsChanges[sectionValue]:={} 66 | setsChanges[sectionValue].deleted:={} 67 | setsChanges[sectionValue].modified:={} 68 | setsChanges[sectionValue].appended:={} 69 | settingsSectionInit(sectionValue) 70 | } 71 | gosub, keysInit 72 | SetTimer, globalSettings, -1 73 | SetTimer, setShortcutKey, -1 74 | SetTimer, hotStringInit, -1 75 | SetTimer, monitorSettingsFile, 500 76 | return 77 | 78 | ;监控设置文件的修改,并作出改动 79 | monitorSettingsFile: 80 | FileGetTime, latestModifyTime, CapsLock+settings.ini 81 | if(latestModifyTime!=settingsModifyTime) 82 | { 83 | settingsModifyTime:=latestModifyTime 84 | ; IniRead, settingsSections, CapsLock+settings.ini, , , %A_Space% 85 | ; sectionArr:=StrSplit(settingsSections,"`n") 86 | 87 | for key,sectionValue in iniSections ;sectionArr 88 | { 89 | isChange%sectionValue%:=settingsSectionInit(sectionValue) 90 | _test:=isChange%sectionValue% 91 | 92 | } 93 | if(isChangeKeys) 94 | { 95 | SetTimer, keysInit, -1 96 | } 97 | if(isChangeGlobal) ;如果global改过 98 | { 99 | 100 | for key1 in setsChanges.Global 101 | { 102 | for key2 in setsChanges.Global[key1] 103 | { 104 | if(key2="autostart") 105 | SetTimer, globalSettings, -1 106 | else if(key2="loadScript") 107 | SetTimer, jsEval_init, -1 108 | } 109 | } 110 | } 111 | if(isChangeTabHotString) 112 | { 113 | SetTimer, hotStringInit, -1 114 | } 115 | if(isChangeTTranslate) 116 | { 117 | SetTimer, youdaoApiInit, -1 118 | } 119 | ;如果有新添加的字段,要在这句上面添加一个if,这样文件改动才会修改到相应的内容 120 | if(isChangeQStyle) 121 | { 122 | global needInitQ:=1 ;+q初始化标志位 123 | CLq() 124 | return ;如果整个Q都重绘,那也不用在单独重载QListView了,返回好了 125 | } 126 | if(isChangeQSearch) 127 | { 128 | SetTimer, QListIconInit, -1 129 | } 130 | if(isChangeQWeb||isChangeQRun) 131 | { 132 | SetTimer, QListIconInit, -1 133 | SetTimer, hotStringInit, -1 134 | } 135 | } 136 | return 137 | 138 | getShortSetKey(str) 139 | { 140 | return RegExReplace(str, "\s*<.*>$") 141 | } 142 | 143 | settingsSectionInit(sectionValue) 144 | { 145 | isChange:=0 ;这个字段是否有改动过 146 | IniRead, settingsKeys, CapsLock+settings.ini, %sectionValue%, , %A_Space% 147 | settingsKeys:=RegExReplace(settingsKeys, "m`n)=.*$") 148 | keyArr:=StrSplit(settingsKeys,"`n") 149 | 150 | 151 | tempLen:=CLSets.length[sectionValue] 152 | if tempLen is not number ;如果还没初始化过 153 | { 154 | CLSets[sectionValue]:={} 155 | _clsetsSec:=CLSets[sectionValue] 156 | CLSets.length[sectionValue]:=0 157 | 158 | for key,keyValue in keyArr 159 | { 160 | IniRead, setValue, CapsLock+settings.ini, %sectionValue%, %keyValue%, %A_Space% 161 | 162 | if sectionValue in QSearch,QRun,QWeb ;如果是这些里面的,用对象来保存,否则直接key=value 163 | { 164 | shortKey:=getShortSetKey(keyValue) ;从 abc(xxx) 中提取出 abc,用来作关键字 165 | _clsetsSec[shortKey]:={} 166 | _t:=_clsetsSec[shortKey] 167 | _t.fullKey:=keyValue 168 | _t.setValue:=setValue 169 | } 170 | else if(sectionValue="Keys") 171 | { 172 | ;如果是 keys 项的值,控制它们的开头必须为 "keyFunc_" ,以避免调用到其他非 keyFunc_ 函数 173 | ;同时,也就要求所有按键函数名应该以 "keyFunc_" 开头 174 | if(SubStr(setValue,1,8)="keyFunc_") 175 | _clsetsSec[keyValue]:=setValue 176 | ; else 177 | ; _clsetsSec[keyValue]:="keyFunc_" . setValue 178 | } 179 | else 180 | { 181 | _clsetsSec[keyValue]:=setValue 182 | } 183 | CLSets.length[sectionValue]++ 184 | } 185 | } 186 | else ;不是初始化 187 | { 188 | _clsetsSec:=CLSets[sectionValue] 189 | if sectionValue in QSearch,QRun,QWeb 190 | { 191 | for key,value in _clsetsSec 192 | { 193 | _fullKey:=value.fullKey 194 | IniRead, valNew, CapsLock+settings.ini, %sectionValue%, %_fullKey%, %A_Space% 195 | if(valNew="") ;已删除 196 | { 197 | ;在这里接直接删除CLSets的话,循环的index会被弄乱,跑完for才删除CLSets 198 | setsChanges[sectionValue].deleted.insert(_fullKey) 199 | isChange:=1 200 | } 201 | else 202 | { 203 | if(value.setValue!=valNew) 204 | { 205 | shortKey:=getShortSetKey(key) 206 | _t:=_clsetsSec[shortKey] 207 | _t.fullKey:=key 208 | _t.setValue:=valNew 209 | ; if(sectionValue!="TabHotString") 210 | setsChanges[sectionValue].modified[key]:=valNew 211 | isChange:=1 212 | } 213 | } 214 | } 215 | 216 | for key, value in setsChanges[sectionValue].deleted 217 | { 218 | _clsetsSec.remove(value) 219 | CLSets.length[sectionValue]-- 220 | } 221 | 222 | for key,value in keyArr 223 | { 224 | valOld:=_clsetsSec[getShortSetKey(value)].setValue 225 | if(!(valOld=0||valOld)) ;如果未声明过的变量, 新添加 226 | { 227 | IniRead, valNew, CapsLock+settings.ini, %sectionValue%, %value%, %A_Space% 228 | shortKey:=getShortSetKey(value) 229 | _clsetsSec[shortKey]:={} 230 | _t:=_clsetsSec[shortKey] 231 | _t.fullKey:=value 232 | _t.setValue:=valNew 233 | CLSets.length[sectionValue]++ 234 | ; if(sectionValue!="TabHotString") 235 | setsChanges[sectionValue].appended[value]:=valNew 236 | isChange:=1 237 | } 238 | } 239 | } 240 | else ;如果不在QSearch,QRun,QWeb之中 241 | { 242 | for key,value in _clsetsSec 243 | { 244 | IniRead, valNew, CapsLock+settings.ini, %sectionValue%, %key%, %A_Space% 245 | if(valNew="") ;已删除 246 | { 247 | ;在这里接直接删除CLSets的话,循环的index会被弄乱,跑完for才删除CLSets 248 | setsChanges[sectionValue].deleted.insert(key) 249 | isChange:=1 250 | } 251 | else 252 | { 253 | if(value!=valNew) 254 | { 255 | ; msgbox, % value . "@" . valNew 256 | _clsetsSec[key]:=valNew 257 | setsChanges[sectionValue].modified[key]:=valNew 258 | isChange:=1 259 | } 260 | } 261 | } 262 | 263 | for key, value in setsChanges[sectionValue].deleted 264 | { 265 | _clsetsSec.remove(value) 266 | CLSets.length[sectionValue]-- 267 | } 268 | 269 | for key,value in keyArr 270 | { 271 | valOld:=_clsetsSec[value] 272 | if(!(valOld=0||valOld)) ;如果未声明过的变量, 新添加 273 | { 274 | IniRead, valNew, CapsLock+settings.ini, %sectionValue%, %value%, %A_Space% 275 | _clsetsSec[value]:=valNew 276 | CLSets.length[sectionValue]++ 277 | setsChanges[sectionValue].appended[value]:=valNew 278 | isChange:=1 279 | } 280 | } 281 | } 282 | 283 | } 284 | return isChange 285 | } 286 | 287 | 288 | globalSettings: 289 | ; scriptNameNoSuffix:=RegExReplace(A_ScriptName , "i)(\.ahk|\.exe)$") 290 | ;----------auto start------------- 291 | autostartLnk:=A_StartupCommon . "\CapsLock+.lnk" 292 | if(CLsets.global.autostart) ;如果开启开机自启动 293 | { 294 | IfExist, % autostartLnk 295 | { 296 | FileGetShortcut, %autostartLnk%, lnkTarget 297 | if(lnkTarget!=A_ScriptFullPath) 298 | FileCreateShortcut, %A_ScriptFullPath%, %autostartLnk%, %A_WorkingDir% 299 | } 300 | else 301 | { 302 | FileCreateShortcut, %A_ScriptFullPath%, %autostartLnk%, %A_WorkingDir% 303 | } 304 | } 305 | else 306 | { 307 | IfExist, % autostartLnk 308 | { 309 | FileDelete, %autostartLnk% 310 | } 311 | } 312 | 313 | if(CLsets.Global.allowClipboard!="0") 314 | CLsets.Global.allowClipboard:=1 315 | 316 | return 317 | 318 | ; 支持ctrl+alt+Capslock启动capslock+ 319 | setShortcutKey: 320 | startMenuLnk:=A_ProgramsCommon . "\CapsLock+.lnk" 321 | IfExist, % startMenuLnk 322 | { 323 | FileGetShortcut, %startMenuLnk%, lnkTarget 324 | if(lnkTarget!=A_ScriptFullPath) 325 | FileCreateShortcut, %A_ScriptFullPath%, %startMenuLnk%, %A_WorkingDir%, , , , Capslock 326 | } 327 | else 328 | { 329 | FileCreateShortcut, %A_ScriptFullPath%, %startMenuLnk%, %A_WorkingDir%, , , , Capslock 330 | } 331 | return 332 | 333 | ; caps+tab 热字串替换初始化;用拼接正则的方法实现关键字匹配 334 | hotStringInit: 335 | global regexHotString:="iS)(" 336 | for key,value in CLSets.TabHotString 337 | { 338 | regexHotString.="\Q" . key . "\E" . "|" 339 | } 340 | for key,value in CLSets.QRun 341 | { 342 | regexHotString.="\Q" . key . "\E" . "|" 343 | } 344 | for key,value in CLSets.QWeb 345 | { 346 | regexHotString.="\Q" . key . "\E" . "|" 347 | } 348 | regexHotString.=")$" 349 | return 350 | 351 | CLhotString() 352 | { 353 | matchKey:="" 354 | RegExMatch(Clipboard, regexHotString, matchKey) 355 | if(matchKey) 356 | { 357 | if(CLSets.TabHotString[matchKey]) 358 | { 359 | temp:=RegExReplace(Clipboard, "\Q" . matchKey . "\E$", CLSets.TabHotString[matchKey]) 360 | StringReplace, temp, temp, \n, `n, All ;替换换行符 361 | StringReplace, temp, temp, \`n, \n, All ;有转义符的换回来 362 | Clipboard:=temp 363 | } 364 | else if(IsObject(CLSets.QRun[matchKey])) 365 | { 366 | Clipboard:=RegExReplace(Clipboard, "\Q" . matchKey . "\E$", CLSets.QRun[matchKey].setValue) 367 | } 368 | else 369 | { 370 | Clipboard:=RegExReplace(Clipboard, "\Q" . matchKey . "\E$", CLSets.QWeb[matchKey].setValue) 371 | } 372 | } 373 | 374 | return matchKey 375 | } 376 | 377 | 378 | 379 | -------------------------------------------------------------------------------- /lib/lib_winJump.ahk: -------------------------------------------------------------------------------- 1 | activateSideWin(UDLR){ 2 | global winJumpSelected, winJumpIgnoreCount 3 | _sensitivity := Ceil(20/96*A_ScreenDPI) ; 灵敏度,每隔多少像素点检测一次,高分屏按dpi等比增加扫描间隔 4 | _deskTopExtra := 0 ; 在桌面中的话,增大移动距离 5 | winLastFoundId:="" 6 | CoordMode, Mouse, Screen 7 | ; 如果没有已选中的窗口,则取当前激活窗口为参照窗口 8 | ; 或者,如果选中的的窗口是最小化状态的 winJumpSelected 9 | if(!winJumpSelected){ 10 | winHwnd := WinExist("A") 11 | ; isFromActiveWin:=true 12 | } 13 | else{ 14 | winHwnd := winJumpSelected 15 | ; isFromActiveWin:=false 16 | } 17 | WinGetPos, winX, winY, winW, winH, ahk_id %winHwnd% 18 | MouseGetPos, mouX, mouY ; 保存原鼠标位置 19 | WinGetPos, , , screenW, screenH, Program Manager ; 获取全屏大小 20 | 21 | 22 | 23 | goY:=winY+winH/2 24 | goX:=winX+winW/2 25 | ; h := screenH/2 26 | 27 | if(UDLR="r") 28 | goX:=winX+winW 29 | else if(UDLR="l") 30 | goX:=winX 31 | else if(UDLR="u") 32 | goY:=winY 33 | else if(UDLR="d") 34 | goY:=winY+winH 35 | else if(UDLR="fl") ; 从最左扫描 36 | goX:=0 37 | else if(UDLR="fr") ; 从最右扫描 38 | goX:=screenW 39 | else if(UDLR="c"){ ; 中间 40 | goXY:=[] 41 | winW1_4:=winW/4 42 | winH1_4:=winH/4 43 | ; 取窗口中等分的9个点扫描 44 | goXY.Insert(1, goX, goY) 45 | goXY.Insert(3, goX-winW1_4, goY-winH1_4) 46 | goXY.Insert(5, goX+winW1_4, goY+winH1_4) 47 | goXY.Insert(7, goX-winW1_4, goY+winH1_4) 48 | goXY.Insert(9, goX+winW1_4, goY-winH1_4) 49 | goXY.Insert(11, goX-winW1_4, goY) 50 | goXY.Insert(13, goX+winW1_4, goY) 51 | goXY.Insert(15, goX, goY-winH1_4) 52 | goXY.Insert(17, goX, goY+winH1_4) 53 | 54 | winJumpCover(winX+10, winY, 0, 0) 55 | winLastFoundId:=winHwnd 56 | } 57 | SystemCursor(0) ; 隐藏鼠标 58 | ; msgbox, % goX . "$" . goY 59 | ; scaning 60 | loop{ 61 | if(UDLR="r") 62 | goX += _sensitivity+_deskTopExtra 63 | else if(UDLR="l") 64 | goX -= _sensitivity+_deskTopExtra 65 | else if(UDLR="u") 66 | goY -= _sensitivity+_deskTopExtra 67 | else if(UDLR="d") 68 | goY += _sensitivity+_deskTopExtra 69 | else if(UDLR="fl") 70 | goX += (A_index=1?0:_sensitivity+_deskTopExtra) 71 | else if(UDLR="fr") 72 | goX -= (A_index=1?0:_sensitivity+_deskTopExtra) 73 | else if(UDLR="c"){ 74 | 75 | if(A_index<=9){ 76 | goX:=goXY[A_index*2-1] 77 | goY:=goXY[A_index*2] 78 | }else{ 79 | winJumpCover(winX, winY, winW, winH) 80 | break 81 | } 82 | 83 | ; scanParticleSize:=5 84 | ; if(A_index<=scanParticleSize){ 85 | ; goX += (winW-30)/scanParticleSize 86 | ; goY += (winH-30)/scanParticleSize 87 | ; }else{ 88 | ; goX := winX+winW/scanParticleSize*(A_index-scanParticleSize-1) 89 | ; goY := (winY+winH)-winH/scanParticleSize*(A_index-scanParticleSize-1) 90 | ; } 91 | 92 | 93 | ; ; scanParticleSize:=5 94 | ; ; ; 从左上角扫到右下角 95 | ; ; msgbox, % goX . "@" . winX . "@" . winX+winW . "||" . goY . "@" . winY . "@" . winY+winH 96 | ; ; if(scanParticleSize>=A_index){ 97 | ; ; goX := winX+winW/scanParticleSize*(A_index) 98 | ; ; goY := winY+winH/scanParticleSize*(A_index) 99 | ; ; }else{ ; 从左下角到右上角 100 | ; ; goX := winX+winW/scanParticleSize*(A_index-scanParticleSize-1) 101 | ; ; goY := (winY+winH)-winH/scanParticleSize*(A_index-scanParticleSize-1) 102 | ; ; } 103 | ; msgbox, % A_index . "%" . sgoX . "@" . winX . "@" . winX+winW . "||" . goY . "@" . winY . "@" . winY+winH 104 | ; if(goXwinX+winW or goYwinY+winH) 105 | ; break 106 | ; if(A_index>=(scanParticleSize*2)) 107 | ; break 108 | } 109 | ; msgbox, % screenW . "@" . screenH 110 | 111 | if(UDLR!="c" and (goX<0 or goX>screenW or goY<0 or goY>screenH)) 112 | break 113 | 114 | MouseMove, %goX%, %goY%, 0 115 | MouseGetPos, , , winNowId, controlClass 116 | ; 如果有需要忽略的窗口,则加速跳过 117 | if(winNowId=winLastFoundId){ 118 | _deskTopExtra+=10 119 | continue 120 | } 121 | ; msgbox, 1 122 | WinGetTitle, title, ahk_id %winNowId% 123 | 124 | ; 如果是桌面,加速跳过 125 | if(title="Program Manager"){ 126 | _deskTopExtra+=10 127 | continue 128 | } 129 | 130 | WinGetPos, winNowX, winNowY, winNowW, winNowH, ahk_id %winNowId% 131 | 132 | ; 不是启动栏的话 133 | if(controlClass!="MSTaskListWClass1"){ 134 | 135 | ; 如果有需要跳过的窗口,跳过(若干次) 136 | if(winJumpIgnoreCount>0){ 137 | winLastFoundId:=winNowId 138 | winJumpIgnoreCount-- 139 | continue 140 | } 141 | ; msgbox, cover%winJumpIgnoreCount% 142 | winJumpCover(winNowX, winNowY, winNowW, winNowH) 143 | winJumpSelected:=winNowId 144 | 145 | settimer, winJumpActivate, 50 146 | 147 | break 148 | } 149 | 150 | } 151 | MouseMove, mouX, mouY, 0 152 | SystemCursor() ; 显示鼠标 153 | return 154 | } 155 | 156 | 157 | winJumpActivate: 158 | if(!GetKeyState("LAlt", "P") || !Capslock) 159 | { 160 | ; clean 161 | destroyWinJumpCover() 162 | winJumpIgnoreCount:=0 163 | ; /clean 164 | WinSet, Top,, ahk_id %winJumpSelected% 165 | WinActivate, ahk_id %winJumpSelected% 166 | winJumpSelected:="" 167 | settimer, winJumpActivate, off 168 | } 169 | return 170 | 171 | putWinToBottom(){ 172 | global winJumpSelected 173 | ; SendInput, !{esc} 174 | if(winJumpSelected) 175 | WinSet, Bottom,, ahk_id %winJumpSelected% 176 | else 177 | SendInput, !{esc} 178 | } 179 | 180 | winJumpCover(x,y,w,h){ 181 | Gui winCover:+LastFoundExist 182 | IfWinExist 183 | { 184 | WinMove, , , %x%, %y%, %w%, %h% 185 | return 186 | } 187 | Gui, winCover:New, +HwndwinCoverHwnd 188 | Gui, -Caption -Disabled -Resize +ToolWindow +AlwaysOnTop 189 | Gui, Color, 000000 190 | Gui, +LastFound 191 | WinSet, Transparent, 100 192 | Gui, Show, X%x% Y%y% W%w% H%h% 193 | return 194 | } 195 | 196 | destroyWinJumpCover(){ 197 | Gui, winCover:Destroy 198 | return 199 | } 200 | ; 跳窗的时候忽略窗口,按几下忽略几个 201 | winJumpIgnore(){ 202 | global winJumpIgnoreCount 203 | settimer, cleanWinJumpIgnore, 50 204 | if(!winJumpIgnoreCount) 205 | winJumpIgnoreCount:=1 206 | else 207 | winJumpIgnoreCount++ 208 | ; msgbox, % winJumpIgnoreCount 209 | return 210 | } 211 | 212 | cleanWinJumpIgnore: 213 | if(!GetKeyState("LAlt", "P") || !Capslock) 214 | { 215 | ; clean 216 | winJumpIgnoreCount:=0 217 | settimer, cleanWinJumpIgnore, off 218 | } 219 | return 220 | 221 | 222 | ; 窗口栈--------------- 223 | clearWinMinimizeStach(){ 224 | global minimizeWinArr 225 | minimizeWinArr:={} 226 | return 227 | } 228 | 229 | popWinMinimizeStack(){ 230 | global minimizeWinArr 231 | id:=minimizeWinArr.Remove() 232 | if(id) 233 | WinActivate, ahk_id %id% 234 | } 235 | 236 | pushWinMinimizeStack(){ 237 | _inWinMinimizeStack() 238 | } 239 | 240 | unshiftWinMinimizeStack(){ 241 | _inWinMinimizeStack(true) 242 | } 243 | 244 | _inWinMinimizeStack(ifInStart:=false){ 245 | global minimizeWinArr, winJumpSelected 246 | if not minimizeWinArr 247 | minimizeWinArr:={} 248 | 249 | if(winJumpSelected){ 250 | id:=winJumpSelected 251 | WinMinimize, ahk_id %id% 252 | 253 | winNowId:=WinExist("A") 254 | if(winNowId){ 255 | WinGetPos, winNowX, winNowY, winNowW, winNowH, ahk_id %winNowId% 256 | winJumpCover(winNowX, winNowY, winNowW, winNowH) 257 | winJumpSelected:=winNowId 258 | ; WinGetTitle, title , ahk_id %winNowId% 259 | ; msgbox, % title 260 | } 261 | 262 | }else{ 263 | id:=WinExist("A") 264 | WinMinimize, ahk_id %id% 265 | } 266 | 267 | if not ifInStart 268 | minimizeWinArr.insert(id) 269 | else 270 | minimizeWinArr.insert(1, id) 271 | ; showMsg(id) 272 | } -------------------------------------------------------------------------------- /lib/lib_winTransparent.ahk: -------------------------------------------------------------------------------- 1 | winTransparentInit: 2 | global winTranSetting, transpWinId, allowWinTranspToggle, transp 3 | 4 | ; 窗口透明度 5 | ; transp:=CLSets.Global.mouseSpeed 6 | 7 | return 8 | 9 | winTransparent(){ 10 | if(!winTranSetting){ ; 按下按下后只有第一次生效 11 | winTranSetting:=true 12 | allowWinTranspToggle:=true 13 | 14 | transpWinId:=WinExist("A") 15 | 16 | WinGet, transp, Transparent, ahk_id %transpWinId% 17 | 18 | setTimer, winTranspKeyCheck, 50 19 | 20 | setTimer, checkIfTranspToggle, -300 ; 快速短按的话反转窗口的透明度 21 | } 22 | 23 | return 24 | } 25 | 26 | 27 | checkIfTranspToggle: 28 | allowWinTranspToggle:=false 29 | return 30 | 31 | winTranspReduce: 32 | ; if(!transp) 33 | ; WinGet, transp, Transparent, ahk_id %transpWinId% 34 | if(!transp) 35 | transp:=245 36 | transp-=10 37 | if(transp<15) 38 | transp:=15 39 | 40 | WinSet, Transparent, %transp%, ahk_id %transpWinId% 41 | return 42 | 43 | 44 | winTranspAdd: 45 | ; if(!transp) 46 | ; WinGet, transp, Transparent, ahk_id %transpWinId% 47 | if(!transp or transp=255) 48 | return 49 | 50 | transp+=10 51 | if(transp>255){ 52 | transp:=255 53 | WinSet, Transparent, off, ahk_id %transpWinId% 54 | WinSet, Redraw 55 | return 56 | } 57 | 58 | WinSet, Transparent, %transp%, ahk_id %transpWinId% 59 | return 60 | 61 | 62 | 63 | winTranspKeyCheck: 64 | if(!GetKeyState("f4", "P") || !Capslock){ 65 | setTimer, checkIfTranspToggle, off ; 关闭短按切换透明度 66 | setTimer, winTranspKeyCheck, off 67 | 68 | if(allowWinTranspToggle){ 69 | 70 | ; WinGet, transp, Transparent, ahk_id %transpWinId% 71 | if(transp){ 72 | WinSet, Transparent, off, ahk_id %transpWinId% 73 | WinSet, Redraw 74 | } 75 | else 76 | WinSet, Transparent, 170, ahk_id %transpWinId% 77 | ; msgbox, 0 78 | } 79 | ; msgbox,1 80 | winTranSetting:=false 81 | ; transp:="" 82 | } 83 | return 84 | 85 | #if winTranSetting 86 | 87 | WheelUp:: 88 | ; send, 1 89 | gosub, winTranspAdd 90 | return 91 | 92 | WheelDown:: 93 | ; send, 2 94 | gosub, winTranspReduce 95 | 96 | #if -------------------------------------------------------------------------------- /lib/lib_ydTrans.ahk: -------------------------------------------------------------------------------- 1 | /* 2 | 有道翻译 3 | */ 4 | 5 | #Include lib_json.ahk ;引入json解析文件 6 | #Include sha256.ahk ;引入sha256加密文件 7 | 8 | global TransEdit,transEditHwnd,transGuiHwnd, NativeString 9 | 10 | youdaoApiInit: 11 | global youdaoApiString:="" 12 | 13 | ; #Include *i youdaoApiKey.ahk 14 | global youdaoApiKey0, youdaoApiKey1 15 | youdaoApiKey0=12763084 16 | global appID="" 17 | global appKey="" 18 | 19 | ; 收费版 API 20 | if (CLSets.TTranslate.appPaidID != "" && CLSets.TTranslate.appPaidID != "") 21 | { 22 | appID:=CLSets.TTranslate.appPaidID 23 | appKey:=CLSets.TTranslate.appPaidKey 24 | youdaoApiString=http://openapi.youdao.com/api?signType=v3&from=auto&to=auto&appKey=%appID% 25 | } 26 | else 27 | { 28 | if(CLSets.TTranslate.apiKey!="") 29 | { 30 | key:=CLSets.TTranslate.apiKey 31 | keyFrom:=ClSets.TTranslate.keyFrom 32 | youdaoApiString=http://fanyi.youdao.com/openapi.do?keyfrom=%keyFrom%&key=%key%&type=data&doctype=json&version=1.1&q= 33 | } 34 | else if(youdaoApiKey0) 35 | { 36 | youdaoApiString=http://fanyi.youdao.com/openapi.do?keyfrom=CapsLock&key=%youdaoApiKey0%&type=data&doctype=json&version=1.1&q= 37 | } 38 | } 39 | return 40 | 41 | setTransGuiActive: 42 | WinActivate, ahk_id %transGuiHwnd% 43 | return 44 | 45 | ydTranslate(ss) 46 | { 47 | if(CLSets.TTranslate.apiType = 0 || CLSets.TTranslate.appPaidID = "") 48 | { 49 | MsgBox, %lang_yd_free_key_unavailable_warning% 50 | return 51 | } 52 | transStart: 53 | ; if(StrLen(ss) >= 2000) 54 | ; { 55 | ; MsgBox, , , 文本过长,请重新选择。, 1 56 | ; return 57 | ; } 58 | ss:=RegExReplace(ss, "\s", " ") ;把所有空白符换成空格,因为如果有回车符的话,json转换时会出错 59 | 60 | ;~ global 61 | 62 | NativeString:=Trim(ss) 63 | 64 | transGui: 65 | ;~ WinClose, 有道翻译 66 | MsgBoxStr:=NativeString?lang_yd_translating:"" 67 | 68 | DetectHiddenWindows, On ;可以检测到隐藏窗口 69 | WinGet, ifGuiExistButHide, Count, ahk_id %transGuiHwnd% 70 | if(ifGuiExistButHide) 71 | { 72 | ControlSetText, , %MsgBoxStr%, ahk_id %transEditHwnd% 73 | ControlFocus, , ahk_id %transEditHwnd% 74 | WinShow, ahk_id %transGuiHwnd% 75 | } 76 | else ;IfWinNotExist, ahk_id %transGuiHwnd% ;有道翻译 77 | { 78 | ;~ MsgBox, 0 79 | 80 | Gui, new, +HwndtransGuiHwnd , %lang_yd_name% 81 | Gui, +AlwaysOnTop -Border +Caption -Disabled -LastFound -MaximizeBox -OwnDialogs -Resize +SysMenu -Theme -ToolWindow 82 | Gui, Font, s10 w400, Microsoft YaHei UI ;设置字体 83 | Gui, Font, s10 w400, 微软雅黑 84 | gui, Add, Button, x-40 y-40 Default, OK 85 | 86 | Gui, Add, Edit, x-2 y0 w504 h405 vTransEdit HwndtransEditHwnd -WantReturn -VScroll , %MsgBoxStr% 87 | Gui, Color, ffffff, fefefe 88 | Gui, +LastFound 89 | WinSet, TransColor, ffffff 210 90 | ;~ MsgBox, 1 91 | Gui, Show, Center w500 h402, %lang_yd_name% 92 | ControlFocus, , ahk_id %transEditHwnd% 93 | SetTimer, setTransActive, 50 94 | } 95 | ;~ DetectHiddenWindows, On ;可以检测到隐藏窗口 96 | 97 | if(NativeString) ;如果传入的字符串非空则翻译 98 | { 99 | ;~ MsgBox, 2 100 | SetTimer, ydApi, -1 101 | return 102 | } 103 | 104 | Return 105 | 106 | ydApi: 107 | UTF8Codes:="" ;重置要发送的代码 108 | SetFormat, integer, H 109 | UTF8Codes:=UTF8encode(NativeString) 110 | if(youdaoApiString="") 111 | { 112 | MsgBoxStr=%lang_yd_needKey% 113 | goto, setTransText 114 | } 115 | 116 | ; 目前 apiType 只可能为 1,暂时保留对 apiType 的判断结构,以防以后需要添加其他 api 类型的支持 117 | ; youdao api docs: https://ai.youdao.com/DOCSIRMA/html/trans/api/wbfy/index.html 118 | if (true || CLSets.TTranslate.apiType=1) { 119 | ; salt sign curtime 120 | ; sign=sha256(应用ID+input+salt+curtime+应用密钥) 121 | myNow := A_NowUTC 122 | myNow -= 19700101000000, Seconds 123 | salt := CreateUUID() 124 | myNow := Format("{:d}", myNow) 125 | if (StrLen(NativeString) > 20) { 126 | NativeStringF := SubStr(NativeString, 1, 10) 127 | NativeStringE := SubStr(NativeString, -9, 10) 128 | signString := appID . NativeStringF . Format("{:d}", StrLen(NativeString)) . NativeStringE . salt . myNow . appKey 129 | } else { 130 | signString := appID . NativeString . salt . myNow . appKey 131 | } 132 | sign:=bcrypt.hash(signString, "SHA256") 133 | sendStr:=youdaoApiString . "&salt=" . salt . "&curtime=" . myNow . "&sign=" . sign . "&q=" . UTF8encode(NativeString) 134 | whr := ComObjCreate("Msxml2.XMLHTTP") 135 | 136 | whr.Open("GET", sendStr, False) 137 | } else { 138 | sendStr:=youdaoApiString . UTF8Codes 139 | whr := ComObjCreate("WinHttp.WinHttpRequest.5.1") 140 | 141 | whr.Open("GET", sendStr) 142 | } 143 | 144 | ;~ MsgBox, 3 145 | try 146 | { 147 | whr.Send() 148 | } 149 | catch 150 | { 151 | MsgBoxStr:=lang_yd_errorNoNet 152 | goto, setTransText 153 | } 154 | afterSend: 155 | responseStr := whr.ResponseText 156 | 157 | ;~ transJson:=JSON_from(responseStr) 158 | transJson:=JSON.Load(responseStr) 159 | ; MsgBox, % responseStr 160 | ; MsgBox, % JSON_to(transJson) ;弹出整个翻译结果的json,测试用 161 | returnError:=transJson.errorCode 162 | if(returnError) ;如果返回错误结果,显示出相应原因 163 | { 164 | if(returnError=10) 165 | { 166 | MsgBoxStr:=lang_yd_errorTooLong 167 | } 168 | else if(returnError=11) 169 | { 170 | MsgBoxStr:=lang_yd_errorNoResults 171 | } 172 | else if(returnError=20) 173 | { 174 | MsgBoxStr:=lang_yd_errorTextTooLong 175 | } 176 | else if(returnError=30) 177 | { 178 | MsgBoxStr:=lang_yd_errorCantTrans 179 | } 180 | else if(returnError=40) 181 | { 182 | MsgBoxStr:=lang_yd_errorLangType 183 | } 184 | else if(returnError=50) 185 | { 186 | MsgBoxStr:=lang_yd_errorKeyInvalid 187 | } 188 | else if(returnError=60) 189 | { 190 | MsgBoxStr:=lang_yd_errorSpendingLimit 191 | } 192 | else if(returnError=70) 193 | { 194 | MsgBoxStr:=lang_yd_errorNoFunds 195 | } 196 | else if (returnError=202) 197 | { 198 | MsgBoxStr:=lang_yd_errorKeyInvalid 199 | } 200 | goto, setTransText 201 | return 202 | } 203 | ;================拼MsgBox显示的内容 204 | { 205 | 206 | MsgBoxStr:= % transJson.query . "`t" ;原单词 207 | if(transJson.basic.phonetic) 208 | { 209 | MsgBoxStr:=% MsgBoxStr . "[" . transJson.basic.phonetic . "] " ;读音 210 | } 211 | MsgBoxStr:= % MsgBoxStr . "`r`n`r`n" . lang_yd_trans . "`r`n" ;分隔,换行 212 | ;~ MsgBoxStr:= % MsgBoxStr . "--有道翻译--`n" 213 | Loop 214 | { 215 | if (transJson.translation[A_Index]) 216 | { 217 | if (%A_Index%>1) 218 | { 219 | MsgBoxStr:=% MsgBoxStr . A_Space . ";" . A_Space ;给每个结果之间插入" ; " 220 | } 221 | MsgBoxStr:= % MsgBoxStr . transJson.translation[A_Index] ;翻译结果 222 | } 223 | else 224 | { 225 | MsgBoxStr:= % MsgBoxStr . "`r`n`r`n" . lang_yd_dict . "`r`n" 226 | break 227 | } 228 | } 229 | ;~ MsgBoxStr:= % MsgBoxStr . "--有道词典结果--`n" 230 | Loop 231 | { 232 | if (transJson.basic.explains[A_Index]) 233 | { 234 | if (A_Index>1) 235 | { 236 | ;~ MsgBoxStr:=% MsgBoxStr . A_Space . ";" . A_Space ;给每个结果之间插入" ; " 237 | MsgBoxStr:=% MsgBoxStr . "`r`n" ;每条短语换一行 238 | } 239 | MsgBoxStr:= % MsgBoxStr . transJson.basic.explains[A_Index] ;有道词典结果 240 | } 241 | else 242 | { 243 | MsgBoxStr:= % MsgBoxStr . "`r`n`r`n" . lang_yd_phrase . "`r`n" 244 | break 245 | } 246 | } 247 | ;~ MsgBoxStr:= % MsgBoxStr . "--短语--`n" 248 | Loop 249 | { 250 | if (transJson.web[A_Index]) 251 | { 252 | if (A_Index>1) 253 | { 254 | MsgBoxStr:=% MsgBoxStr . "`r`n" ;每条短语换一行 255 | } 256 | MsgBoxStr:= % MsgBoxStr . transJson.web[A_Index].key . A_Space . A_Space ;短语 257 | thisA_index:=A_Index 258 | Loop 259 | { 260 | if(transJson.web[thisA_index].value[A_Index]) 261 | { 262 | if (A_Index>1) 263 | { 264 | MsgBoxStr:=% MsgBoxStr . A_Space . ";" . A_Space ;给每个结果之间插入" ; " 265 | } 266 | MsgBoxStr:= % MsgBoxStr . transJson.web[thisA_index].value[A_Index] 267 | } 268 | else 269 | { 270 | break 271 | } 272 | } 273 | } 274 | else 275 | { 276 | break 277 | } 278 | } 279 | } 280 | ;~ MsgBox, % MsgBoxStr 281 | setTransText: 282 | ControlSetText, , %MsgBoxStr%, ahk_id %transEditHwnd% 283 | ControlFocus, , ahk_id %transEditHwnd% 284 | SetTimer, setTransActive, 50 285 | return 286 | ;================拼MsgBox显示的内容 287 | 288 | ButtonOK: 289 | Gui, Submit, NoHide 290 | 291 | TransEdit:=RegExReplace(TransEdit, "\s", " ") ;把所有空白符换成空格,因为如果有回车符的话,json转换时会出错 292 | NativeString:=Trim(TransEdit) 293 | ;~ goto, ydApi 294 | goto, transGui 295 | 296 | return 297 | 298 | } 299 | 300 | 301 | ;确保激活 302 | setTransActive: 303 | IfWinExist, ahk_id %transGuiHwnd% 304 | { 305 | SetTimer, ,Off 306 | WinActivate, ahk_id %transGuiHwnd% 307 | } 308 | return 309 | 310 | CreateUUID() 311 | { 312 | VarSetCapacity(puuid, 16, 0) 313 | if !(DllCall("rpcrt4.dll\UuidCreate", "ptr", &puuid)) 314 | if !(DllCall("rpcrt4.dll\UuidToString", "ptr", &puuid, "uint*", suuid)) 315 | return StrGet(suuid), DllCall("rpcrt4.dll\RpcStringFree", "uint*", suuid) 316 | return "" 317 | } -------------------------------------------------------------------------------- /lib/sha256.ahk: -------------------------------------------------------------------------------- 1 | ; AHK implementation for CNG (https://github.com/jNizM/AHK_CNG) 2 | class bcrypt 3 | { 4 | static BCRYPT_OBJECT_LENGTH := "ObjectLength" 5 | static BCRYPT_HASH_LENGTH := "HashDigestLength" 6 | static BCRYPT_ALG_HANDLE_HMAC_FLAG := 0x00000008 7 | static hBCRYPT := DllCall("LoadLibrary", "str", "bcrypt.dll", "ptr") 8 | 9 | hash(String, AlgID, encoding := "utf-8") 10 | { 11 | AlgID := this.CheckAlgorithm(AlgID) 12 | ALG_HANDLE := this.BCryptOpenAlgorithmProvider(AlgID) 13 | OBJECT_LENGTH := this.BCryptGetProperty(ALG_HANDLE, this.BCRYPT_OBJECT_LENGTH, 4) 14 | HASH_LENGTH := this.BCryptGetProperty(ALG_HANDLE, this.BCRYPT_HASH_LENGTH, 4) 15 | HASH_HANDLE := this.BCryptCreateHash(ALG_HANDLE, HASH_OBJECT, OBJECT_LENGTH) 16 | this.BCryptHashData(HASH_HANDLE, STRING, encoding) 17 | HASH_LENGTH := this.BCryptFinishHash(HASH_HANDLE, HASH_LENGTH, HASH_DATA) 18 | hash := this.CalcHash(HASH_DATA, HASH_LENGTH) 19 | this.BCryptDestroyHash(HASH_HANDLE) 20 | this.BCryptCloseAlgorithmProvider(ALG_HANDLE) 21 | return hash 22 | } 23 | 24 | hmac(String, Hmac, AlgID, encoding := "utf-8") 25 | { 26 | AlgID := this.CheckAlgorithm(AlgID) 27 | ALG_HANDLE := this.BCryptOpenAlgorithmProvider(AlgID, this.BCRYPT_ALG_HANDLE_HMAC_FLAG) 28 | OBJECT_LENGTH := this.BCryptGetProperty(ALG_HANDLE, this.BCRYPT_OBJECT_LENGTH, 4) 29 | HASH_LENGTH := this.BCryptGetProperty(ALG_HANDLE, this.BCRYPT_HASH_LENGTH, 4) 30 | HASH_HANDLE := this.BCryptCreateHmac(ALG_HANDLE, HMAC, HASH_OBJECT, OBJECT_LENGTH, encoding) 31 | this.BCryptHashData(HASH_HANDLE, STRING, encoding) 32 | HASH_LENGTH := this.BCryptFinishHash(HASH_HANDLE, HASH_LENGTH, HASH_DATA) 33 | hash := this.CalcHash(HASH_DATA, HASH_LENGTH) 34 | this.BCryptDestroyHash(HASH_HANDLE) 35 | this.BCryptCloseAlgorithmProvider(ALG_HANDLE) 36 | return hash 37 | } 38 | 39 | file(FileName, AlgID, bytes := 1048576, offset := 0, length := -1, encoding := "utf-8") 40 | { 41 | AlgID := this.CheckAlgorithm(AlgID) 42 | ALG_HANDLE := this.BCryptOpenAlgorithmProvider(AlgID) 43 | OBJECT_LENGTH := this.BCryptGetProperty(ALG_HANDLE, this.BCRYPT_OBJECT_LENGTH, 4) 44 | HASH_LENGTH := this.BCryptGetProperty(ALG_HANDLE, this.BCRYPT_HASH_LENGTH, 4) 45 | HASH_HANDLE := this.BCryptCreateHash(ALG_HANDLE, HASH_OBJECT, OBJECT_LENGTH) 46 | if !(IsObject(f := FileOpen(filename, "r", encoding))) 47 | throw Exception("Failed to open file: " filename, -1) 48 | length := length < 0 ? f.length - offset : length 49 | if ((offset + length) > f.length) 50 | throw Exception("Invalid parameters offset / length!", -1) 51 | f.Pos(offset) 52 | while (length > bytes) && (dataread := f.RawRead(data, bytes)) { 53 | this.BCryptHashFile(HASH_HANDLE, DATA, DATAREAD) 54 | length -= dataread 55 | } 56 | if (length > 0) { 57 | if (dataread := f.RawRead(data, length)) 58 | this.BCryptHashFile(HASH_HANDLE, DATA, DATAREAD) 59 | } 60 | f.Close() 61 | HASH_LENGTH := this.BCryptFinishHash(HASH_HANDLE, HASH_LENGTH, HASH_DATA) 62 | hash := this.CalcHash(HASH_DATA, HASH_LENGTH) 63 | this.BCryptDestroyHash(HASH_HANDLE) 64 | this.BCryptCloseAlgorithmProvider(ALG_HANDLE) 65 | return hash 66 | } 67 | 68 | pbkdf2(Password, Salt, AlgID, Iterations := 1024, KeySize := 128, encoding := "utf-8") 69 | { 70 | AlgID := this.CheckAlgorithm(AlgID) 71 | ALG_HANDLE := this.BCryptOpenAlgorithmProvider(AlgID, this.BCRYPT_ALG_HANDLE_HMAC_FLAG) 72 | this.BCryptDeriveKeyPBKDF2(ALG_HANDLE, Password, Salt, Iterations, KeySize / 8, PBKDF2_DATA, encoding) 73 | pbkdf2 := this.CalcHash(PBKDF2_DATA, KeySize / 8) 74 | this.BCryptCloseAlgorithmProvider(ALG_HANDLE) 75 | return pbkdf2 76 | } 77 | 78 | 79 | ; =========================================================================================================================== 80 | ; Function ...: BCryptOpenAlgorithmProvider 81 | ; Links ......: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptopenalgorithmprovider 82 | ; =========================================================================================================================== 83 | BCryptOpenAlgorithmProvider(ALGORITHM, FLAGS := 0) 84 | { 85 | if (NT_STATUS := DllCall("bcrypt\BCryptOpenAlgorithmProvider", "ptr*", BCRYPT_ALG_HANDLE 86 | , "ptr", &ALGORITHM 87 | , "ptr", 0 88 | , "uint", FLAGS) != 0) 89 | throw Exception("BCryptOpenAlgorithmProvider: " NT_STATUS, -1) 90 | return BCRYPT_ALG_HANDLE 91 | } 92 | 93 | ; =========================================================================================================================== 94 | ; Function ...: BCryptGetProperty 95 | ; Links ......: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgetproperty 96 | ; =========================================================================================================================== 97 | BCryptGetProperty(BCRYPT_HANDLE, PROPERTY, cbOutput) 98 | { 99 | if (NT_STATUS := DllCall("bcrypt\BCryptGetProperty", "ptr", BCRYPT_HANDLE 100 | , "ptr", &PROPERTY 101 | , "uint*", pbOutput 102 | , "uint", cbOutput 103 | , "uint*", cbResult 104 | , "uint", 0) != 0) 105 | throw Exception("BCryptGetProperty: " NT_STATUS, -1) 106 | return pbOutput 107 | } 108 | 109 | ; =========================================================================================================================== 110 | ; Function ...: BCryptCreateHash 111 | ; Links ......: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptcreatehash 112 | ; =========================================================================================================================== 113 | BCryptCreateHash(BCRYPT_ALG_HANDLE, ByRef pbHashObject, cbHashObject) 114 | { 115 | VarSetCapacity(pbHashObject, cbHashObject, 0) 116 | if (NT_STATUS := DllCall("bcrypt\BCryptCreateHash", "ptr", BCRYPT_ALG_HANDLE 117 | , "ptr*", BCRYPT_HASH_HANDLE 118 | , "ptr", &pbHashObject 119 | , "uint", cbHashObject 120 | , "ptr", 0 121 | , "uint", 0 122 | , "uint", 0) != 0) 123 | throw Exception("BCryptCreateHash: " NT_STATUS, -1) 124 | return BCRYPT_HASH_HANDLE 125 | } 126 | 127 | BCryptCreateHmac(BCRYPT_ALG_HANDLE, HMAC, ByRef pbHashObject, cbHashObject, encoding := "utf-8") 128 | { 129 | VarSetCapacity(pbHashObject, cbHashObject, 0) 130 | VarSetCapacity(pbSecret, (StrPut(HMAC, encoding) - 1) * ((encoding = "utf-16" || encoding = "cp1200") ? 2 : 1), 0) 131 | cbSecret := StrPut(HMAC, &pbSecret, encoding) - 1 132 | if (NT_STATUS := DllCall("bcrypt\BCryptCreateHash", "ptr", BCRYPT_ALG_HANDLE 133 | , "ptr*", BCRYPT_HASH_HANDLE 134 | , "ptr", &pbHashObject 135 | , "uint", cbHashObject 136 | , "ptr", &pbSecret 137 | , "uint", cbSecret 138 | , "uint", 0) != 0) 139 | throw Exception("BCryptCreateHash: " NT_STATUS, -1) 140 | return BCRYPT_HASH_HANDLE 141 | } 142 | 143 | ; =========================================================================================================================== 144 | ; Function ...: BCryptHashData 145 | ; Links ......: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcrypthashdata 146 | ; =========================================================================================================================== 147 | BCryptHashData(BCRYPT_HASH_HANDLE, STRING, encoding := "utf-8") 148 | { 149 | VarSetCapacity(pbInput, (StrPut(STRING, encoding) - 1) * ((encoding = "utf-16" || encoding = "cp1200") ? 2 : 1), 0) 150 | cbInput := StrPut(STRING, &pbInput, encoding) - 1 151 | if (NT_STATUS := DllCall("bcrypt\BCryptHashData", "ptr", BCRYPT_HASH_HANDLE 152 | , "ptr", &pbInput 153 | , "uint", cbInput 154 | , "uint", 0) != 0) 155 | throw Exception("BCryptHashData: " NT_STATUS, -1) 156 | return true 157 | } 158 | 159 | BCryptHashFile(BCRYPT_HASH_HANDLE, pbInput, cbInput) 160 | { 161 | if (NT_STATUS := DllCall("bcrypt\BCryptHashData", "ptr", BCRYPT_HASH_HANDLE 162 | , "ptr", &pbInput 163 | , "uint", cbInput 164 | , "uint", 0) != 0) 165 | throw Exception("BCryptHashData: " NT_STATUS, -1) 166 | return true 167 | } 168 | 169 | ; =========================================================================================================================== 170 | ; Function ...: BCryptFinishHash 171 | ; Links ......: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptfinishhash 172 | ; =========================================================================================================================== 173 | BCryptFinishHash(BCRYPT_HASH_HANDLE, cbOutput, ByRef pbOutput) 174 | { 175 | VarSetCapacity(pbOutput, cbOutput, 0) 176 | if (NT_STATUS := DllCall("bcrypt\BCryptFinishHash", "ptr", BCRYPT_HASH_HANDLE 177 | , "ptr", &pbOutput 178 | , "uint", cbOutput 179 | , "uint", 0) != 0) 180 | throw Exception("BCryptFinishHash: " NT_STATUS, -1) 181 | return cbOutput 182 | } 183 | 184 | ; =========================================================================================================================== 185 | ; Function ...: BCryptDeriveKeyPBKDF2 186 | ; Links ......: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptderivekeypbkdf2 187 | ; =========================================================================================================================== 188 | BCryptDeriveKeyPBKDF2(BCRYPT_ALG_HANDLE, PASS, SALT, cIterations, cbDerivedKey, ByRef pbDerivedKey, encoding := "utf-8") 189 | { 190 | VarSetCapacity(pbDerivedKey, cbDerivedKey, 0) 191 | VarSetCapacity(pbPass, (StrPut(PASS, encoding) - 1) * ((encoding = "utf-16" || encoding = "cp1200") ? 2 : 1), 0) 192 | cbPass := StrPut(PASS, &pbPass, encoding) - 1 193 | VarSetCapacity(pbSalt, (StrPut(SALT, encoding) - 1) * ((encoding = "utf-16" || encoding = "cp1200") ? 2 : 1), 0) 194 | cbSalt := StrPut(SALT, &pbSalt, encoding) - 1 195 | if (NT_STATUS := DllCall("bcrypt\BCryptDeriveKeyPBKDF2", "ptr", BCRYPT_ALG_HANDLE 196 | , "ptr", &pbPass 197 | , "uint", cbPass 198 | , "ptr", &pbSalt 199 | , "uint", cbSalt 200 | , "int64", cIterations 201 | , "ptr", &pbDerivedKey 202 | , "uint", cbDerivedKey 203 | , "uint", 0) != 0) 204 | throw Exception("BCryptDeriveKeyPBKDF2: " NT_STATUS, -1) 205 | return true 206 | } 207 | 208 | ; =========================================================================================================================== 209 | ; Function ...: BCryptDestroyHash 210 | ; Links ......: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptdestroyhash 211 | ; =========================================================================================================================== 212 | BCryptDestroyHash(BCRYPT_HASH_HANDLE) 213 | { 214 | if (NT_STATUS := DllCall("bcrypt\BCryptDestroyHash", "ptr", BCRYPT_HASH_HANDLE) != 0) 215 | throw Exception("BCryptDestroyHash: " NT_STATUS, -1) 216 | return true 217 | } 218 | 219 | ; =========================================================================================================================== 220 | ; Function ...: BCryptCloseAlgorithmProvider 221 | ; Links ......: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptclosealgorithmprovider 222 | ; =========================================================================================================================== 223 | BCryptCloseAlgorithmProvider(BCRYPT_ALG_HANDLE) 224 | { 225 | if (NT_STATUS := DllCall("bcrypt\BCryptCloseAlgorithmProvider", "ptr", BCRYPT_ALG_HANDLE 226 | , "uint", 0) != 0) 227 | throw Exception("BCryptCloseAlgorithmProvider: " NT_STATUS, -1) 228 | return true 229 | } 230 | 231 | 232 | ; =========================================================================================================================== 233 | ; For Internal Use Only 234 | ; =========================================================================================================================== 235 | CheckAlgorithm(ALGORITHM) 236 | { 237 | static HASH_ALGORITHM := ["MD2", "MD4", "MD5", "SHA1", "SHA256", "SHA384", "SHA512"] 238 | for index, value in HASH_ALGORITHM 239 | if (value = ALGORITHM) 240 | return Format("{:U}", ALGORITHM) 241 | throw Exception("Invalid hash algorithm", -1, ALGORITHM) 242 | } 243 | 244 | CalcHash(Byref HASH_DATA, HASH_LENGTH) 245 | { 246 | loop % HASH_LENGTH 247 | HASH .= Format("{:02x}", NumGet(HASH_DATA, A_Index - 1, "uchar")) 248 | return HASH 249 | } 250 | } 251 | 252 | ; =============================================================================================================================== -------------------------------------------------------------------------------- /loadScript/debug.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /loadScript/scriptDemo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 方差 3 | * @demo variance(1,2,3,4,6,6) 4 | * @param {number} x1~xn n个数据 5 | * @return {number} 返回 n个数据的方差 6 | */ 7 | function variance(){ 8 | var n=arguments.length,s=0,ave=average([].slice.apply(arguments)); 9 | for(var i=0;i 1) { 105 | MsgBoxStr:=% MsgBoxStr . A_Space . ";" . A_Space 106 | } 107 | 108 | MsgBoxStr := % MsgBoxStr . web_tran 109 | } 110 | 111 | if(transJson.phrs){ 112 | MsgBoxStr := % MsgBoxStr . "`r`n`r`n" . lang_yd_phrase . "`r`n`r`n" ;分隔,换行 113 | 114 | for index, entry in transJson.phrs.phrs 115 | { 116 | MsgBoxStr := MsgBoxStr . entry.headword . ": " . entry.translation . "`r`n`r`n" 117 | } 118 | } 119 | 120 | goto, setTransText_cus 121 | } 122 | 123 | MsgBoxStr := lang_yd_errorNoResults 124 | 125 | setTransText_cus: 126 | ControlSetText, , %MsgBoxStr%, ahk_id %transEditHwnd% 127 | ControlFocus, , ahk_id %transEditHwnd% 128 | return 129 | } --------------------------------------------------------------------------------