Jump to content

Just Want To Click On An Icon In The Systray


da_jokker
 Share

Recommended Posts

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

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 by Micha1405
Link to comment
Share on other sites

Look at this: SysTray_UDF

and 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.

Link to comment
Share on other sites

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

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

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...