This App is No Longer Maintained. Visit the Replacement at StrokesPlus.net

StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General Discussion
 You Know What Really Grinds My Gears?
 Small annoyance: Capslock sensitive
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

durexlw

13 Posts

Posted - 01/11/2013 :  08:53:22  Show Profile
If my capslock is on, then the keystrokes that are send with "acSendKeys" are different, compared to when my capslock on the keyboard is off.

I kinda expect if I send a keystroke "a", that this regardless of the capslockstate of my keyboard is send as "a" and not "A".

Rob

USA
2615 Posts

Posted - 01/11/2013 :  09:42:19  Show Profile  Visit Rob's Homepage
Obviously it's not worth building in something that checks/optionally toggles CAPS Lock for the rare occasions it happens, but you can use Alien to help!

Put this in your Global Lua:
VK_CAPITAL = 0x14

aliencore = alien.core
user32 = aliencore.load("user32.dll")

-- ************ GetKeyState ************

gGetKeyState = user32.GetKeyState
gGetKeyState:types{ ret = 'short', abi = 'stdcall', 'uint' }

function aGetKeyState(VK)
	return gGetKeyState(VK)
end

And this in your action:
local iCapsOn = aGetKeyState(VK_CAPITAL) --Get the current state of the CAPS Lock key

if iCapsOn == 1 then --CAPS Lock is on, turn it off
	acSendKeys("{CAPSLOCK}")
end

acSendKeys("Hello") --send your keys here

if iCapsOn == 1 then --CAPS Lock was on at the start of this script, so turn it back on
	acSendKeys("{CAPSLOCK}")
end

Note that I only tested this for the CAPS Lock key, not the other reasons for calling GetKeyState; just noting in case the function is not ideal for other situations.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 01/11/2013 :  09:46:48  Show Profile  Visit Rob's Homepage
Of course, you could also make a function in Global Lua (in addition to the Global Lua above) which encapsulates this:
function acSendKeysNoCAPSLock(keys)    
    local iCapsOn = aGetKeyState(VK_CAPITAL) --Get the current state of the CAPS Lock key

    if iCapsOn == 1 then --CAPS Lock is on, turn it off
    	acSendKeys("{CAPSLOCK}")
    end

    acSendKeys(keys) --send your keys here

    if iCapsOn == 1 then --CAPS Lock was on at the start of this script, so turn it back on
    	acSendKeys("{CAPSLOCK}")
    end
end

And call it instead:
acSendKeysNoCAPSLock("Test")
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000