Page 1 of 1

hotkey bugs if I keep pressing it too long (how to release the key that I'm pressing?)

Posted: 04 Apr 2019, 03:32
by partof
This code work as expected, until I press the # for too long. In this case it send another "#a" (the # I press + the a of the "al" it sent) which log off the computer (it's an inbuilt hotkey I would desactivate if I could).

Code: Select all

#a:: 
    {
        Send {# up}
        send, al 
    }

return
I also tried using {Blind} (I first though that "blind" will just send "al", even if # is still pressed, but it doesnt):

Code: Select all

  send, {Blind} al ;


The real code works in google doc. it write "al" in subscript and open a comment on it, and past the content of the clipboard into it :

Code: Select all

#If WinActive("Google Docs ahk_class Chrome_WidgetWin_1") 

#a:: 
    {
        send, ^; ; set upperscript
        sleep, 100 ; 
        
        Send {# up} ; to release # key (otherwhise it sends #+a which log out)
        
        send, al ;
        sleep, 200 ; time to select
        send, +{Left 2} ; select the "al"
        sleep, 250 
        send, ^!m ; open the comment box
       sleep, 100
       send ^v ; past the clipboard
       send ^{enter} ; save the comment
       sleep 10
    }
return

Re: hotkey bugs if I keep pressing it too long (how to release the key that I'm pressing?)  Topic is solved

Posted: 08 Apr 2019, 04:19
by partof
the solution was :

Code: Select all

KeyWait LWin, L
It means: wait for windows key to be released before resuming the code

Full code:

Code: Select all

#If WinActive("Google Docs ahk_class Chrome_WidgetWin_1") 

#a:: 
    {
        KeyWait LWin, L  ; Wait for # to be released.
        send, ^; ; set upperscript
        sleep, 100 ; 
               
        send, al ;
        sleep, 200 ; time to select
        send, +{Left 2} ; select the "al"
        sleep, 250 
        send, ^!m ; open the comment box
       sleep, 100
       send ^v ; past the clipboard
       send ^{enter} ; save the comment
       sleep 10
    }
return