Control key not held down

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Control key not held down

Post by milkygirl90 » 24 Jul 2021, 01:38

I simply want the control button to be held down until the script is done with clicking, but it doesn't seem to hold.

any idea why?

Code: Select all

!Up:: ;draw UP arrow to mark OPEN position and date 
Click Middle
SendInput {down 7}{Enter}
Sleep 100
Send {Control Down}
Click
Mousemove 30,100,,R
Click
Send {Control Up}
return

Ianizer
Posts: 79
Joined: 07 Mar 2021, 00:06

Re: Control key not held down

Post by Ianizer » 26 Jul 2021, 10:16

This seems to work:

Code: Select all

!Up:: ;draw UP arrow to mark OPEN position and date 
Send {Blind}{Alt Up} ;release alt so it doesn't interfere with control ;use blind in case it's held down physically (that would cause it to be in the "Down" state again).
Click Middle
SendInput {down 7}{Enter}
Sleep 100
Send {Blind}{Control Down} ;honestly not sure exactly why {Blind} makes it work, but it does!
Click
Mousemove 30,100,,R ;i just learned that MouseMove is essentially a Send command in disguise. that means it will release modifier keys if they are held down, just like Send. But that doesn't explain why Blind makes it work.
Click
Send {Blind}{Control Up}
return
But I recommend using this way instead:

Code: Select all

!Up:: ;draw UP arrow to mark OPEN position and date 
Send {Blind}{Alt Up} ;release alt so it doesn't interfere with control ;use blind in case it's held down physically (that would cause it to be in the "Down" state again). 
Click Middle
SendInput {down 7}{Enter}
Sleep 100
Send {Control Down} ;Click doesn't release modifiers, so Blind isn't needed
Click
Click 30 100 Relative
Send {Control Up}
return
If anyone who knows why {Blind} fixes everything in the first script, please tell me!
https://www.autohotkey.com/docs/commands/Send.htm#Blind

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: Control key not held down

Post by milkygirl90 » 27 Jul 2021, 02:34

I tested this on another program and can confirm it works, but it makes a simple script extremely long though.

Was thinking whether there's any alternative?

Code: Select all

#If WinActive("ahk_exe IDMan.exe")
^k::
Send {Blind}{Ctrl Up}
Send !do
Sleep 300
Send {Blind}{Ctrl Down}
SendInput {tab}
Sleep 100
SendInput {tab}
Send {Blind}{Ctrl Up}
SendInput {tab 4}
return

Ianizer
Posts: 79
Joined: 07 Mar 2021, 00:06

Re: Control key not held down

Post by Ianizer » 27 Jul 2021, 10:28

You could merge some Send commands together like so:

Code: Select all

#If WinActive("ahk_exe IDMan.exe")
^k::
Send !do ;the Send command releases any currently-held-down modifiers automatically and un-releases them when done, so no need to release Control unless you use {Blind}. Sorry I made things confusing with the first script's comments.
Sleep 300
SendInput ^{tab}
Sleep 100
SendInput ^{tab}{tab 4}
return
Something I should clarify: {Blind} usually isn't needed with Send, but for unknown (to me) reasons, if you want Control to be held down before and after using a MouseMove command, you need to use {Blind}.

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: Control key not held down

Post by milkygirl90 » 27 Jul 2021, 17:34

Ianizer wrote:
27 Jul 2021, 10:28
You could merge some Send commands together like so:

Code: Select all

#If WinActive("ahk_exe IDMan.exe")
^k::
Send !do ;the Send command releases any currently-held-down modifiers automatically and un-releases them when done, so no need to release Control unless you use {Blind}. Sorry I made things confusing with the first script's comments.
Sleep 300
SendInput ^{tab}
Sleep 100
SendInput ^{tab}{tab 4}
return
Something I should clarify: {Blind} usually isn't needed with Send, but for unknown (to me) reasons, if you want Control to be held down before and after using a MouseMove command, you need to use {Blind}.
The above was my original script but it couldn't work without Blind command (i.e. control doesn't get held down..)

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: Control key not held down

Post by milkygirl90 » 27 Jul 2021, 17:34

Ianizer wrote:
27 Jul 2021, 10:28
You could merge some Send commands together like so:

Code: Select all

#If WinActive("ahk_exe IDMan.exe")
^k::
Send !do ;the Send command releases any currently-held-down modifiers automatically and un-releases them when done, so no need to release Control unless you use {Blind}. Sorry I made things confusing with the first script's comments.
Sleep 300
SendInput ^{tab}
Sleep 100
SendInput ^{tab}{tab 4}
return
Something I should clarify: {Blind} usually isn't needed with Send, but for unknown (to me) reasons, if you want Control to be held down before and after using a MouseMove command, you need to use {Blind}.
The above was my original script but it couldn't work without Blind command (i.e. control doesn't get held down..)

Post Reply

Return to “Ask for Help (v1)”