支持各種軟件快速切換,補全括號,代碼等!!!!!!!!

;這種全局定義要寫在所有代碼的前面才能讓所有代碼起作用. SetCapsLockState , AlwaysOff SetNumlockState, AlwaysOn GroupAdd, DisableBracketAuto , PyCharm ;注意這種語句要放最前面才起作用 GroupAdd, DisableBracketAuto , Xshell ;注意這種語句要放最前面才起作用 SetTitleMatchMode, 2 SetTitleMatchMode, slow ^b:: run http://www.baidu.com/ return #b:: run https://www.google.com/ return ;需要寫一個按照像素移動鼠標的功能,做cv用,當然photoshop也可以使用. CapsLock & Up:: MouseMove, 0, -1, 100, R return CapsLock & Down:: MouseMove, 0, 1, 100, R return CapsLock & Left:: MouseMove, -1, 0, 100, R return CapsLock & Right:: MouseMove, 1, 0, 100, R return CapsLock & 9:: send ,{PgUp} return CapsLock & 0:: send ,{PgDn} return CapsLock & u:: send ,{backspace} return CapsLock & o:: send ,{del} return ;如何選中光標當前字.就是模擬鼠標敲2下的操作. /* LCtrl & LShift:: Send #{Space} return */ /* linux下調試還是用gdb 還是用autohotkey來控制吧,沒找到linux設置輸入快捷鍵的方法 */ /* $+9:: ;因為這個shift跟輸入法的沖突至今還沒解決,只能進入搜狗輸入法把切換中英文改成ctrl即可. SetKeyDelay, 30 ;只要跟剪貼板有關就必須設置這個參數 t=%clipboard% clipboard= x=%clipboard% y=%clipboard% send {(} send {)} send {left} clipboard=%t% return */ /* ^t:: ime_status:=DllCall("GetKeyboardLayout","int",0,UInt) ;返回值的低位字包含了輸入語言的語言標識符,高位字包含了鍵盤物理布局的句柄。 msgbox, %ime_status% ;獲取67699721這個輸入法代碼 return */ /* ^t:: ime_status:=DllCall("GetKeyboardLayout","int",0,UInt) msgbox, %ime_status% ;獲取67699721這個輸入法代碼和134481924 return */ /*注意dll的名字可能跟windowsapi里面名字不一樣,0表示空指針,並且注釋一定要把*斜杠單獨寫一樣才行,挺bug */ /* 調用windows Api .第一個參數是函數名,后面是type和參數值. ^t:: DllCall("CreateDirectory", "Str", "dsaf",Ptr, 0) return */ ;好想廢了insert這個建的功能,但是沒找到api,但是因為有些軟件insert跟其他軟件insert相反,所以還是保留着吧, ;如果找到了底層api能鎖定上就好了 switchime(ime ) { if (ime = 1){ DllCall("SendMessage", UInt, WinActive("A"), UInt, 80, UInt, 1, UInt, DllCall("LoadKeyboardLayout", Str,"00000804", UInt, 1)) }else if (ime = 0) { DllCall("SendMessage", UInt, WinActive("A"), UInt, 80, UInt, 1, UInt, DllCall("LoadKeyboardLayout", Str,, UInt, 1)) }else if (ime = "A") { ;ime_status:=DllCall("GetKeyboardLayout","int",0,UInt) Send, #{Space} }} #f:: If WinActive("Everything"){ WinMinimize,A return } Run "C:\Program Files\Everything\Everything.exe" return #c:: SetKeyDelay, 1 If WinActive("管理員: C:\windows\SYSTEM32\cmd.exe") { switchime(0) WinMinimize,A return } If WinExist("管理員: C:\windows\SYSTEM32\cmd.exe") { WinActivate switchime(0) ;寫在激活的后面才行. return } else { run, cmd switchime(0) a=%clipboard% sleep, 200 MouseClick, left, A_ScreenWidth/2, A_ScreenHeight/2 ;居中點一下 send,{enter} ;這個點一下操作會清空clipborad,重新賦值一下即可.簡單 clipboard=%a% return } return #a:: SetKeyDelay, 1 If WinActive("360") { WinMinimize,A return } If WinExist("360"){ WinActivate return } else{ run "C:\Users\zhangbo340\AppData\Roaming\360se6\Application\360se.exe" ;為了防止alt點開菜單欄 return } return #q:: SetKeyDelay, 1 If WinActive("福昕閱讀器") { WinMinimize,A return } If WinExist("福昕閱讀器"){ WinActivate return } else{ run "C:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe" ;為了防止alt點開菜單欄 return } return #x:: SetKeyDelay, 1 If WinActive("筆記.txt") { WinMinimize,A return } If WinExist("筆記.txt"){ WinActivate return } else{ run D:\zhangbo340\Desktop\筆記.txt ;為了防止alt點開菜單欄 WinActivate return } return ^u:: SetKeyDelay, 30 send, ^c x = %clipboard% StringUpper, x, x clipboard = %x% send, ^v return #z:: SetKeyDelay, 1 If WinActive("ahk_class Xshell6::MainFrame_0"){ WinMinimize,A return } If WinExist("ahk_class Xshell6::MainFrame_0"){ WinActivate switchime(0) } else{ Run "C:\Program Files (x86)\NetSarang\Xshell 6\Xshell.exe" switchime(0) } return ; 切換至sougou 調用這個函數即可switchime(1) ; 切換至英文 調用這個函數即可 switchime(0) /* ;gc克隆代碼 */ :*:;gc:: SetKeyDelay, 30 x=%clipboard% d=%x% clipboard=git clone %d% Send, +{Ins} sleep,0.01 clipboard=%x% Send {enter} return /* 下面的^g是為了git命令寫的,為了能回滾到之前任意一次提交,所以加入了tag標簽, 如果tag里面標簽內容重復,好像idea就不能保存狀態,所以用一個當前時間作參數穿進去. 懶得自己寫push了,也寫上. */ ^g:: switchime(0) x=%clipboard% FormatTime, now_date, %A_Now%, yyyy-MM-dd ;格式化當前時間 d=git add . && git commit -am "" &&git tag %A_Now%&&git push SetKeyDelay, 100 clipboard = %d% Send +{insert} SetKeyDelay, 0.1 Send {LEFT 36} return !g:: run D:\zhangbo340\Desktop\個人信息.txt return ;通過if else已經完美的利用alt+x 啟動筆記和最小化筆記,喚起筆記了. ;下面我要實現的功能是想在一段話左右加括號,只需要選中這段話之后按下shift+9就行.等號右邊的變量需要加雙%,其實還是有bug存在 ;當剪貼板內容和選擇內容相同時候有bug,所以如果你要復制一段話到一個新地方並且加上括號.就先復制話,然后輸入括號再粘貼即可.順序反了就出不來.目前只有這個一個bug CapsLock & n::SendInput {_} CapsLock & ,::SendInput {+} CapsLock & .::SendInput {=} ;用;p來替換書寫經常不好使,因為輸入多個字符替換可能會bug ; caplock表示右,ctrl+caplock切換大小寫 ;CapsLock::SendInput {Right} ;這樣改就避免沖突了 CapsLock & l::Send {Right} CapsLock & i::SendInput {up} CapsLock & j::SendInput {left} CapsLock & k::SendInput {down} CapsLock & y::send print(type()){left 2} CapsLock & h::Send {home} CapsLock::Send {right} CapsLock & `;::Send {end} ;加入`表示autohotkey里面的轉義字符 CapsLock & m::Send import{space} ;send最穩的寫法是每次send一個字符 !b:: run D:\zhangbo340\Desktop\gapa.exe return CapsLock & r::send return{space} CapsLock & 7::send ^{Backspace} CapsLock & 8::send ^{del} CapsLock & e::send exit(){enter} CapsLock & c::send continue SetWinDelay, 10 #ClipboardTimeout 2000 ;這個版本已經基本修復了輸入括號等shift與切換中英文輸入法之間的沖突 #s::Suspend ; 給一個熱鍵指定掛起的開關功能。 CapsLock & t::send 15122306087 CapsLock & f::send 210102198908124112 CapsLock & b:: send,break return !p:: IfWinExist, 無標題 - 畫圖 ;注意這里面的標題名字就是打開程序里面寫的標題,注意中間帶空格.;這樣寫就控制了程序開關. { WinClose return } else { run mspaint return } !j::run calc :*:;m::15122306087@163.com ^NumpadAdd::SoundSet , +1, WAVE ^NumpadSub::SoundSet , -1, WAVE F3:: SetKeyDelay, 100 x=%clipboard% d=.append() clipboard=%d% Send ^v sleep,0.01 Send, {Left} clipboard=%x% return F4:: SetKeyDelay, 50 x=%clipboard% SetKeyDelay, 50 d='''''' clipboard=%d% Send ^v sleep,0.1 ; 貌似可以防止剪貼板粘貼錯誤 clipboard=%x% send {left 3} send {enter} send {enter} send {up} return $^v:: tmp1=%clipboard% asdf:=0=RegExMatch(tmp1, "————————(.*)\r\n版權聲明(.*)\r\n原文鏈接:(.*)") If %asdf% { send, ^v return } else { tmp1 := RegExReplace(tmp1, "————————(.*)\r\n版權聲明(.*)\r\n原文鏈接:(.*)", "") clipboard=%tmp1% send,^v return } ;使用方法是輸入,xun然后空格 :*:lsit::list :*:braek::break :*:berak::break :*:,rr::return{space} :*:dfe::def :*:retrun::return :*:retunr::return :*:calss::class :*:slef::self :*:slfe::self :*:apend::append :*:appedn::append :*:contiune::continue :*:contnue::continue ;下面為了java擴充的: CapsLock & s:: SetKeyDelay, 100 x=%clipboard% d=System.out.println(); clipboard=%d% Send ^v sleep,0.01 Send, {Left 2} clipboard=%x% return :*:':: SetKeyDelay, 100 x=%clipboard% d='' clipboard=%d% Send ^v Send {Left} sleep,0.01 clipboard=%x% return :*:;d:: SetKeyDelay, 100 sleep ,30 x=%clipboard% sleep ,30 FormatTime, d, LongDate,yyyy-MM-dd,H點mm sleep ,30 clipboard = %d% sleep ,30 Send ^v sleep,30 clipboard=%x% return ;下面添加sql快捷鍵 :*:;sql:: switchime(0) x=%clipboard% d=select * from (); SetKeyDelay, 100 clipboard = %d% SetKeyDelay, 1 Send ^v Send {LEFT 2} Send {ENTER 2} Send {UP} clipboard=%x% return /*自動復制搜索 */ CapsLock & p::send print(){left} #IfWinActive Xshell 6 ;這句話表示在shell里面這里面的語句才有效,但是為什么其他快捷鍵都失效,當shell時候? ;起始很簡單,只需要把這個If掛載的代碼寫在最后即可.這樣在判斷之前前面的快捷鍵已經都生效了. ;因為xshell里面粘貼是shift+insert所以也給他改成ctrl+v :*:;cm::cmake .&&make{enter} :*:;ls::lsof -i: ^b::^b return ;vim改建 用於快速保存或者關閉vim文件. ^q:: send,{Esc} switchime(0 ) send,:q+1 send,{enter} send,{enter} return ^s:: send,{Esc} switchime(0 ) send,:x send,{enter} send,{enter} return ;超級find命令 :*:;f::find / -name {space} return #IfwinNotActive , ahk_group DisableBracketAuto ;Edit_GetSel Gets the starting and ending character positions of the current selection in an edit or rich edit control. You can use this macro or send the EM_GETSEL message explicitly. ;https://docs.microsoft.com/zh-cn/windows/win32/controls/em-getsel ;ime_status:=DllCall("SetClipboardData","int",CF_UNICODETEXT,UInt) ^y:: m := 1 n :=2 ;n1:=DllCall("EM_GETSEL") n1:=DllCall("EM_GETSEL",Ptr,0,Ptr,0) ;n1:=DllCall("EM_GETSEL") oo:=&n mm:=&m tt:=*m tt2:=*oo msgbox, %n1%,%n1%,999999999999,%n%,%m%,%oo%,%mm%,%tt%,%tt2% return ^6:: m=1 MyVar=ooo MyVar2:=DllCall("CharUpper", Ptr, &MyVar) msgbox, %MyVar% return ;注意要刪除pycharm 里面 copy 的 ctrl+insert這個快捷鍵. ;然后開啟pycharm自帶的補全. $+9:: ;因為這個shift跟輸入法的沖突至今還沒解決,只能進入搜狗輸入法把切換中英文改成ctrl即可. SetKeyDelay, 20 ;只要跟剪貼板有關就必須設置這個參數 SaveOldData=%clipboard% clipboard= sleep,10 send , ^{insert} sleep,10 x=%clipboard% y=%clipboard% send +9 send +0 sleep,30 send {left} sleep,30 send , ^v clipboard=%SaveOldData% return $+[:: ;因為這個shift跟輸入法的沖突至今還沒解決,只能進入搜狗輸入法把切換中英文改成ctrl即可. SetKeyDelay, 20 ;只要跟剪貼板有關就必須設置這個參數 SaveOldData=%clipboard% clipboard= ;必須強制手動清空剪貼板 send , ^{insert} x=%clipboard% y=%clipboard% send {{} send {}} send {left} sleep,50 send , ^v clipboard=%SaveOldData% return $[:: ;因為這個shift跟輸入法的沖突至今還沒解決,只能進入搜狗輸入法把切換中英文改成ctrl即可. SetKeyDelay, 20 ;只要跟剪貼板有關就必須設置這個參數 SaveOldData=%clipboard% clipboard= ;必須強制手動清空剪貼板 send , ^{insert} x=%clipboard% y=%clipboard% send {[} send {]} send {left} sleep,50 send , ^v clipboard=%SaveOldData% return $':: ;因為這個shift跟輸入法的沖突至今還沒解決,只能進入搜狗輸入法把切換中英文改成ctrl即可. SetKeyDelay, 20 ;只要跟剪貼板有關就必須設置這個參數 SaveOldData=%clipboard% clipboard= ;必須強制手動清空剪貼板 send , ^{insert} x=%clipboard% y=%clipboard% send {'} send {'} send {left} sleep,50 send , ^v clipboard=%SaveOldData% return $":: ;因為這個shift跟輸入法的沖突至今還沒解決,只能進入搜狗輸入法把切換中英文改成ctrl即可. SetKeyDelay, 20 ;只要跟剪貼板有關就必須設置這個參數 SaveOldData=%clipboard% clipboard= ;必須強制手動清空剪貼板 send , ^{insert} x=%clipboard% y=%clipboard% send {"} send {"} send {left} sleep,50 send , ^v clipboard=%SaveOldData% return #IfWinActive Xshell ^v::send,+{insert} return ^b:: run http://www.baidu.com/ return ;ime_status:=DllCall("GetClipboardData","int",CF_UNICODETEXT,UInt) $+9:: ;因為這個shift跟輸入法的沖突至今還沒解決,只能進入搜狗輸入法把切換中英文改成ctrl即可. SetKeyDelay, 20 ;只要跟剪貼板有關就必須設置這個參數 clipboard= ;必須強制手動清空剪貼板 x=%clipboard% y=%clipboard% send +9 send +0 send {left} sleep,50 return $+[:: ;因為這個shift跟輸入法的沖突至今還沒解決,只能進入搜狗輸入法把切換中英文改成ctrl即可. SetKeyDelay, 20 ;只要跟剪貼板有關就必須設置這個參數 SaveOldData=%clipboard% clipboard= ;必須強制手動清空剪貼板 x=%clipboard% y=%clipboard% send {{} send {}} send {left} sleep,50 clipboard=%SaveOldData% return $[:: ;因為這個shift跟輸入法的沖突至今還沒解決,只能進入搜狗輸入法把切換中英文改成ctrl即可. SetKeyDelay, 20 ;只要跟剪貼板有關就必須設置這個參數 SaveOldData=%clipboard% clipboard= ;必須強制手動清空剪貼板 x=%clipboard% y=%clipboard% send {[} send {]} send {left} sleep,50 clipboard=%SaveOldData% return $':: ;因為這個shift跟輸入法的沖突至今還沒解決,只能進入搜狗輸入法把切換中英文改成ctrl即可. SetKeyDelay, 20 ;只要跟剪貼板有關就必須設置這個參數 SaveOldData=%clipboard% clipboard= ;必須強制手動清空剪貼板 x=%clipboard% y=%clipboard% send {'} send {'} send {left} sleep,50 clipboard=%SaveOldData% return $":: ;因為這個shift跟輸入法的沖突至今還沒解決,只能進入搜狗輸入法把切換中英文改成ctrl即可. SetKeyDelay, 20 ;只要跟剪貼板有關就必須設置這個參數 SaveOldData=%clipboard% clipboard= ;必須強制手動清空剪貼板 x=%clipboard% y=%clipboard% send {"} send {"} send {left} sleep,50 clipboard=%SaveOldData% return #IfWinActive pycharm ^F1:: SetKeyDelay, 30 x=%clipboard% d=for i in range(len()): clipboard=%d% Send ^v sleep,0.01 Send, {Left 4} clipboard=%x% return F1:: SetKeyDelay, 100 x=%clipboard% d=for i in : clipboard = %d% Send ^v Send {LEFT 1} Send {space} clipboard=%x% return #IfWinNotActive pycharm ^F1:: SetKeyDelay, 30 x=%clipboard% d=for i in range(len()): clipboard=%d% Send ^v sleep,0.01 Send, {Left 3} clipboard=%x% return F1:: SetKeyDelay, 100 x=%clipboard% d=for i in : clipboard = %d% Send ^v Send {LEFT 1} clipboard=%x% return