oshaker Posted April 19, 2009 Share Posted April 19, 2009 I am looking for a script that shows me the states of CAPS, Num and SCROLL keys states whether on or off in the tray. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 19, 2009 Moderators Share Posted April 19, 2009 oshaker,Where have you looked? A quick search will give you some code to determine the state of the LOCK keys (I know because I have just looked myself ;-)). Then you will need to design some icons (you will, of course, need 8 to cover all possibilities) and use the #AutoIt3Wrapper_Res_Icon_Add directive to load them into your compiled script. Finally, you will need to run a loop to determine the current LOCK state and then display the correct icon using TraySetIcon.Give it a go yourself - we are here if you run into problems.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...
oshaker Posted April 19, 2009 Author Share Posted April 19, 2009 expandcollapse popup#cs ---------------------------------------------------------------------------- A system tray util to indicate the state of the Caps Lock, Num Lock & Scroll Lock Keys by changing the Icon to suit #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Constants.au3> $close = TrayCreateItem ("Exit") ;incase u wanted to close the app Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 1) Global Const $VK_NUMLOCK = 0x90 Global Const $VK_SCROLL = 0x91 Global Const $VK_CAPITAL = 0x14 $Apps="KeyState 1.0" ;~ CHANGE THIS PATH TO SUIT YOUR ENVIRONMENT FileInstall(".\0.ico",@ScriptDir & "\" ) FileInstall(".\1.ico",@ScriptDir & "\" ) FileInstall(".\2.ico",@ScriptDir & "\" ) FileInstall(".\3.ico",@ScriptDir & "\" ) FileInstall(".\4.ico",@ScriptDir & "\" ) FileInstall(".\5.ico",@ScriptDir & "\" ) FileInstall(".\6.ico",@ScriptDir & "\" ) FileInstall(".\7.ico",@ScriptDir & "\" ) main() Func main() While 1 $msg = TrayGetMsg () Select Case $msg = $close Exit EndSelect toggleKeys() sleep(100) WEnd exit EndFunc Func toggleKeys() $keystate=0 If getNumLock() <> 0 then $keystate= $keystate + 1 EndIf If GetScrollLock() <>0 Then $keystate= $keystate + 2 EndIf If GetCapsLock() <>0 Then $keystate= $keystate + 4 EndIf Select Case $keystate = 1 TraySetIcon("1.ico") Case $keystate = 2 TraySetIcon("2.ico") Case $keystate = 3 TraySetIcon("3.ico") Case $keystate = 4 TraySetIcon("4.ico") Case $keystate = 5 TraySetIcon("5.ico") Case $keystate = 6 TraySetIcon("6.ico") Case $keystate = 7 TraySetIcon("7.ico") Case Else TraySetIcon("0.ico") EndSelect EndFunc ;Code from gafrost ==> http://www.autoitscript.com/forum/index.php?showtopic=12056 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 GetCapsLock() Local $ret $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_CAPITAL) Return $ret[0] EndFunc I will try to use #AutoIt3Wrapper_Res_Icon_Add as I need to see if this has to exract icons as with FileInstall Thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 19, 2009 Moderators Share Posted April 19, 2009 oshaker,You need the full SciTE4AutoIt3 intallation to use the #AutoIt3Wrapper_Res_Icon_Add directive. It is much easier to use than FileInstall because you merely need set the TraySetIcon parameters as follows:filename: @ScriptFullPathiconID: -5 for the first added icon, then -6 and so on (this is because the indices are negative ordinals [do not ask me why!] and the first 5 are the standard Autoit icons)No messy writing to file needed - the icons are within the complied .exe! Other than that it looks like you are well on your way.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...
oshaker Posted April 21, 2009 Author Share Posted April 21, 2009 oshaker, You need the full SciTE4AutoIt3 intallation to use the #AutoIt3Wrapper_Res_Icon_Add directive. It is much easier to use than FileInstall because you merely need set the TraySetIcon parameters as follows: filename: @ScriptFullPath iconID: -5 for the first added icon, then -6 and so on (this is because the indices are negative ordinals [do not ask me why!] and the first 5 are the standard Autoit icons) No messy writing to file needed - the icons are within the complied .exe! Other than that it looks like you are well on your way. M23 This is not my script, I could have written one, but icons were something to think about. FileInstall extracts the icons, if you are to distribute your script, you might opt to make it one exe and surprise the user with a bunch of icons Any way, thanks for your advice. Link to comment Share on other sites More sharing options...
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