Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Just Want To Click On An Icon In The Systray


  • Please log in to reply
5 replies to this topic

#1 da_jokker

da_jokker

    Seeker

  • New Members
  • 4 posts

Posted 17 April 2006 - 06:15 AM

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







#2 Micha1405

Micha1405

    Adventurer

  • Active Members
  • PipPip
  • 107 posts

Posted 17 April 2006 - 07:53 AM

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, 17 April 2006 - 07:55 AM.


#3 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,785 posts

Posted 17 April 2006 - 11:54 AM

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.

#4 CyberSlug

CyberSlug

    Overwhelmed with work....

  • MVPs
  • 3,587 posts

Posted 17 April 2006 - 12:15 PM

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!

#5 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 10,333 posts

Posted 18 April 2006 - 01:52 AM

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.

#6 da_jokker

da_jokker

    Seeker

  • New Members
  • 4 posts

Posted 18 April 2006 - 01:58 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users