derelky Posted March 31, 2015 Share Posted March 31, 2015 (edited) Hello, is it possible to get the state of a checkbox in a system tray menu? its german and i want to check if the status of the "Bereit" button is check or uncheck. Other option is the hanging lamp change to red if unchecked and green when check. So if its possible to get this information its also OK Edited March 31, 2015 by derelky Link to comment Share on other sites More sharing options...
MikahS Posted March 31, 2015 Share Posted March 31, 2015 (edited) Stumbled across this> post by Melba23 on how to right click an icon in the system tray. This will help you get you in the right direction (at least pulling up the menu to check the state). Edited March 31, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
derelky Posted March 31, 2015 Author Share Posted March 31, 2015 Hello, yes i found that and it works to open the menu and change the state. But i doesnt find in that post the solution to check the state before change (if already check then dont change) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 31, 2015 Moderators Share Posted March 31, 2015 derelky,junkew seems to think that his UIAutomation UDF might be useful in this situation - but I leave it to you to wade through the thread. 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...
MikahS Posted March 31, 2015 Share Posted March 31, 2015 (edited) I just modified Melba23's post and updated with another function he made (>link). This will return the state to the console instead of the text. It will also allow you to wait till you've gotten the menu pulled up to hit a hotkey to find the item state. expandcollapse popup#include <WindowsConstants.au3> #include <GUIToolbar.au3> #include <WinAPI.au3> #include <GuiMenu.au3> Opt("WinTitleMatchMode", 2) HotKeySet("{ESC}", "ex") ; <<<<< ESCAPE hotkey (will run the Func ex() when escape is keyed on) HotKeySet("{END}", "Quit") ; <<<<<<<< added this to quit out of this script Global $hSysTray_Handle, $iSystray_ButtonNumber Global $sToolTipTitle = "" ; Add the text of your tray icon here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< While 1 WEnd ;put this into function so that you can run anytime with hotkeyset Func ex() $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle) If $iSystray_ButtonNumber = 0 Then MsgBox(16, "Error", "Is the App running?") Exit Else Sleep(250) _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right") Sleep(250) Send("{UP}") ; Move your cursor around on the menu here <<<<<<<<<<<<<<<<<<<<<<<<<<< ConsoleWrite(GetPopUpSelText() & @CRLF) ; This will read the currently selected item <<<<<<<<<<<<<<<<<<<<<<<<<<<< EndIf EndFunc ;==>ex Func Get_Systray_Index($sToolTipTitle) ; Find systray handle $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') If @error Then MsgBox(16, "Error", "System tray not found") Exit EndIf ; Get systray item count Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) If $iSystray_ButCount = 0 Then MsgBox(16, "Error", "No items found in system tray") Exit EndIf ; Look for wanted tooltip For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1 If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) <> 0 Then ExitLoop Next If $iSystray_ButtonNumber = $iSystray_ButCount Then Return 0 ; Not found Else Return $iSystray_ButtonNumber ; Found EndIf EndFunc ;==>Get_Systray_Index Func GetPopUpSelText() Local $aPopUp_List = _WinAPI_EnumWindowsPopup() Local $hWnd = $aPopUp_List[1][0] Local $sClass = $aPopUp_List[1][1] If $sClass = "#32768" Then ; This is a "standard" Windows API popup menu $hMenu = _SendMessage($hWnd, $MN_GETHMENU, 0, 0) If _GUICtrlMenu_IsMenu($hMenu) Then $iCount = _GUICtrlMenu_GetItemCount($hMenu) For $j = 0 To $iCount - 1 If _GUICtrlMenu_GetItemHighlighted($hMenu, $j) Then Return _GUICtrlMenu_GetItemState($hMenu, $j) ;<<<<<<<<<<<< here we change to find the state EndIf Next EndIf EndIf Return "" EndFunc ;==>GetPopUpSelText Func Quit() Exit EndFunc Hopefully that helps you on your journey. Edited March 31, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
derelky Posted March 31, 2015 Author Share Posted March 31, 2015 Thx now i found it. Now the Script works as want. Link to comment Share on other sites More sharing options...
MikahS Posted March 31, 2015 Share Posted March 31, 2015 Glad to hear it. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 31, 2015 Moderators Share Posted March 31, 2015 MikahS,I had forgotten all about that one. 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...
MikahS Posted March 31, 2015 Share Posted March 31, 2015 (edited) Melba23, I had to do some digging but turns out I found some gold. Edited March 31, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ 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