AllenAdministrator
(KiX Supporter)
2008-10-04 09:31 AM
GetKeyState and SetKeyState Using DynaWrapper

As part of my learning process, here is the fruit of my labor. Thanks to Arend for getting me started. You may have created a monster. It's 3:30am my time, and I have to be up in 4 hours... I'll review this again because I am afraid of what I may have missed.

? GetKeyState("Capslock")
? SetKeyState("Capslock","on")
 
Function GetKeyState($Key) dim $objDynaWrap $objDynaWrap=CreateObject("DynamicWrapper") if @error exit @error endif Select Case $key="ScrollLock" $key=&00000091 Case $key="CapsLock" $key=&00000014 Case $key="NumLock" $key=&00000090 endselect $=$objDynaWrap.Register("USER32.DLL","GetKeyState", "i=l", "f=s", "r=u") $GetKeyState=$objDynaWrap.GetKeyState($Key) EndFunction
Function SetKeyState($Key,$toggle) dim $rc if $toggle="on" $toggle="1" endif if $toggle="off" $toggle="0" endif if $key="Numlock" or $key="Capslock" if GetKeyState($key)<>$toggle $rc=Sendkeys("{" + $key + "}") endif endif EndFunction





Arend_
(MM club member)
2008-10-04 10:20 AM
Re: GetKeyState and SetKeyState Using DynaWrapper

Very nice \:D


AllenAdministrator
(KiX Supporter)
2008-10-05 06:35 AM
Re: GetKeyState and SetKeyState Using DynaWrapper

I updated the SetKeyState, and it can now be found in the UDFs here:
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=190022&Main=25720#Post190022