Jump to content

Capital Letter Hotkey


Recommended Posts

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?

Link to comment
Share on other sites

  • 2 weeks later...
  • Moderators

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!

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...