I am having problems with my script freezing up after some commands, seems to decay and only goes away after I press CTRL after running a script.
The freezing seems to be holding down the CTRL key.
Could somebody take a look and see if I messed anything up?
;Schedule Yourself for the next 30 minutes
^]::
CoordMode, Mouse, Screen
MouseClick, Left, 3693, 350
Sleep, 50
MouseClick, Left, 3224 , 447
Sleep, 25
FormatTime, currentdatetime,, hh:mm
SendInput %CurrentDateTime%
MouseClick, Left, 3777, 443
var:=A_Now ; get the time
EnvAdd, Var, 30 ,Minits ; add 30 minits
FormatTime, var,%var%, hh:mm ; format the time
SendInput,%Var% ; display the new time
MouseClick, Left, 2966, 611
Return
;Todays date
^\::
FormatTime, CurrentDateTime,, dd/MM/yy
SendInput %CurrentDateTime%
Return
;Callback
^p::
SendInput,
(
Please give us a call back at your earliest convenience{!}
)
Return
;Is there anything else
^i::
SendInput,
(
Is there anything else I can help you with?
)
Return
;Left A VM
^1::
SendInput,
(
*******************We've Left A Voice Mail*******************
WE NEED THE FOLLOWING FROM YOU:
THINGS YOU CAN TRY IN THE MEANTIME:
OUR NEXT STEPS: We will need additional information. Please respond to this email, or contact us at 801-562-8778.
If there is a window of time you would like to schedule a call, let us know and we will do our best to reschedule during that window of time.
Called Client (y/n): Y
Emailed Client (y/n): Y
******************We'll Continue To Follow-up*****************
)
Return
;Client Coms
^2::
SendInput,
(
******************NEW Message from i.t.NOW******************
Thank you,
Ian
OUR NEXT STEPS: Waiting client response
Called Client (y/n): Y
Emailed Client (y/n): Y
**********************************************************
)
Return
;Ticket Resolution
^3::
SendInput,
(
**********************Ticket Resolution**********************
TODAY WE ASSESSED:
SOLUTION:
Called Client (y/n): Y
Emailed Client (y/n): Y
*********************************************************
Upon closing your request, you may receive the world's simplest survey.
Just click on the appropriate icon to indicate your satisfaction level and let us know how we are doing{!}
If you need further assistance please reach us at 801-562-8778, help@itnow.net or on the web at http://itnow.net
We make IT look easy{!}
)
Return
;New Ticket
^4::
SendInput,
(
*************************************
Caller Name (First/Last):
Best Contact Number/Ext:
Problem Description:
Do you have an existing ticket this issue is in regards to (ie: New Workstation): No
When did your issue start: Today
Is this a new issue, or has it occurred before: New
How many devices/people are affected: 1
i.t.NOW Management ID:
Additional notes: N/A
*************************************
TICKET NUMBER PROVIDED TO USER: YES
*************************************
)
Return
;Ticket Escalation
^5::
SendInput,
(
******************Ticket Escalation**********************
Priority of request:
Date/Time REQUIRED:
Tech to escalate to:
Estimated time required:
Problem description:
Troubleshooting performed:
Suspected causes:
i.t.NOW Management ID:
Configuration added to ticket:
Computer/Server up-time:
Computer/Server Operating System:
Log in info:
Additional Notes:
******************************************************
)
Return
CTRL Key stuck after script
Re: CTRL Key stuck after script
When the hotkey triggers, CTRL is held, because your hotkeys use CTRL
You use SendInput, and I am not hugely familiar with it's idiosyncrasies, but try sending a Ctrl up event as soon as the hotkey starts processing, eg:
Other workarounds may be:
Do not use Ctrl in your hotkeys (Try remapping the Function keys, they are largely useless these days anyway)
Copy the text to the clipboard and then just paste the clipboard, rather than sending keystrokes
You use SendInput, and I am not hugely familiar with it's idiosyncrasies, but try sending a Ctrl up event as soon as the hotkey starts processing, eg:
Code: Select all
^\::
Send Ctrl up
Do not use Ctrl in your hotkeys (Try remapping the Function keys, they are largely useless these days anyway)
Copy the text to the clipboard and then just paste the clipboard, rather than sending keystrokes
Re: CTRL Key stuck after script
Thanks I will give this a try and let you know if it works.
Re: CTRL Key stuck after script
I tried this for a while and unfortunately I am still having the problem. Remapping as function keys works, however using the ctrl key would be very useful if I could get it working somehow.
Re: CTRL Key stuck after script
I often have issues with modifier keys getting "stuck" in my scripts - usually when I use blockinput but sometimes other times. One thing I've had some success with is making sure the hotkey doesn't do anything until I release the modifier keys. You can do this:
If you put that as the first two lines of the hotkey, it will make sure nothing else happens until you release control, which should help.
Code: Select all
while (GetKeyState("Ctrl"))
sleep, -1
Re: CTRL Key stuck after script
I have also had this problem, posted my solution here: https://stackoverflow.com/questions/490 ... -key-stuck
Re: CTRL Key stuck after script
DO NOT DO THIS!MaxAstro wrote:I often have issues with modifier keys getting "stuck" in my scripts - usually when I use blockinput but sometimes other times. One thing I've had some success with is making sure the hotkey doesn't do anything until I release the modifier keys. You can do this:If you put that as the first two lines of the hotkey, it will make sure nothing else happens until you release control, which should help.Code: Select all
while (GetKeyState("Ctrl")) sleep, -1
Observe what happens if you use that technique in some code - run the following code and hold F1, hold F2, then release F1.
The release for F1 is NOT triggered until you release F2, and also notice that A_ThisHotkey is wrong.
Code: Select all
F1::
while (GetKeyState(A_ThisHotkey))
Sleep -1
Tooltip % "F1 RELEASE @ " A_TickCount "(A_ThisHotkey = " A_ThisHotkey ")", 0, 0, 1
return
F2::
while (GetKeyState(A_ThisHotkey))
Sleep -1
Tooltip % "F2 RELEASE @ " A_TickCount "(A_ThisHotkey = " A_ThisHotkey ")", 0, 30, 2
return
Re: CTRL Key stuck after script
Okay, yes, it doesn't work if you are triggering multiple hotkeys simultaneously because of limitations with GetKeyState. In my use case as far as I can tell it works fine because all of my hotkeys are discreet; they never trigger concurrently. I also don't use A_ThisHotKey.
That all said, in most cases, putting a one second sleep at the start of the script - long enough to be sure the key has been released - probably works just as well.
Alternatively, would doing this achieve the "wait until released" while dodging the issues with GetKeyState?
That all said, in most cases, putting a one second sleep at the start of the script - long enough to be sure the key has been released - probably works just as well.
Alternatively, would doing this achieve the "wait until released" while dodging the issues with GetKeyState?
Code: Select all
Loop
{
Sleep, 400
if (!GetKeyState("Ctrl"))
break
}
Re: CTRL Key stuck after script
No, that code still suffers from the exact same issues (It's still a blocking wait). Bear in mind that Sleep is still a blocking call in AHK! Whilst, for example, a Sleep -1 yields to other processes, it DOES NOT yield to suspended AHK threads (Only the finishing of the thread that interrupted it does)
The ONLY ways to handle key release detection with no side-effects are to use an Up event hotkey, or a SetTimer that checks the state.
This thread has more information as to what is going on and why it is a problem: https://autohotkey.com/boards/viewtopic.php?t=19745
The ONLY ways to handle key release detection with no side-effects are to use an Up event hotkey, or a SetTimer that checks the state.
This thread has more information as to what is going on and why it is a problem: https://autohotkey.com/boards/viewtopic.php?t=19745
Re: CTRL Key stuck after script
try puting this at the end
Code: Select all
Send, {Blind}
Re: CTRL Key stuck after script
What does sending blind on it's own do?
Re: CTRL Key stuck after script
it did help me a lot in my scripts where ctrl being stuck
https://autohotkey.com/docs/commands/Send.htm#blind
https://autohotkey.com/docs/commands/Send.htm#blind
Re: CTRL Key stuck after script
Sorry if I'm not understanding correctly, but wouldn't that mean that ANY blocking wait, regardless of what it is waiting for, would have that issue?
-
- Posts: 1
- Joined: 30 Aug 2019, 09:27
Re: CTRL Key stuck after script
I was having the same issue. This solved it for me: https://autohotkey.com/board/topic/88715-control-key-getting-stuck/
TLDR, remove this from top of script:
TLDR, remove this from top of script:
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.