Script with Multiple Submissions

Asked

Viewed 38 times

2

I am with the following doubt. I am trying to make a script in AHK that performs the following function:

When pressed mouse keying (XB1), the script should send [Shift+F1], just after holding down [Z].

When the key (XB1) was released, the script should send [Shift+F2] and release [Z].

Until that part I managed to do without problems, however the script is running only once, and I needed them to perform this check every time the key was pressed. I’ll put the code right down.

main(){
    MsgBox, "Estou na Main!"
    while GetKeyState("XButton1","P"){
        MsgBox, "Pressionado Main()"
        Send, {Z Down}
    }
    MsgBox, "Estou fora do While na Main!"
    Send, {Z Up}
    MsgBox, "Subi a Letra Z"
    Sleep, 100
    Send, +{F2 Down} +{F2 Up}
    MsgBox, "Enviei o F2"
}

XButton1:
    If GetKeyState("XButton1","P"){
        MsgBox, "Pressionado!"
        Send, +{F1 Down} +{F1 Up}
        Sleep, 100
        main()
    }else{
        MsgBox, "Não Pressionado!"
    }
Return
ESC:: ExitApp

1 answer

0


XButton1::
  Send, +{F1}
  Send, {Z Down}
Return

XButton1 Up::
  Send, {Z Up}
  Send, +{F2}
Return

ESC:: ExitApp
  • Felipe thank you very much, you showed a very simple solution, for something I was trying to complicate.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.