Jump to content

ControlClick on SysTray


syno
 Share

Recommended Posts

Hello All

I am trying to right click on a sys tray icon using the ControlClick control but not able able to find the correct ControlID using the AutoIT v3 Windows Info tool.

The class for all the icons in the sys tray appears to be ToolbarWindow32 and the INSTANCE is always 1. How do I right click the mouse button on a sys tray icon using a control. Do I need to get the handle for the control?

Thanks for your help...

Link to comment
Share on other sites

This topic might help you Edited by BigDod


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Hello All

I am trying to right click on a sys tray icon using the ControlClick control but not able able to find the correct ControlID using the AutoIT v3 Windows Info tool.

The class for all the icons in the sys tray appears to be ToolbarWindow32 and the INSTANCE is always 1. How do I right click the mouse button on a sys tray icon using a control. Do I need to get the handle for the control?

Thanks for your help...

Hi,

have a look at attached au files.

Systray_test.au3 is an example script, systray_udf.au3 the include file.

With function _SysTrayIconPos () you get x/y coordinates of your Tray Icon and then you can click it with MouseMove () and MouseClick ().

Have a look at the Systray_test.au3 and just do a paste and copy of what you need.

;-))

Stefan

P.S: BigDod has had same idea, but the link should be: http://www.autoitscript.com/forum/index.php?showtopic=13704&hl=systray&st=0

Systray_test.au3

SysTray_UDF.au3

Edited by 99ojo
Link to comment
Share on other sites

  • Moderators

There is also a lot of code in this topic which might help you. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 2 weeks later...

That's great, it works with the code that you have provided, i.e

#Include <GuiToolBar.au3>

Global $hSysTray_Handle, $iSystray_ButtonNumber

Global $sToolTipTitle = "" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here

$iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle)

If $iSystray_ButtonNumber = 0 Then
    MsgBox(16, "Error", "Icon not found in system tray")
    Exit
Else
    Sleep(500)
    _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")
EndIf

Exit

;............

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) = 1 Then ExitLoop
    Next

    If $iSystray_ButtonNumber = $iSystray_ButCount Then
        Return 0 ; Not found
    Else
        Return $iSystray_ButtonNumber ; Found
    EndIf

EndFunc

However I want to left click twice the sys tray icon and I have tried replacing:

_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")

with

_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "left", 2)

But it does not work. Any help would be appreciated

Thanks

Link to comment
Share on other sites

  • Moderators

syno,

Try using the correct syntax: :)

_GUICtrlToolbar_ClickButton($hWnd, $iCommandID[, $sButton = "left"[, $fMove = False[, $iClicks = 1[, $iSpeed = 1]]]])

Looks as if you are missing the $fMove parameter! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

syno,

Try using the correct syntax: :)

_GUICtrlToolbar_ClickButton($hWnd, $iCommandID[, $sButton = "left"[, $fMove = False[, $iClicks = 1[, $iSpeed = 1]]]])

Looks as if you are missing the $fMove parameter! :)

M23

Thanks Melba32

I chose the following:

$fMove = False, $iClicks = 2

And it works!!!

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