da_jokker Posted April 17, 2006 Share Posted April 17, 2006 This is killing me. I've spent days trying both with AutoIt as well as API calls in Visual Basic to just simply click on an icon in the systray. Nothing seems to work all the time. I either need to double click on the icon to open up the program so I can then click the shutdown option. or I need to send a single click to the button while the form is minimized in the Systray. At this point, I'll take either! Anyone can point me in the general direction I'd appriciate it. I've run out of ideas. Note: The icon in the systray is showing up as a Process and not an application however I've been able to use API calls and AutoIt to get the Process ID and then convert it to the windows Hwnd. But then all the ShowWindow, click window, pull my hair out window doesn't work. Thanks Link to comment Share on other sites More sharing options...
Micha1405 Posted April 17, 2006 Share Posted April 17, 2006 (edited) I think this will help you to start (use Beta): ;==>Start #include <guiconstants.au3> #include <constants.au3> ; Opt ("TrayAutoPause", 0) Opt ("TrayMenuMode", 1) Opt("GUICloseOnESC", 0) opt("TrayAutoPause",0) $appTitel="My Window" ; ; $guiApp = GUICreate( $appTitel, 200, 200) GUISetState() $appState = @SW_SHOW ; ; Do $guiMsg = GUIGetMsg() $trayMsg = TrayGetMsg() if Not WinActive($appTitel) And $appState = @SW_SHOW Then ;lost focus minimize window _ToggleAppState() EndIf Select case $trayMsg = $TRAY_EVENT_PRIMARYDOWN _ToggleAppState() ;Case other function from gui EndSelect ; until $guiMsg = $GUI_EVENT_CLOSE ; ; User defined function minimize and restore the gui Func _ToggleAppState() if $appState = @SW_HIDE then $appState = @SW_SHOW GUISetState(@SW_SHOW, $guiApp) Else $appState = @SW_HIDE GUISetState(@SW_HIDE, $guiApp) EndIf EndFunc Edited April 17, 2006 by Micha1405 My TrayToolBar Link to comment Share on other sites More sharing options...
Zedna Posted April 17, 2006 Share Posted April 17, 2006 Look at this: SysTray_UDFand you may also need Winspector if you want to send direct messages.And in your example code is wrong idea that you could directly click on Control of hidden window.If app is in systray this window may be destoyed (and not only hiden) and is created only after tray click. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
CyberSlug Posted April 17, 2006 Share Posted April 17, 2006 Possible workarounds:ProcessClose(...)Somtimes running the program again opens the window. For example, this method works with MSN Messenger to show its window so you can then use WinMenuSelectItem to sign off or close. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Richard Robertson Posted April 18, 2006 Share Posted April 18, 2006 Some programs only run as an icon in the System Tray. I have actually written some such programs. Trying to find an arbitrary icon from the System Tray is most likely not a simple task. Good luck if you can figure something out. Direct Window messages might work. Link to comment Share on other sites More sharing options...
da_jokker Posted April 18, 2006 Author Share Posted April 18, 2006 Thanks everyone. That information is def worth me keeping for future use. Luckily, I was able to make my code work. Turns out that the guy who wrote the systray program had 3 different hidden forms and I was trying to interact with the wrong form. I found a program that uses Windows Enumeration to list all objects that currently exists along with their class info and such. Working my way down the tree I found the form that I needed and was able to (luckily) use the "TEXT" field to distinguish it from the other forms with the same class name. Works great now. But the code and notes above sound like the way to go for the proper SysTray handling. This is just a down and dirty quick script for a couple of months until they get the programmer to make some changes. Thanks again for your attention and time. -B 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