Jump to content

NumLock toggle


Inverted
 Share

Recommended Posts

I made this for a friend. It sets NumLock On at start of the script and has a 'NumLock toggle' tray option. Tray icon changes indepedently according to the state of NumLock.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Icon_Add="C:STUFFAutoit_stuffNumLockControlon.ico"
#AutoIt3Wrapper_Res_Icon_Add="C:STUFFAutoit_stuffNumLockControloff.ico"
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

;Opt("SendAttachMode", 1)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)
TraySetClick(16)

Send("{NUMLOCK on}")

TrayCreateItem("Toggle NumLock")
TrayItemSetOnEvent(-1, "toggleNumLock")
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "ExitScript")

While 1
updateTrayIcon()
Sleep(100)
WEnd

Func toggleNumLock()
Send("{NUMLOCK toggle}")
EndFunc

Func updateTrayIcon()
$sState = _WinAPI_GetKeyState(0x90)
If $sState Then
TraySetIcon(@ScriptFullPath, -5)
Else
TraySetIcon(@ScriptFullPath, -6)
EndIf

EndFunc

Func ExitScript()
Exit
EndFunc

Func _WinAPI_GetKeyState($vkCode)
Local $Ret = DllCall('user32.dll', 'int', 'GetKeyState', 'int', $vkCode)
Return $Ret[0]
EndFunc

Compiled script exe for convenience :

http://speedy.sh/6sVtN/NumLockControl.zip

It only seems to work fine in win7 x64 but not in my XP virtual machine. I don't know if it's because of Virtualbox keyboard hooking or just XP incompatibility. Pleaselet me know if it works on real XP.

Edited by Inverted
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...