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

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
partof
Posts: 110
Joined: 16 Jan 2016, 08:38

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

04 Apr 2019, 03:32

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
partof
Posts: 110
Joined: 16 Jan 2016, 08:38

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

08 Apr 2019, 04:19

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

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Nerafius, RandomBoy and 176 guests