Jump to content

Close/manage tray item


Dirk98
 Share

Recommended Posts

Guys, I have a software that creates it's own item in the tray. It is not standard Windows type (shows its own menus when clicked on). I need to close it before running anything else in the script.

I also run this software later in the script again and need to select items from the menu that pops up. Can you please give an example of how to manage this.

Many thanks.

Link to comment
Share on other sites

Ok, I've learnt how to manipulate the tray items, but I also need to kill the process, along with the tray item. Could you pls give me a pointer on how to kill a running exe process? Many thanks.

If in it's tray popupmenu is Exit command then invoke it - this is simplest way.

Otherwise you may use ProcessClose()

Link to comment
Share on other sites

If in it's tray popupmenu is Exit command then invoke it - this is simplest way.

Otherwise you may use ProcessClose()

Just to click on GFKeys.exe icon in the tray (required for my task) I have to do all this quoted below. Now, there are 4 commands in the popup menue of GFKeys.exe : "Show Config Panel", "Disable Key Mapping", "Enable Key Mapping", "Quit GFKeys". Any ideas what else to add to the code below to be able to pick different commands from the menu, say: "Enable Key Mapping"?

Many thanks.

#include "SysTray_UDF.au3"

; -- Example 5 --
; Left-click Outlook's icon on system tray

; Press hide inactive icon's button part is from Valik's refresh system tray script!
$oldMatchMode = Opt("WinTitleMatchMode", 4)
$oldChildMode = Opt("WinSearchChildren", 1)

$class = "classname=Shell_TrayWnd"
$hControl = ControlGetHandle($class, "", "Button2")

; get tray position and move there. Helps if Auto Hide tray option is used.
$posTray = WinGetPos(_FindTrayToolbarWindow())
MouseMove($posTray[0], $posTray[1])

$index = _SysTrayIconIndex("GFKeys.exe"); Change this to some other application if needed
If $index <> -1 Then
$pos = _SysTrayIconPos($index)

If $pos = -1 Then
  ; ***** Moved by CatchFish *****
  ; If XP and the Hide Inactive Icons mode is active
    If $hControl <> "" And ControlCommand($class, "", $hControl, "IsVisible","") Then
    ControlClick($class, "", $hControl)
    Sleep(250); Small delay to allow the icons to be drawn
    EndIf
  ; ******************************
    $pos = _SysTrayIconPos($index)
    If $pos = -1 Then Exit; ** A real error this time;)
EndIf

MouseMove($pos[0], $pos[1])
Sleep(1000)
MouseClick("left")
EndIf
ConsoleWrite(@CRLF & @CRLF & "Pos[0]: " & $pos[0] & "$pos[1]: " & $pos[1])
; Restore Opt settings
Opt("WinTitleMatchMode", $oldMatchMode)
Opt("WinSearchChildren", $oldChildMode)
Edited by Dirk98
Link to comment
Share on other sites

Man are you blind? Look at my post #2!

Zedna, unfortunately the script quted on that page does not work here (on my english OS):

#include <A3LMenu.au3>
#include <A3LToolbar.au3>

Opt("WinTitleMatchMode", 4)

$hWnd   = ControlGetHandle("classname=Shell_TrayWnd", "", "Notification Area")
$iCount = _Toolbar_ButtonCount($hwnd)

for $iI = 1 to $iCount
  $iCommand = _Toolbar_IndexToCommand($hWnd, $iI)
  $sText    = _Toolbar_GetButtonText ($hWnd, $iCommand)
  if $sText = "Volume" then
    if ControlGetHandle("classname=Shell_TrayWnd", "", "Button2") <> 0 then
      ControlClick("classname=Shell_TrayWnd", "", "Button2")
    endif
    _Toolbar_ClickButton($hWnd, $iCommand, "right", False, 1, 1, True)
    _Menu_ClickPopupAccel("O")
    ExitLoop
  endif
next

I get Error on line 26:

_Toolbar_ClickButton($hWnd, $iCommand, "right", False, 1, 1, True)

^ERROR

Error: Incorrect number of parameters in function call.

So, I'm stuck on my script since the exemplary one you referred to doesn't work.

Any ideas?

Many thanks.

Edited by Dirk98
Link to comment
Share on other sites

Zedna, unfortunately the script quted on that page does not work here (on my english OS):

#include <A3LMenu.au3>
#include <A3LToolbar.au3>

Opt("WinTitleMatchMode", 4)

$hWnd   = ControlGetHandle("classname=Shell_TrayWnd", "", "Notification Area")
$iCount = _Toolbar_ButtonCount($hwnd)

for $iI = 1 to $iCount
  $iCommand = _Toolbar_IndexToCommand($hWnd, $iI)
  $sText    = _Toolbar_GetButtonText ($hWnd, $iCommand)
  if $sText = "Volume" then
    if ControlGetHandle("classname=Shell_TrayWnd", "", "Button2") <> 0 then
      ControlClick("classname=Shell_TrayWnd", "", "Button2")
    endif
    _Toolbar_ClickButton($hWnd, $iCommand, "right", False, 1, 1, True)
    _Menu_ClickPopupAccel("O")
    ExitLoop
  endif
next

I get Error on line 26:

_Toolbar_ClickButton($hWnd, $iCommand, "right", False, 1, 1, True)

^ERROR

Error: Incorrect number of parameters in function call.

So, I'm stuck on my script since the exemplary one you referred to doesn't work.

Any ideas?

Many thanks.

Last parameter was redundant. Try this:

_Toolbar_ClickButton($hWnd, $iCommand, "right", False, 1, 1)

And search forum AutoIt/Auto3Library helkpfile for more details/examples.

Link to comment
Share on other sites

Last parameter was redundant. Try this:

_Toolbar_ClickButton($hWnd, $iCommand, "right", False, 1, 1)

And search forum AutoIt/Auto3Library helkpfile for more details/examples.

Zedna, you are the saviour, thx man! Would take me 100 years following what you suggested. But I'm trying.

Edited by Dirk98
Link to comment
Share on other sites

But there's a problem in the above script again. If I change "Button2" to "Button1" the script still opens the same Play Control, instead of Sounds and Audio Devices Properties. Which negates any control over selection to make. And that's what I needed originally. If it doesn't work with the native windows' uplets, it won't work in custom ones I guess. Any idea how I can change the selections in the popup menu of the tray in the above example?

Thanks.

Edited by Dirk98
Link to comment
Share on other sites

Zedna, pls, any idea why changing Button2 to Button1 (or any other numbers) in the above scrip doesn't make different selections in the tray popup menu? I need to learn a way how to select different items in the tray icon popup.

Many thanks, sorry for stalking. :)

Link to comment
Share on other sites

Zedna, pls, any idea why changing Button2 to Button1 (or any other numbers) in the above scrip doesn't make different selections in the tray popup menu? I need to learn a way how to select different items in the tray icon popup.

Many thanks, sorry for stalking. :)

I didn't used tray automatize in any of my projects so I don't know details.

Just try to search Auto3Library helpfile and forum for examples which are using these functions.

Link to comment
Share on other sites

I didn't used tray automatize in any of my projects so I don't know details.

Just try to search Auto3Library helpfile and forum for examples which are using these functions.

Thank you, Zedna. I've found some pertinent references in the Auto3Lib Help but too hard to comprehend. I'll ask it again and refined on the forum.

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