Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Control key getting stuck



  • Please log in to reply
9 replies to this topic
blixel
  • Members
  • 12 posts
  • Last active: Dec 30 2015 09:08 AM
  • Joined: 14 Aug 2012

I copied the AutoHotkey script from orbiterwiki.org. The script wasn't working for me as is, but I was able to change it so that it does work. However, every time I run the script, the two External MFD's come up just fine, but when the script exits, my computer acts as though the Control key is being held down. I've found that simply tapping the control key 1 time will make my computer let go of the control key, but I'd like to figure out what the problem is because every time I run the script, I have to remember to press my control key afterwards or else all sorts of weird things happen.

Weird things like, if you scroll your mouse wheel while inside of an app, it thinks you are CTRL+scrolling ... which often resizes the text. Or if you press an arrow key, it thinks you are pressing CTRL+arrow key.

Here is my version of the script.

Note that I had to replace Send ^{F4} with
Send {LCtrl down } ;
Send {F4} ;
Send {LCtrl up } ;

For whatever reason, Send ^{F4} simply does not work on my system, but the other way does work? shrug.GIF

To be perfectly clear, my question is: Can anyone identify a problem with this script? Or does anyone have any ideas for things I can try to prevent the control key from being stuck after the script runs?

 

[code=auto:0]; Author: A.N.Other <[email protected]>

;
; Script Function:
;	Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

SetKeyDelay,10,30

pltMfd1PosX:=3
pltMfd1PosY:=123
pltMfd1Width:=634
pltMfd1Height:=479

pltMfd2PosX:=1380
pltMfd2PosY:=123
pltMfd2Width:=634
pltMfd2Height:=479

WinActivate,Orbiter
Send {LCtrl down } ;
Send {F4} ;
Send {LCtrl up } ;
WinWait, Custom
Control, ChooseString, External Mfd, ListBox1, Custom
ControlClick, Button1, Custom
WinWait,MFD
WinSetTitle,pltMfd1
WinMove,pltMfd1,,%pltMfd1PosX%,%pltMfd1PosY%,%pltMfd1Width%,%pltMfd1Height%
WinGet,pltMfd1Handle,ID,pltMfd1
    
WinActivate,Orbiter
Send {LCtrl down } ;
Send {F4} ;
Send {LCtrl up } ;
WinWait, Custom
Control, ChooseString, External Mfd, ListBox1, Custom
ControlClick, Button1, Custom
WinWait,MFD
WinSetTitle,pltMfd2
WinMove,pltMfd2,,%pltMfd2PosX%,%pltMfd2PosY%,%pltMfd2Width%,%pltMfd2Height%
WinGet,pltMfd2Handle,ID,pltMfd2

WinActivate,Orbiter
return


Sanctus
  • Members
  • 283 posts
  • Last active: Dec 06 2014 04:05 PM
  • Joined: 30 Nov 2012

try putting a small delay before doing f4

 

Send, {LCtrl down}
Sleep, 50
Send, {F4}
Send, {LCtrl up}

 

works for me, without sleep it doesnt

but Send, ^{F4} works for me aswell :)


Check out ALL My Scripts  ;)


blixel
  • Members
  • 12 posts
  • Last active: Dec 30 2015 09:08 AM
  • Joined: 14 Aug 2012
try putting a small delay before doing f4

 

Send, {LCtrl down}
Sleep, 50
Send, {F4}
Send, {LCtrl up}

 

works for me, without sleep it doesnt

but Send, ^{F4} works for me aswell smile.png

 

Thanks for the reply. I tried adding the Sleep statement but unfortunately it didn't help. Such an odd problem.



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

Try this:

Send, {LCtrl down}
Send, {F4}
Send, {LCtrl up}
GetKeyState("LCtrl","P")


blixel
  • Members
  • 12 posts
  • Last active: Dec 30 2015 09:08 AM
  • Joined: 14 Aug 2012

Try this:

Send, {LCtrl down}
Send, {F4}
Send, {LCtrl up}
GetKeyState("LCtrl","P")

 

