I have a hotkey with Ctrl and space.
Sometimes after the hotkey the ctrl seems to stay pressed. If have added
Send,{Ctrl UP}
at the end of the hotkey, but it seems to stay pressed sometimes although. Is this a known bug or is there a solution for this problem?
Thanks!
Ctrl seems to stay pressed
-
- Posts: 216
- Joined: 30 Jun 2016, 06:01
Re: Ctrl seems to stay pressed
I've had this problem many times myself. I'd also love a solution. I play games and use many hotkeys, and often, one key seems to get stuck, usually ctrl, shift, or alt.
Re: Ctrl seems to stay pressed
Show your code.
Very hard to tell without seeing some code.
I suspect that you are doing something like ^Space::a but not appreciating that what this actually does when you hit Ctrl+Space is RELEASE ctrl, send A, then hold Ctrl again (Because you asked AHK to send a, not CTRL+a).
If using syntax like this with a game, then if your KeyDelay setting is not high enough, then the game will interpret this sequence of key events wrongly, because keys go down and up within one frame of the game, and so are ignored.
In this instance, you should use ^Space::Send {Blind}a instead. Also try adding SetKeyDelay, 0, 50 to the start of the script.
When you perceive CTRL as being "Stuck" down - check the AHK key history to see what the OS thinks the state of the key is.
Very hard to tell without seeing some code.
I suspect that you are doing something like ^Space::a but not appreciating that what this actually does when you hit Ctrl+Space is RELEASE ctrl, send A, then hold Ctrl again (Because you asked AHK to send a, not CTRL+a).
If using syntax like this with a game, then if your KeyDelay setting is not high enough, then the game will interpret this sequence of key events wrongly, because keys go down and up within one frame of the game, and so are ignored.
In this instance, you should use ^Space::Send {Blind}a instead. Also try adding SetKeyDelay, 0, 50 to the start of the script.
When you perceive CTRL as being "Stuck" down - check the AHK key history to see what the OS thinks the state of the key is.
Re: Ctrl seems to stay pressed
You might want to consider #HotkeyModifierTimeout.
Re: Ctrl seems to stay pressed
interesting, I was not aware of that directive.
Re: Ctrl seems to stay pressed
Here my code. #HotkeyModifierTimeout 100 didnt work....evilC wrote:Show your code.
Very hard to tell without seeing some code.
I suspect that you are doing something like ^Space::a but not appreciating that what this actually does when you hit Ctrl+Space is RELEASE ctrl, send A, then hold Ctrl again (Because you asked AHK to send a, not CTRL+a).
If using syntax like this with a game, then if your KeyDelay setting is not high enough, then the game will interpret this sequence of key events wrongly, because keys go down and up within one frame of the game, and so are ignored.
In this instance, you should use ^Space::Send {Blind}a instead. Also try adding SetKeyDelay, 0, 50 to the start of the script.
When you perceive CTRL as being "Stuck" down - check the AHK key history to see what the OS thinks the state of the key is.
Code: Select all
SetTitleMatchMode, Slow
SetTitleMatchMode, RegEx
#SingleInstance force
setcapslockstate, alwaysoff
Autotrim,On
Sendmode Input
DetectHiddenWindows, On
DetectHiddenText, On
WinActivate,Force
StringCaseSense,Off
SetBatchLines -1
SetControldelay -1
SetKeyDelay -1
SetWinDelay,-1
SetMouseDelay,-1
Menu,TRAY,Color,FF00FF
Menu,TRAY,NoStandard
Menu,Tray,Add,Hilfe,Hilfe
Menu,Tray,Add,Protokoll Öffnen,FVProt
Menu,Tray,Add
Menu,Tray,Add,Programm neu starten,neustart
Menu,Tray,Add,Programm Pause AN/AUS,progpause
Menu,Tray,Add,Programm Beenden,CloseAdminLogon
Logname:=RegExReplace(A_Scriptname,"(.*)(exe|ahk)","$1txt")
IfNotExist,C:\tmp
FileCreateDir,c:\tmp
IfExist,%logname%
FileMove,%Logname%,c:\tmp\%logname%,1
Logname:="c:\tmp\" . Logname
if not A_IsAdmin
RunAsAdmin()
Hilfedatei:="C:\tmp\" . A_Scriptname . "_Hilfe.txt"
IfExist,%Hilfedatei%
FileDelete,%Hilfedatei%
FileAppend,
(Ltrim
Strg+Leertaste: IP (oder IDF) in den Fastviewer kopieren und suchen (es kann ruhig mehr als die IP-Adresse markiert sein)
Strg+l oder Strg+Shift+l: Bei Remote-Anmeldung als Administrator anmelden
Strg+Shift+s: Bei Remote-Anmeldung als Service anmelden
Hinweis bei Windows10:
Falls die Automatische Remote-Anmeldung nicht klappt: Bitte einmal manuell als Administrator bei einer Apotheke anmelden und hierbei den Haken "Anmeldedaten speichern" setzen. Ab dann sollte es funktionieren.
),%Hilfedatei%
Loop
{
IfWinExist,Fernwartung
If (WinExist("Windows-Sicherheit ahk_exe FastMaster.*","(Anmeldedaten speichern)") or WinExist("Windows-Sicherheit ahk_class Credential Dialog Xaml Host ahk_exe FastMaster.*"))
{
If (!NotShow)
{
WinActivate
Msgbox,4132,Als Administrator anmelden?,Soll ich dich automatisch als Administrator anmelden?`n`n(In 5 Sekunden wird automatisch angemeldet),5
IfMsgbox,No
WinWaitClose,Windows-Sicherheit ahk_exe FastMaster.*
else
Gosub,AdminAnmeldung
}
}
Sleep 500
Send,{Ctrl Up}
}
^l::
^+l::
^+s::
AdminAnmeldung:
zusatz:=""
If A_Thislabel=AdminAnmeldung
zusatz:=" ahk_exe FastMaster.*"
FileAppend,-> Automatische Remote-Anmeldung wurde gestartet.`n,%Logname%
user:="xxx"
pw:="xxx"
If (A_ThisLabel="^+s")
{
user:="yyy"
pw:="yyy"
}
;Neu ab Windows10
If WinExist("Windows-Sicherheit ahk_class Credential Dialog Xaml Host ahk_exe FastMaster.*")
{
NotShow:=1
Blockinput,Mouse
Coordmode,Mouse,Relative
WinActivate
Click,103,291
Send,{TAB}
WinActivate
Send,{Space}
Sleep 100
WinActivate
Send,{TAB 2}
WinActivate
Send,{Space}
WinActivate
Sleep 100
Click,96,255
Send,%user%{TAB}%pw%{ENTER}
Coordmode,Mouse,Screen
Blockinput,Off
;Hier neu
Sleep 1000
WinWait, Windows-Sicherheit ahk_class Credential Dialog Xaml Host ahk_exe FastMaster.*,,5
If WinExist("Windows-Sicherheit ahk_class Credential Dialog Xaml Host ahk_exe FastMaster.*")
{
Blockinput,Mouse
Coordmode,Mouse,Relative
WinActivate
Send,{TAB 2}
WinActivate
Send,{Space}
Sleep 100
WinActivate
Send,{TAB 2}
WinActivate
Send,{Space}
WinActivate
Sleep 100
Send,%user%{TAB}%pw%{ENTER}
Coordmode,Mouse,Screen
Blockinput,Off
}
NotShow:=0
}
Else
IfWinExist,Windows-Sicherheit%zusatz%,(Anmeldedaten speichern)
{
IfWinNotActive,Windows-Sicherheit%zusatz%,(Anmeldedaten speichern), WinActivate, Windows-Sicherheit%zusatz%,(Anmeldedaten speichern)
WinWaitActive,Windows-Sicherheit%zusatz%,(Anmeldedaten speichern)
sleep, 300
Send, {Down}%user%{TAB}%pw%{ENTER}
Sleep 1000
ControlSetText,Edit1,%user%,Windows-Sicherheit%zusatz%,(Anmeldedaten speichern)
ControlSetText,Edit2,%pw%,Windows-Sicherheit%zusatz%,(Anmeldedaten speichern)
ControlClick,Button2,Windows-Sicherheit%zusatz%,(Anmeldedaten speichern)
}
Else
IfWinExist,Fernwartung
{
IfWinNotActive, Fernwartung, , WinActivate, Fernwartung,
WinWaitActive, Fernwartung,
MouseClick, left, 966, 474
Sleep, 100
Send,%user%{TAB}%pw%{ENTER}
}
Send,{Ctrl up}
Return
Ctrl & Space::
IP=
altClip:=ClipBoard
Send,^c
clipwait,3
Sleep 300
StringReplace,IP,clipboard,`n,,ALL
StringReplace,IP,IP,`r,,ALL
StringReplace,IP,IP,%A_SPACE%,,ALL
FoundPos:=RegExMatch(IP,"10\.(\d*)\.(\d*)\.(\d*)")
If (FoundPos > 0)
{
IP:=RegExReplace(IP,".*10\.(\d*\.\d*)\.\d*.*","10.$1.")
;Tooltip,IP %IP% gefunden!,15,15
}
else
{
FoundPos:=RegExMatch(IP,"(\d*)")
If (FoundPos > 0)
IP:=RegExReplace(IP,"[^0-9]","")
}
clipboard:=IP
FileAppend,%A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec% - %IP% wurde gesucht.`n,%Logname%
IfWinExist,Fernwartung
{
WinActivate
WinMaximize,Fernwartung
WinWaitActive,Fernwartung,,3
If !ErrorLevel
{
Coordmode,Mouse,Relative
ControlGetPos,X,Y,,,FWinCustomControl1,Fernwartung
If X
{
x:=x+5
y:=y+5
MouseClick,Left,%X%,%Y%
Sleep 100
MouseClick,Left,16,69
}
ControlGetPos,X,Y,,,SysTreeView322,Fernwartung
;MouseClick,Left,%X%,%Y%
x:=x+20
y:=y+20
Sleep 200
Send,{UP}
Sleep 200
WinGet,Controls,ControlList,Fernwartung
EditX:=RegExReplace(Controls,"m).*(Edit\d*).*","$1")
ControlGetPOs,X,Y,,,%EditX%,Fernwart
x:=x+10
y:=y+10
;msgbox EditX: %EditX% x: %x% y: %y%
MouseClick,Left,%X%,%Y%,2
Sleep 100
Send,{Del 15}{BS 15}
Send,^v
Sleep 100
Send,{ENTER}
}
}
Else
{
fastmaster=
Loop,D:\Dokus\FastMaster*.exe
{
IfNotInstring,A_LoopFileName,Supported
{
Run, % fastmaster:=A_LoopFileFullPath
Sleep 2000
}
}
If fastmaster=
MsgBox,16,Start Fastviewer first!,I really wished your FastViewer was started!`n`nAber wenn du ihn nach D:\Dokus legst`, starte ich ihn dir das nächste Mal automatisch!,3
FileAppend,--> Fastviewer war nicht gestartet!`n,%Logname%
}
ClipBoard:=altClip
Settimer,ToolTipOff,-1
Send,{Ctrl up}
Return
ToolTipOff:
Sleep 1500
Tooltip
Return
FVProt:
IfExist,%logname%
Run,%Logname%
else
Msgbox,64,Fehler!,%logname% existiert (noch?) nicht.
Return
CloseAdminLogon:
ExitApp
Return
neustart:
Reload
Exitapp
Return
progpause:
Pause,Toggle
Return
Hilfe:
IfExist,%Hilfedatei%
Run,%Hilfedatei%
else
Msgbox,64,Fehler,%Hilfedatei% existiert nicht!
Return
RunAsAdmin() {
global
Loop, %0% ; For each parameter:
params .= A_Space . %A_Index%
local ShellExecute
ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
if not A_IsAdmin
{
A_IsCompiled
? DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, params , str, A_WorkingDir, int, 1)
: DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """" . A_Space . params, str, A_WorkingDir, int, 1)
ExitApp
}
}
Re: Ctrl seems to stay pressed
I don't think my suggestion applies to your case.
It might not matter, but consider this,
It might not matter, but consider this,
That is, try ^Space:: instead of Ctrl & Space::.The manual wrote: For standard modifier keys, normal hotkeys typically work as well or better than "custom" combinations. For example, <+s:: is recommended over LShift & s::.
Re: Ctrl seems to stay pressed
I will try this, thanks!Helgef wrote:I don't think my suggestion applies to your case.
It might not matter, but consider this,That is, try ^Space:: instead of Ctrl & Space::.The manual wrote: For standard modifier keys, normal hotkeys typically work as well or better than "custom" combinations. For example, <+s:: is recommended over LShift & s::.
-
- Posts: 216
- Joined: 30 Jun 2016, 06:01
Re: Ctrl seems to stay pressed
I've had this problem with something as simple as this:
After using this hotkey, sometimes CTRL gets "held down" until I press it again. I haven't tried using setkeydelay, might help. Big problem with testing is that the problem occurs randomly and rarely.
Code: Select all
^p::
Send m
Sleep 500
Send {Up}{Return}{Esc}
Return
Re: Ctrl seems to stay pressed
Does this work? Ctrl Up, or LCtrl Up?
One thing I do that is similar:
Code: Select all
^p::
Send {Ctrl Up}m
Sleep 500
Send {Up}{Return}{Esc}
Return
Code: Select all
RAlt & Left:: ;internet explorer - tab back/forward
SendInput {RAlt Up}!{Left}
return
RAlt & Right:: ;internet explorer - tab back/forward
SendInput {RAlt Up}!{Right}
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Ctrl seems to stay pressed
If anything, I'd try something lower than the default 50, perhaps 25.aaffe wrote:#HotkeyModifierTimeout 100 didnt work....
@ jeeswg, does SendInput {RAlt Up}!{Left} work better for you than SendInput,!{Left} ?
Re: Ctrl seems to stay pressed
@Helgef, you had me worried I was going to do a facepalm, but actually no. I tried !{Left} and !{Right}, and it worked very intermittently, often not working, and causing the menu bar to appear sometimes. The {RAlt Up} version that I shared worked really smoothly. Before that I was using a method involving KeyWait (see below). Nice emoticon usage btw hehe.
Code: Select all
;good method
RAlt & Left:: ;internet explorer - tab back/forward
SendInput {RAlt Up}!{Left}
return
RAlt & Right:: ;internet explorer - tab back/forward
SendInput {RAlt Up}!{Right}
return
;==================================================
;other method
;RAlt & Left:: ;internet explorer - tab back/forward
BlockInput, On
ToolTip, release AltGr key
KeyWait, Alt
ToolTip
SendInput !{Left}
BlockInput, Off
return
;RAlt & Right:: ;internet explorer - tab back/forward
BlockInput, On
ToolTip, release AltGr key
KeyWait, Alt
ToolTip
SendInput !{Right}
BlockInput, Off
return
;==================================================
;problem method
;RAlt & Left:: ;internet explorer - tab back/forward
SendInput !{Left}
return
;RAlt & Right:: ;internet explorer - tab back/forward
SendInput !{Right}
return
;==================================================
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
-
- Posts: 1
- Joined: 16 Mar 2017, 09:45
Re: Ctrl seems to stay pressed
never use < in hotkey
this character leads to stay pressed hotkey
i mean never use like below
<^<+z::
bless you all.
this character leads to stay pressed hotkey
i mean never use like below
<^<+z::
bless you all.
Re: Ctrl seems to stay pressed
Why do you say that? The < symbol just means to use the left key of a pair of keys, so <^<+z:: just says to use the left Ctrl key and the left Shift key along with the Z key.