| View previous topic :: View next topic |
| Author |
Message |
beardboy
Joined: 02 Mar 2004 Posts: 444 Location: SLC, Utah
|
Posted: Fri May 07, 2004 12:55 am Post subject: Windows Key State still down after suspend / hibernate |
|
|
| Quote: | | Fixed Win-L (hotkey to lock the computer) so that the Windows key is not considered to be down when you log back in. [thanks Jack Horsfield]. |
I have same problem when I uses a Hotkey to send the computer to suspend or hibernate. I setup a test script to test all the alphabetical keys and the following ones have the same problem:
| Code: | #d::
MsgBox, Hotkey = %A_ThisHotkey%
return
#e::
MsgBox, Hotkey = %A_ThisHotkey%
return
#f::
MsgBox, Hotkey = %A_ThisHotkey%
return
#m::
MsgBox, Hotkey = %A_ThisHotkey%
return
#r::
MsgBox, Hotkey = %A_ThisHotkey%
return
#u::
MsgBox, Hotkey = %A_ThisHotkey%
return |
thanks,
beardboy |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Fri May 07, 2004 1:29 am Post subject: |
|
|
The keyboard/mouse hooks are apparently deactivated by Windows when it does certain things, such as logging out and perhaps switching video resolutions. It looks like Suspend and Hibernate can be added to the list.
The program receives no notification (that I know of) when Windows removes (and then later reactivates) the hooks. It's all done invisibly I think. So unfortunately, I do not think I can fix this. The only reason I was able to fix it for Win+L and Ctrl+Alt+Del is that those are detectible key sequences that have known behavior on specific operating systems.
This problem only affects scripts that use the hooks. The only workaround I know of is to physically press the stuck key when the computer comes out of hibernate/suspend. This resets its physical state as tracked by the hook.
Although I could add a script command that resets the physical modifiers, I'm not sure that would help you. Maybe it would if your hotkey subroutine resumes running where it left off after the hibernate/suspend finishes, thus the command could be run to reset the modifiers.
Here is another workaround: Add a delay in the subroutine that gives you enough time to release the modifiers before the hibernate/suspend takes effect. That way, the hook's tracking should be correct. |
|
| Back to top |
|
 |
beardboy
Joined: 02 Mar 2004 Posts: 444 Location: SLC, Utah
|
Posted: Fri May 07, 2004 1:50 am Post subject: |
|
|
I set the suspend / hibernate with a RunWait, that way the next line will run after the computer comes back. I have set the next line to be a Send, {LWINUP} to fix the problem.
| Code: | FileInstall, c:\winnt\system32\suspend.exe, c:\winnt\system32\suspend.exe, 1
RunWait, c:\winnt\system32\suspend.exe,, hide ; Run suspend.exe
Send, {LWINUP} ; Reset windows key state |
thanks,
beardboy |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Fri May 07, 2004 2:38 am Post subject: |
|
|
| That might not work because the hook tracks the physical state of the modifiers separately from the logical state. So if it thinks the LWin key is physically down, sending {LWinUp} won't reset it because that's artificial (non-physical) input. |
|
| Back to top |
|
 |
beardboy
Joined: 02 Mar 2004 Posts: 444 Location: SLC, Utah
|
Posted: Fri May 07, 2004 2:40 am Post subject: |
|
|
Well it was worth a shot. I have been just hitting the windows key when it happens.
thanks,
beardboy |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Fri May 07, 2004 3:56 am Post subject: |
|
|
| If you throw a "Sleep 500" before the runwait, that might do the trick. All it needs is a little time for you to release the windows key. |
|
| Back to top |
|
 |
|