Jump to content

Keys getting stuck in the "down" position


Recommended Posts

When I hotkey a macro with say, alt+n for example, it appears after the program executes, the alt key gets stuck in the down position. any history with an issue like this?

I've tried using blockinput and variations on sleep and send("{altup}") at the end of the program, but it still sometimes gets hung.

Is there a way for autoit to "see" if a key is in the down positon and correct it? or, can you reset the keyboard in some way after a prog executes? Thank you for your help.

Link to comment
Share on other sites

When I hotkey a macro with say, alt+n for example, it appears after the program executes, the alt key gets stuck in the down position. any history with an issue like this?

I've tried using blockinput and variations on sleep and send("{altup}") at the end of the program, but it still sometimes gets hung.

Is there a way for autoit to "see" if a key is in the down positon and correct it? or, can you reset the keyboard in some way after a prog executes? Thank you for your help.

I had exactly the same thing happen to me when using a hotkey to trigger a macro. See here for martin's explanation of what causes the problem.

Edited by philw
Link to comment
Share on other sites

Is there a way for autoit to tell when a key has been released?

Not _IsPressed but something like _IsReleased would fix the hotkey keystuck problem.

Martin's explanation makes good sense, and what he provides as a solution is well recieved, however having a window pop up everytime a person holds alt or shift or delete too long seems like more of a bandaid than a solution.

Martins solution:

Func _SendEx($ss)

Local $iT = TimerInit()

While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")

If TimerDiff($iT) > 100 Then

MsgBox(262144, "Warning", "Shift, Ctrl and Alt Keys need to be released to proceed!")

EndIf

WEnd

Send($ss)

EndFunc ;==>_SendEx

Link to comment
Share on other sites

Sorry for my ignorance. It seems with some correct placment of

Func while_button()

While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")

Sleep(300)

WEnd

EndFunc

Solves the problem nicely.

HotKeySet("^d", "Pastedate")

Func pastedate()

while_button()

run(@ProgramFilesDir & "\Unison Tools\Paste Today Date.exe")

EndFunc

Paste Today Date.exe is:

#include <Date.au3>

#include <Misc.au3>

_Singleton(@ScriptFullPath)

AdlibEnable("Terminate",3000)

WinSetState("", "", @SW_ENABLE)

$date = StringSplit(_NowDate(), "")

For $I = 1 To Ubound($date)-1

Sleep(5)

Send($date[$I])

Next

Sleep(50)

Exit

Func Terminate()

Exit

EndFunc

Edited by boji
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...