简体   繁体   中英

in autohotkey not all send tabs are working

i was trying to make a .ahk to macro a gif making, uploading, and url coping but it often times ignores keystrokes like send, {tab down}{tab up} which compleatly breaks the macro. also send, ^L isnt working when i send it in the middle of the string

^q::
Run, firefox.exe "gifcreator.me"
sleep 9000
Loop 9
    {
        Send, {tab}
        sleep 100
    }
send, {enter down}
sleep 500
send, {enter up}
sleep 200
Loop 4
    {
    send, {ctrl down}
    send, ^L
    send, {ctrl up}

    }
sleep 200
send {ctrl down}
send, a
send, {ctrl up}
sleep 200
send, {delete down}
sleep 200
send {delete up}
sleep 5000
send, C:\Users\John Reuter\OneDrive\art
sleep 300
send, {enter down}
sleep 500
send, {enter up}
sleep 5000
click 1200, 50
sleep 3000
click 1200, 50
sleep 200
send, {ctrl down}
sleep 200
send, v
sleep 200
send, {Ctrl Up}
sleep 13000
click 50, 150
sleep 3000
send, {Ctrl Down}
sleep 200
send, a
sleep 200
send, {Ctrl Up}
sleep 200
send, {Ctrl Down}
sleep 200
send, a
sleep 200
send, {Ctrl Up}
sleep 7000
send, {enter}
sleep 5000
send, 5
sleep 200
send, 1
sleep 3000
send,^{ctrl down}-{ctrl up}
sleep 3000
send,^{ctrl down}-{ctrl up}
sleep 3000
send,^{ctrl down}-{ctrl up}
sleep 3000
send,^{ctrl down}-{ctrl up}
sleep 3000
send,^{ctrl down}-{ctrl up}
sleep 3000
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 3000
click 567, 227;                    miss
sleep 3000
send, {Ctrl Down}
send, f
send, {Ctrl Up}
sleep 3000
send, download gif
sleep 5000
send, {enter}
sleep 5000
send, {Ctrl Down}
send, l
send, {Ctrl Up}
sleep 5000
send, giphy.com/upload
sleep 3000
send, 2
sleep 3000
click 642, 325
sleep 8000
send, {down} 
sleep 3000
send, {right}
sleep 3000
send, {down}
sleep 3000
send, {right}
sleep 3000
send, {down}
sleep 3000
send, {right}
sleep 3000
send, {down}
sleep 3000
send, {right}
sleep 3000
send, {enter}
sleep 7000
send, {Ctrl Down}
send, f
send, {Ctrl Up}
sleep 3000
send, upload gifs
sleep 3000
click right 661, 198
sleep 3000
click 713, 218
sleep 3000
send, {Ctrl Down}
send, l
send, {Ctrl Up}
sleep 3000
send, {Ctrl Down}
send, x
send, {Ctrl Up}
sleep 3000
send, <img src="
sleep 3000
send, {Ctrl Down}
send, v
send, {Ctrl Up}
sleep 3000
send, "alt=""style="width:12px;height:18px;">
;======================
Esc::ExitApp

Instead of sleeps, try using WinWait etc. Look in AHK help file how the commands (Run, WinWait etc.) are properly used.

SetTitleMatchMode, 2
Run, firefox.exe "gifcreator.me"
WinWait, Online Animated GIF Maker
IfWinNotActive, Online Animated GIF Maker, ,WinActivate, Online Animated GIF Maker
WinWaitActive, Online Animated GIF Maker
sleep 100
Loop 8
{   
    Send, {tab}
    sleep 100
}
Send, {Enter}
; WinWait, ...
; IfWinNotActive, ...
; ...
; SendInput, C:\Users\John\OneDrive\art
; ...

EDIT

If the next window doesn't appear after the first "Send, {Enter}", try using a loop:

SetTitleMatchMode, 2
Run, firefox.exe "gifcreator.me"
Loop
{
    WinWait, Online Animated GIF Maker
    IfWinNotActive, Online Animated GIF Maker, ,WinActivate, Online Animated GIF Maker
    WinWaitActive, Online Animated GIF Maker
    sleep 100
    Loop 8
    {
        Send, {tab}
        sleep 100
    }
    Send, {Enter}   
    sleep 1000
    IfWinExist,  title of next window
        break
}
; WinWait, title of next window
; IfWinNotActive, ...
; ...
; SendInput, C:\Users\John\OneDrive\art

Why are you putting a comma after Send? That is not proper syntax. These examples from the AltHotKey website would be the proper syntax for your commands:

Send {b down}{b up}
Send {TAB down}{TAB up}
Send {Up down}  ; Press down the up-arrow key.
Sleep 1000  ; Keep it down for one second.
Send {Up up}  ; Release the up-arrow key.

Check their web page for more details about the Send command: https://www.autohotkey.com/docs/commands/Send.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM