Jump to content

Recommended Posts

Posted

I've run across this issue when trying to remap keyboard letters, best shown in this code

Opt("SendCapslockMode", 0)
HotKeySet("a","func1")
HotKeySet("A","func2")
While 1
Sleep(10)
WEnd
Func func1()
Send("b")
EndFunc
Func func2()
Send("B")
EndFunc

If I hold SHIFT, the first time I press "a", func2 will be called. But as long as I keep holding SHIFT after that, func1 will be called instead, which isn't the desirable behavior for me. I have to release SHIFT and hold it again to call func2. I want func2 to be called as long as SHIFT is held. What can I do about this, and why is it happening in the first place?

  • 2 weeks later...
Posted

I tried replace "A" and "B" with "+a" and "+b" (and any combination of those), but I still get the same behavior.

  • Moderators
Posted

The only other way I can see to do it would be to point both HotKeys to func1, and then do an If statement to check whether SHIFT is pressed. Something like this perhaps:

#include <Misc.au3>
Local $hDLL = DllOpen("user32.dll")
HotKeySet("a","func1")
HotKeySet("A", "func1")

While 1
Sleep(10)
WEnd

Func func1()

   If _IsPressed(10, $hDLL) Then
     func2()
   Else
     MsgBox(0, "", "a was selected.")
   EndIf

EndFunc

Func func2()

MsgBox(0, "", "A was selected.")
 
EndFunc

DllClose($hDLL)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
×
×
  • Create New...