Thank you for the reply. I added the new line but it still didn't help. After the script runs, the control key is stuck on until I physically tap it. Is there a way to change key state?



blixel
  • Members
  • 12 posts
  • Last active: Dec 30 2015 09:08 AM
  • Joined: 14 Aug 2012

I made a video to show what's happening.

 



blixel
  • Members
  • 12 posts
  • Last active: Dec 30 2015 09:08 AM
  • Joined: 14 Aug 2012

Someone else is having this problem too. They seem to have solved it, but they didn't say how.



blixel
  • Members
  • 12 posts
  • Last active: Dec 30 2015 09:08 AM
  • Joined: 14 Aug 2012

I found another person with this problem in this thread.

 

After trying a few different variations.

 

I tried:

 

 

Send, {CTRLDOWN} ;

 

Send, {F4} ;
Send, {CTRLUP} ;
 
That didn't work at all.
 
I tried:
 
Send, {LCtrl down } ;
Send, {F4} ;
Send, {LCtrl up } ;
Send, {CTRLUP} ;
 
That sort of worked, but only 1 of my windows would open.

 

Finally, I ended up with this:

 

At the very end of my script, I added:

 

 

Send, {CTRLUP}

 

 
And now it lets go of the control key before exiting.
 
 
So the whole script is:
 
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <[email protected]>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
 
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
 
SetKeyDelay,10,30
 
pltMfd1PosX:=3
pltMfd1PosY:=123
pltMfd1Width:=634
pltMfd1Height:=479
 
pltMfd2PosX:=1380
pltMfd2PosY:=123
pltMfd2Width:=634
pltMfd2Height:=479
 
WinActivate,Orbiter
Send, {LCtrl down } ;
Send, {F4} ;
Send, {LCtrl up } ;
WinWait, Custom
Control, ChooseString, External Mfd, ListBox1, Custom
ControlClick, Button1, Custom
WinWait,MFD
WinSetTitle,pltMfd1
WinMove,pltMfd1,,%pltMfd1PosX%,%pltMfd1PosY%,%pltMfd1Width%,%pltMfd1Height%
WinGet,pltMfd1Handle,ID,pltMfd1
    
WinActivate,Orbiter
Send, {LCtrl down } ;
Send, {F4} ;
Send, {LCtrl up } ;
WinWait, Custom
Control, ChooseString, External Mfd, ListBox1, Custom
ControlClick, Button1, Custom
WinWait,MFD
WinSetTitle,pltMfd2
WinMove,pltMfd2,,%pltMfd2PosX%,%pltMfd2PosY%,%pltMfd2Width%,%pltMfd2Height%
WinGet,pltMfd2Handle,ID,pltMfd2
 
WinActivate,Orbiter
;Sleep, 500 ; Mine works without the sleep statement.
Send, {CTRLUP}
return
 
Hopefully this thread will be useful to someone else some day. Those other two threads I found helped me.


blixel
  • Members
  • 12 posts
  • Last active: Dec 30 2015 09:08 AM
  • Joined: 14 Aug 2012
✓  Best Answer

I just wanted to come back and add 1 final thing to this topic. This issue with the CTRL key has been a continual pain in my side. I thought I had it solved back in January (per my last post), but it has continued to be a problem off and on. Recently I got a new computer and, for whatever reason, the old solution was no longer working.

 

I believe I have it solved permanently now. The problem seems to have been with this line at the top of the script:

 

SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.

 

I took that line out and now everything works better than ever. Not only do I not need an extra "Send, {CTRLUP}" at the end of the script any more, I also no longer have to do this:

 

Send, {LCtrl down } ;

Send, {F4} ;

Send, {LCtrl up } ;

 

I can now simply do this (which never worked before):

 

Send, ^{F4} ;

 

I am just following up on this post because someone else may run into this some day and this solution my work for them as well.

 



rosto
  • Members
  • 130 posts
  • Last active: Jan 06 2016 01:50 PM
  • Joined: 14 Feb 2006

I have the same problem, 

I took that line out as well but that didn't resolve the problem.

I just have the click on the Control key after using my autohotkey script file.

Don't know even which part it it.