Jump to content
Sign in to follow this  
Guest vash17

Calling experienced coders!

Recommended Posts

Guest vash17

Okay, I was wondering if it is possible to use Caps Lock to toggle hitting a key twice, into another application.

Case 1:

Caps Lock is OFF! I press A, it inputs A into "Application".

Case 2:

Caps Lock is ON! I press A, and it inputs A, A (at approximately 10 milliseconds) into "Application".

It doesn't matter if the letter A is in caps or not. That can be fixed later.

Thanks a lot!

Share this post


Link to post
Share on other sites
Lazycat

Try this code, based on modified _IsPressed function.

While 1
    Sleep(10)
    $nKey = _IsPressedMod()
    If $nKey > 0 and _CapsLockOn() Then Send(Chr($nKey))
Wend

Func _CapsLockOn()
    Local $ret = DllCall("user32.dll", "int", "GetKeyState", "long", 0x14); VK_CAPITAL
    Return(BitAND($ret[0], 1))
EndFunc

Func _IsPressedMod()
  Local $aR
  For $i = 0x41 To 0x7A ; A..Z, a..z
      $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", '0x' & Hex($i,2))
      If BitAND($aR[0], 0x8000) Then Return $i
  Next
  Return 0
EndFunc

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.