2013-01-18 104 views
0

如何編寫一個.ahk腳本來自動執行 「按住」鍵'2秒「的過程, 」按住'鍵2'秒鐘「, 」按住'key3'2秒「, 」右鍵單擊,等待2秒鐘「,然後重複。用於簡單功能的AutoHotKey腳本

我從來沒有爲鍵盤上的自動操作編寫腳本,所以這對我來說都是新的領域。我認爲任何有經驗的人都可以在一兩分鐘內實現上述內容。

編輯:我也想能夠調用這個腳本開始與某種組合鍵,如「等待alt + a,然後執行」。

回答

1

希望這得到是你要去..

!a:: ; Alt+a to start script 
Loop 
{ ; Start of loop 
    GetKeyState, keystate, Pause, P ; Get the state of the Pause key 
    if keystate = D ; The Pause key was held down, break out of the loop. 
     break ; Stop loop when the Pause key was held down 
    Send, {Space Down} ; This will NOT autorepeat 
    Sleep 2000 ; Wait 200 ms 
    Send, {Space Up} ; Release the key 
    GetKeyState, keystate, Pause, P ; Get the state of the Pause key 
    if keystate = D ; The Pause key was held down, break out of the loop. 
     break ; Stop loop when the Pause key was held down 
    Send, {b Down} ; This will NOT autorepeat 
    Sleep 2000 ; Wait 200 ms 
    Send, {b Up} ; Release the key 
    GetKeyState, keystate, Pause, P ; Get the state of the Pause key 
    if keystate = D ; The Pause key was held down, break out of the loop. 
     break ; Stop loop when the Pause key was held down 
    MouseClick, left, 150,150 ; Click the mouse at 150X,150Y pixels, check exact mouse coordinates with AHK Window Spy 
} ; End of loop 
return ; End of script 

附:除了在每個鍵之後添加Break陷阱之外,您還可以添加熱鍵來運行exitapp。

+0

我很感謝幫助!只是一個快速的評論,我不知道這是否是我的錯,但暫停鍵並沒有爲我工作。相反,我在return語句之前(和Loop之外)使用了'Esc :: ExitApp'中的一些東西。但其餘的完美解決。 – Nibirue