MarioFernando Posted June 19, 2009 Posted June 19, 2009 anybody know a script to check whwther the numlock is on! if its on then turn it off by {numlock off} i dont know how to check it whether its on or not
oMBRa Posted June 19, 2009 Posted June 19, 2009 try this: #include <WinAPI.au3> $Toggle = _WinAPI_GetAsyncKeyState(20) If $Toggle Then MsgBox(0, '', 'CapsLock On') Else MsgBox(0, '', 'CapsLock Off') EndIf
MarioFernando Posted July 3, 2009 Author Posted July 3, 2009 try this: #include <WinAPI.au3> $Toggle = _WinAPI_GetAsyncKeyState(20) If $Toggle Then MsgBox(0, '', 'CapsLock On') Else MsgBox(0, '', 'CapsLock Off') EndIf dosnt work :-(
PhilZ Posted August 14, 2009 Posted August 14, 2009 Why not just send the {CAPSLOCK off}? The result's the same.
GEOSoft Posted August 14, 2009 Posted August 14, 2009 (edited) PhilZ's solution will not work. He seems to have missed the fact that its NUMLOCK you are working with and not CAPSLOCK. Change the provided code to the key you want and try again. And you don't have to bother checking the state. Just set it to off regardless of what it is to begin with. Edited August 14, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Yashied Posted August 14, 2009 Posted August 14, 2009 (edited) For CapsLock key.#Include <WinAPIEx.au3> _SetCapsLockState(Not _GetCapsLockState()) Sleep(1000) _SetCapsLockState(Not _GetCapsLockState()) Func _GetCapsLockState() Return BitAND(_WinAPI_GetKeyState(0x14), 1) = 1 EndFunc ;==>_GetCapsLockState Func _SetCapsLockState($iState) If BitXOR($iState, _GetCapsLockState()) Then _WinAPI_keybd_event(0x14, 0) _WinAPI_keybd_event(0x14, 2) EndIf EndFunc ;==>_SetCapsLockStateWinAPIEx.au3 Edited August 14, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
DW1 Posted August 14, 2009 Posted August 14, 2009 (edited) Post #2 was close but there is a difference between the GetAsyncKeyState and GetKeyState. This should work fine: IF _WinAPI_GetKeyState(0x90) Then MsgBox(0, "Numlock test", "on") Else MsgBox(0, "Numlock test", "off") EndIf Func _WinAPI_GetKeyState($iKey) Local $aResult $aResult = DllCall("User32.dll", "int", "GetKeyState", "int", $iKey) If @error Then Return SetError(@error, 0, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetKeyState Edited August 14, 2009 by danwilli AutoIt3 Online Help
GEOSoft Posted August 14, 2009 Posted August 14, 2009 @Yashied How many times do I have to point out that the OP stated NUMLOCK not CAPSLOCK? a simple Send("{NUMLOCK off}") does what he wants with no need to even check the current state. If it's already off then it will stay that way. If there is a need for checking then he can use your code but he needs the keycode for NUMLOCK which IIRC is 0x90 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Yashied Posted August 14, 2009 Posted August 14, 2009 @YashiedHow many times do I have to point out that the OP stated NUMLOCK not CAPSLOCK?a simpleSend("{NUMLOCK off}") does what he wants with no need to even check the current state. If it's already off then it will stay that way.If there is a need for checking then he can use your code but he needs the keycode for NUMLOCK which IIRC is 0x90Just talk touched CapsLock. I try Send(), and that does not work for me. So I showed this code. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
GEOSoft Posted August 14, 2009 Posted August 14, 2009 (edited) Just talk touched CapsLock. I try Send(), and that does not work for me. So I showed this code.Read my reply again, amd again and again...You will notice that there is definitly something different between what the OP asked for and what you gave him. FORGET capslock. It's not part of the question. Edited August 14, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Yashied Posted August 14, 2009 Posted August 14, 2009 (edited) OK. I am not going to "inflate" this topic. You want that I deleted my example? Edited August 14, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
GEOSoft Posted August 14, 2009 Posted August 14, 2009 (edited) OK. I am not going to "inflate" this topic. You want that I deleted my example? No I don't. What you still (apparently) didn't notice is you gave him the correct code for the Capslock key and he asked about the NumLock key. Since I have errors when including your WinAPIEx.au3 file (duplicate function) I just took your excellent _WinAPI_GetKeyState() function and copied it into this sample code which does what he asked with checking. $VKey = 0x90 $sState = _WinAPI_GetKeyState($VKey) Send("{NUMLOCK off}") MsgBox(0, "Result", $sState) Sleep(2000) If $sState Then Send("{NUMLOCK on}") Func _WinAPI_GetKeyState($vkCode) Local $Ret = DllCall('user32.dll', 'int', 'GetKeyState', 'int', $vkCode) If @error Then Return SetError(1, 0, 0) EndIf Return $Ret[0] EndFunc ;==>_WinAPI_GetKeyState danwilli got it right. EDIT: Spelling Edited August 14, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
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