ResNullius Posted June 13, 2007 Posted June 13, 2007 Since a lot of people seem to be experiencing problems with "Send", "ControlSend" and various configurations of "SendCapslockMode" I thought I would whip up a little udf to check the state of the lock keys and then we can set it to what we need it to be, do our send(s) and then restore it. I know "SendCapslockMode" option is supposed to be able to do this, but I still have (intermittent) problems, even with setting the "SendAttachMode" option. I know that having this return 0 on an error is not such a good idea (since it also returns 0 for OFF, but I wanted a simple Synatx for checking the state: ie: "If GetLockKeyState("caps") then ..." . If anybody has any ideas on how to make this better, please go right ahead. Thanks expandcollapse popup;=============================================================================== ; AutoIt Version: 3.2.49 ; ; Description: Returns the state of the specified "lock key": ; CapsLock, ScrollLock, or Numlock ; ; Syntax: _GetLockKeyState($sLockKey) ; ; Parameter(s): $sLockKey = The "lock" key to check the state of: ; in the format "CAPS" or "SCROLL" or NUM" (case insensitive) ; ; Requirement(s): None ; ; Return Value(s): On Success - Returns an integer representation of the ; lock key's state, 1 being "ON", 0 being "OFF", and ; sets @ERROR = 0 ; ; On Failure - Returns 0 and sets ; @ERROR = 1 if $sLockKey is not valid parameter ; @ERROR = 2 if DllCall fails for some reason ; ; Author(s): ResNullius based on th.meger ; ; Note(s): based on routine posted by th.meger in this thread: ; http://www.autoitscript.com/forum/index.php?s=&showtopic=39681&view=findpost&p=295635 ; ; Version : 1.0 ;=============================================================================== ; ;Uncomment next two lines for example ;$LockState = _GetLockKeyState("caps") ;If $LockState And Not @error Then MsgBox(4096, "_GetLockKeyState", "Lockstate is: " & $LockState & @CRLF & "@error: " & @error) #include-once Func _GetLockKeyState($lLockKey) Local $lGetKey, $lLockKeyState Switch StringUpper($lLockKey) Case "CAPS" $lGetKey = 0x14 Case "NUM" $lGetKey = 0x90 Case "SCROLL" $lGetKey = 0x91 Case Else ;MsgBox(16+4096,"CALL ERROR","Call to _GetLockKeyState() failed with" & @CRLF & CHR(34) & $lLockKey & CHR(34) & "... unrecognized parameter") SetError(1) Return 0 EndSwitch Local $lLockKeyState = DllCall("user32.dll", "long", "GetKeyState", "long", $lGetKey) ; Capslock If Not @error Then SetError(0) Return $lLockKeyState[0] Else SetError(2) Return 0 EndIf EndFunc ;==>_GetLockKeyState
GaryFrost Posted June 13, 2007 Posted June 13, 2007 http://www.autoitscript.com/forum/index.ph...ost&p=96980 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
ResNullius Posted June 13, 2007 Author Posted June 13, 2007 (edited) http://www.autoitscript.com/forum/index.ph...ost&p=96980DOH! Now why couldn't I find that when I was searching... As Gilda (as Emily) used to say: "Nevermind..."Edit: If anybody wants me, I'll be working ont the next great thing: it's round and goes on the bottom of things to help move them. I haven't worked out all the details yet, but I've come up with a working name: I'm going to call it the "wheel". Whaddya think? Edited June 13, 2007 by ResNullius
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now