jftuga Posted June 1, 2005 Share Posted June 1, 2005 I searched the forums but did not come up with anything too quickly. How can I tell if the caps, scroll, and/or the num locks keys are on or off? Thanks, -John Admin_Popup, show computer info or launch shellRemote Manager, facilitates connecting to RDP / VNCProc_Watch, reprioritize cpu intensive processesUDF: _ini_to_dict, transforms ini file entries into variablesUDF: monitor_resolutions, returns resolutions of multiple monitorsReport Computer Problem, for your IT help deskProfile Fixer, fixes a 'missing' AD user profile Link to comment Share on other sites More sharing options...
Helge Posted June 1, 2005 Share Posted June 1, 2005 If I remember correctly it was possible to retrive the state of at least 2 of the 'locks in AutoIt v2. However I haven't seen this been done in v3. It's strange really... It might be possible with a DLLCall though.. Well, my guessing isn't exactly helping you, so maybe someone else can do that..? Anyone ? Link to comment Share on other sites More sharing options...
GaryFrost Posted June 1, 2005 Share Posted June 1, 2005 (edited) Return of 0 is off, 1 is on Global Const $VK_NUMLOCK = 0x90 Global Const $VK_SCROLL = 0x91 Global Const $VK_CAPITAL = 0x14 ConsoleWrite(_GetNumLock() & @LF) ConsoleWrite(_GetScrollLock() & @LF) ConsoleWrite(_GetCaps() & @LF) Func _GetNumLock() Local $ret $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_NUMLOCK) Return $ret[0] EndFunc Func _GetScrollLock() Local $ret $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_SCROLL) Return $ret[0] EndFunc Func _GetCaps() Local $ret $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_CAPITAL) Return $ret[0] EndFunc Edited June 1, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
GaryFrost Posted June 1, 2005 Share Posted June 1, 2005 Or could be 1 function that returns an array of the 3 key states Example: $KeyStates = _GetKeyState() For $i = 1 to $KeyStates[0] ConsoleWrite($KeyStates[$i] & @LF) Next Func _GetKeyState() Const $VK_NUMLOCK = 0x90 Const $VK_SCROLL = 0x91 Const $VK_CAPITAL = 0x14 Local $ret, $a_keystate[4] $a_keystate[0] = 3 $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_NUMLOCK) $a_keystate[1] = $ret[0] $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_SCROLL) $a_keystate[2] = $ret[0] $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_CAPITAL) $a_keystate[3] = $ret[0] Return $a_keystate EndFunc ;==>_GetKeyState SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
jftuga Posted June 1, 2005 Author Share Posted June 1, 2005 (edited) gafrost,Thanks. I could not have figured that out on my own!How does someone go about learning about DllCall and user32.dll, (or other dlls) etc?EDIT:I just tried both versions of the code and got nothing back for the return values. I tried 3.1.1.38 and the .41 betas.Any ideas?-John Edited June 1, 2005 by jftuga Admin_Popup, show computer info or launch shellRemote Manager, facilitates connecting to RDP / VNCProc_Watch, reprioritize cpu intensive processesUDF: _ini_to_dict, transforms ini file entries into variablesUDF: monitor_resolutions, returns resolutions of multiple monitorsReport Computer Problem, for your IT help deskProfile Fixer, fixes a 'missing' AD user profile Link to comment Share on other sites More sharing options...
GaryFrost Posted June 1, 2005 Share Posted June 1, 2005 (edited) Do you use SciTe Editor? If not change the ConsoleWrite to MsgBox statements for example: $KeyStates = _GetKeyState() For $i = 1 to $KeyStates[0] MsgBox(0,"Key State",$KeyStates[$i]) Next Func _GetKeyState() Const $VK_NUMLOCK = 0x90 Const $VK_SCROLL = 0x91 Const $VK_CAPITAL = 0x14 Local $ret, $a_keystate[4] $a_keystate[0] = 3 $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_NUMLOCK) $a_keystate[1] = $ret[0] $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_SCROLL) $a_keystate[2] = $ret[0] $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_CAPITAL) $a_keystate[3] = $ret[0] Return $a_keystate EndFunc ;==>_GetKeyState Edited June 1, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
jftuga Posted June 1, 2005 Author Share Posted June 1, 2005 I tried this already (MsgBox). The problem is the $ret returns nothing. It does not even return a 0 or a 1. The MsgBox output is empty. -John Admin_Popup, show computer info or launch shellRemote Manager, facilitates connecting to RDP / VNCProc_Watch, reprioritize cpu intensive processesUDF: _ini_to_dict, transforms ini file entries into variablesUDF: monitor_resolutions, returns resolutions of multiple monitorsReport Computer Problem, for your IT help deskProfile Fixer, fixes a 'missing' AD user profile Link to comment Share on other sites More sharing options...
GaryFrost Posted June 1, 2005 Share Posted June 1, 2005 (edited) using the loop with consolewrite and using the release version of autoit>Running: (3.1.1.1):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\Gary\My Documents\test5.au3" 100>AutoIT3.exe ended.>Exit code: 0 Time: 1.077Also running WinXp SP2Info from MSDNFunction InformationMinimum DLL Version user32.dll Header Declared in Winuser.h, include Windows.h Import library User32.lib Minimum operating systems Windows 95, Windows NT 3.1you say $ret isn't returning anything, if you just $ret instead of $ret[0] then you would be correct. Edited June 1, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Vinzent Posted April 7, 2014 Share Posted April 7, 2014 for my self i prefer this code: Global Const $VK_NUMLOCK = 0x90 Global Const $VK_SCROLL = 0x91 Global Const $VK_CAPITAL = 0x14 Func _LockKeyGetState($KeyHex) Local $ret $ret = DllCall("user32.dll","long","GetKeyState","long",$KeyHex) Return $ret[0] EndFunc e. g. numlock: _LockKeyGetState($VK_NUMLOCK) or _LockKeyGetState(0x90) It will return 1 if activated and 0 if not conmed 1 Link to comment Share on other sites More sharing options...
iamtheky Posted April 7, 2014 Share Posted April 7, 2014 almost 9 years old, it is not record setting but still... ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 7, 2014 Moderators Share Posted April 7, 2014 Vinzent,Welcome to the AutoIt forum. Please do not necro-post like this again. We discourage it because Autoit has changed so much since this thread was started that the old code seldom runs any more. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts