AutoHotKey 常用腳本


  1 ; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a
  2 ; semicolon, such as this one, are comments.  They are not executed.
  3 
  4 ; This script has a special filename and path because it is automatically
  5 ; launched when you run the program directly.  Also, any text file whose
  6 ; name ends in .ahk is associated with the program, which means that it
  7 ; can be launched simply by double-clicking it.  You can have as many .ahk
  8 ; files as you want, located in any folder.  You can also run more than
  9 ; one .ahk file simultaneously and each will get its own tray icon.
 10 
 11 ; SAMPLE HOTKEYS: Below are two sample hotkeys.  The first is Win+Z and it
 12 ; launches a web site in the default browser.  The second is Control+Alt+N
 13 ; and it launches a new Notepad window (or activates an existing one).  To
 14 ; try out these hotkeys, run AutoHotkey again, which will load this file.
 15 
 16 ;讓腳本持久運行 (即直到用戶關閉或遇到 ExitApp).
 17 ;#Persistent
 18 
 19 ;強制加載新的腳本
 20 #SingleInstance force
 21 
 22 ;嘗試加載圖標
 23 IfExist, icon.ico ;花括號“{”不能和 IfExist 寫在同一行
 24 {
 25 Menu TRAY, Icon, icon.ico ;這句會把 icon.ico 作為圖標
 26 }
 27 
 28 ;定時器 輸入為分鍾數
 29 #t::
 30 ; 彈出一個輸入框,標題 內容
 31 InputBox ,time,定時器,請輸入一個時間(單位是分鍾),,200,100 ;InputBox, time, 計時器, 請輸入一個時間(單位是分鍾)
 32 time := time*1000*60 ; 變量賦值,多一個冒號,乘以 1000*60  變time為分鍾數
 33 Sleep,%time%
 34 MsgBox,,提示信息, 打卡啦
 35 return
 36 
 37 /*
 38 ;打開ie瀏覽器
 39 #1::
 40 run C:\Program Files\Internet Explorer\iexplore.exe
 41 return
 42  
 43 ;打開firefox瀏覽器
 44 #2::
 45 ;run D:\Program Files\Mozilla Firefox\firefox.exe
 46 run C:\Documents and Settings\koujincheng\Local Settings\Application Data\Google\Chrome\Application\chrome.exe
 47 return
 48 */
 49 
 50 ;打開everything
 51 ^!e::
 52 Run D:\Program Files\everything\Everything.exe
 53 return
 54  
 55 ;打開任務管理器
 56 ^!K::
 57 Run taskmgr
 58 return
 59  
 60 ;打開遠程連接
 61 ^!m::
 62 Run mstsc
 63 return
 64  
 65 ;新建或激活記事本窗口
 66 ^!n::
 67 IfWinExist ahk_class Notepad
 68 WinActivate
 69 else
 70 Run Notepad
 71 return
 72  
 73 ;UltraEdit32
 74 ^!u::
 75 Run D:\Program Files\UltraEdit\Uedit32.exe
 76 return
 77  
 78 ;截圖工具 FSCapture
 79 ^!c::
 80 Run D:\Program Files (x86)\FScapture\FSCapture.exe
 81 return
 82  
 83 ; Foxmail
 84 ^!f::
 85 Run D:\Program Files (x86)\Foxmail7.2\Foxmail.exe
 86 return
 87 
 88 ; P2PSearcher
 89 ^!p::
 90 Run D:\Program Files (x86)\P2PSearchers\P2PSearcher.exe
 91 return
 92  
 93 ;重新加載腳本
 94 ^!r::Reload  ; Assign Ctrl-Alt-R as a hotkey to restart the script.
 95 
 96 ;##################################################window script#############################################################
 97 ;###################################################窗口操作#################################################################
 98  
 99 ;最大化或還原(取消最大化)窗口
100 ~LAlt::            
101 Keywait, LAlt, , t0.3
102 if errorlevel = 1
103 return
104 else
105 Keywait, LAlt, d, t0.3
106 if errorlevel = 0
107 {
108 WinGet, DAXIAO , MinMax, A
109 if (DAXIAO = "1")
110 {
111 PostMessage, 0x112, 0xF120,,, A  ; 0x112 = WM_SYSCOMMAND, 0xF120 = SC_RESTORE
112 }
113 else
114 {
115 PostMessage, 0x112, 0xF030,,, A  ; 0x112 = WM_SYSCOMMAND, 0xF030 = SC_MAXIMIZE
116 }
117 }
118 return
119  
120 ;最小化窗口 記錄最后三個最小化的窗口
121 ~RAlt::     
122 Keywait, RAlt, , t0.3
123 if errorlevel = 1
124 return
125 else
126 Keywait, RAlt, d, t0.3
127 if errorlevel = 0
128 {
129 If (WinActive("ahk_class Progman") or WinActive("ahk_class WorkerW"))
130 {
131 }
132 else
133 {
134 Last_Max_Id=0
135 WinGet, Last_Min_Id, ID, A
136 if (MinMemo1 = "0")
137 MinMemo1=%Last_Min_Id%
138 else if(MinMemo2 = "0")
139 {
140 MinMemo2=%MinMemo1%
141 MinMemo1=%Last_Min_Id%
142 }
143 else
144 {
145 MinMemo3=%MinMemo2%
146 MinMemo2=%MinMemo1%
147 MinMemo1=%Last_Min_Id%
148 }
149 IfWinNotActive ahk_class TXGuiFoundation
150 WinMinimize, A
151 else  ;qq窗口使用ctrl+alt+z 最小化
152 {
153 WinGetTitle, Temp0 , A
154 If Temp0 contains QQ20
155 {
156 sleep,100
157 Send, {CTRLDOWN}{ALTDOWN}z{ALTUP}{CTRLUP}
158 }
159 else
160 WinMinimize, A
161 }
162 }
163 } ;end if  errorlevel = 0
164 return
165 ;恢復最小化的窗口,最多三個(只能識別通過腳本最小化的窗口)
166 >!Space::      
167 if (MinMemo1 = "0") ;不存在通過腳本最小化的窗口
168 {
169 WinRestore, A
170 WinActivate,A
171 }
172 else if (MinMemo2 = "0") ;只有一個
173 {
174 WinRestore, ahk_id %MinMemo1%
175 WinActivate, ahk_id %MinMemo1%
176 MinMemo1=0
177 }
178 else if (MinMemo3 = "0")
179 {
180 WinRestore, ahk_id %MinMemo1%
181 WinActivate, ahk_id %MinMemo1%
182 MinMemo1=%MinMemo2%
183 MinMemo2=0
184 }
185 else
186 {
187 WinRestore, ahk_id %MinMemo1%
188 WinActivate, ahk_id %MinMemo1%
189 MinMemo1=%MinMemo2%
190 MinMemo2=%MinMemo3%
191 MinMemo3=0
192 }
193 return
194  
195 ;關閉窗口,在瀏覽器中為關閉標簽頁
196 ~Esc::     
197 Keywait, Esc, , t0.5
198 if errorlevel = 1
199 return
200 else
201 Keywait, Esc, d, t0.2
202 if errorlevel = 0
203 {
204 IfWinActive ahk_class ahk_class IEFrame ;識別IE瀏覽器
205 Send {ctrldown}w{ctrlup}
206 else IfWinActive ahk_class MozillaWindowClass ;識別firfox 瀏覽器
207 Send {ctrldown}w{ctrlup}
208 else
209 send !{F4}
210 }
211 return
212  
213 ;##################################################other script#############################################################
214 ;###################################################其它腳本################################################################
215  
216  
217 ;快速按下兩次Ctrl 快速粘貼
218 /*
219 ~LCtrl::
220 Keywait, LCtrl, , t0.5
221 if errorlevel = 1
222 return
223 else
224 Keywait, LCtrl, d, t0.3
225 if errorlevel = 0
226 {
227 Send,^v
228 }
229 return
230 */
231  
232  
233 ;win+shift+f 在桌面上建立一個以當前日期命名的文件夾
234 #+f::
235 Click right ;在桌面當前鼠標所在位置點擊鼠標右鍵
236 Send, wf ;快捷鍵新建文件夾
237 Sleep, 125 ; 把暫停時間改小
238 clipboard = %A_MM%-%A_DD%-%A_YYYY% ;%A_Hour%-%A_Min%-%A_Sec%-%A_MSec%;把當前的系統日期發送到剪貼板
239 Send, ^v{Enter} ;發送 Ctrl + v 和回車確認修改文件夾名稱
240 return
241  
242 ;ctrl+win+c 得到當前選中文件的路徑,保存到剪貼板中
243 ^#c::
244 send ^c
245 sleep,200
246 clipboard=%clipboard% ;解釋:windows復制的時候,剪貼板保存的是“路徑”.只是路徑而不是字符串,只要轉換成字符串就可以粘貼出來了
247 tooltip,%clipboard% ;提示文本
248 sleep,2000
249 tooltip, ;置空
250 return
251  
252 ; Win+O 關閉顯示器
253 #o:: 
254 Sleep 1000  ; 讓用戶有機會釋放按鍵 (以防釋放它們時再次喚醒顯視器).
255 SendMessage, 0x112, 0xF170, 2,, Program Manager   ; 關閉顯示器: 0x112 為 WM_SYSCOMMAND, 0xF170 為 SC_MONITORPOWER. ; 可使用 -1 代替 2 打開顯示器,1 代替 2 激活顯示器的節能模式
256 return
257 
258 ;獲取當前系統日期
259 ::ddd::
260 ;獲得系統時間比如今天的時間:2013-07-17。如果需要“年”的話請替換上面的“-”。
261 d = %A_YYYY%-%A_MM%-%A_DD% 
262 ;把 d 的值發送到剪貼板,變量不用聲明,引用變量的值時在變量的前后加“%”。clipboard是 AHK 自帶的變量:剪切板
263 clipboard = %d% 
264 Send ^v
265 return
266 
267 ;獲取當前系統時間
268 ::/time::
269 d = %A_Hour%:%A_Min%:%A_sec% 
270 clipboard = %d% 
271 Send ^v
272 return
273 
274 ;獲取系統日期和時間
275 ::/all::
276 d = %A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_sec%
277 clipboard = %d% 
278 Send ^v
279 return
280 
281 ::/kou::
282 Send , koujincheng{Shift}{Tab}1234.abcdd{Enter}
283 return
284 
285 ;選中路徑,快速打開
286 #j::
287 send ^c ; 復制選中的文字
288 clipwait ; 等待復制動作的完成
289 Clipboard := Trim(clipboard,A_Space) ;去除空格
290 Run  %clipboard%
291 return
292 
293 
294 ; Note: From now on whenever you run AutoHotkey directly, this script
295 ; will be loaded.  So feel free to customize it to suit your needs.
296 
297 ; Please read the QUICK-START TUTORIAL near the top of the help file.
298 ; It explains how to perform common automation tasks such as sending
299 ; keystrokes and mouse clicks.  It also explains more about hotkeys.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM