Jump to content

Open Systray Menu


ReverendJ1
 Share

Recommended Posts

Have you looked at the systray udf here.

http://www.autoitscript.com/forum/index.ph...hl=systray++udf

It may (or may not) do what you want

You would need to use the _SysTrayIconPos() functions to find the coordinates of the Systray icon then automate a rightclick into your script against these coordinates.

Ok, this is still 'clicking' the icon but at least it is automated

Edited by rogdog
My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic]
Link to comment
Share on other sites

Example code

CODE
#include <Systray_UDF.au3>

#include <Misc.au3>

Dim $ComboList

$a_Titles = _SysTrayIconTitles()

For $Title_index = 0 to UBound($a_Titles) -1

$pos = _SysTrayIconPos($Title_index)

If UBound($pos) = 2 Then $ComboList &= $Title_index &"_"&$a_Titles[$Title_index] &'|'

Next

$ComboList = StringTrimRight($ComboList,1)

GUICreate("Select Systray Icon to Right Click",320,130)

$Combo = GUICtrlCreateCombo("",10,10,300,20)

GUICtrlSetData(-1,$ComboList)

$Button = GUICtrlCreateButton("Right Click",10,100,100,20)

GUISetState ()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $Button

$p = MouseGetPos()

$Index = StringSplit(GUICtrlRead($Combo),"_")

$pos = _SysTrayIconPos($Index[1])

_MouseTrap ($pos[0]+10, $pos[1]+10, $pos[0]+10, $pos[1]+10)

MouseClick("Right")

_MouseTrap ($p[0], $p[1], $p[0], $p[1])

_MouseTrap ()

EndSelect

Wend

Edited by rogdog
My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic]
Link to comment
Share on other sites

Thank you. That is not as elegant as I was hoping for, but seems to work. I am just having trouble getting the mouse back to the starting position. It worked fine in your script, but after I made a couple changes to click on the AutoIT systray item, it won't move the mouse back until you click something else. It just sort of pauses. Any ideas? Below is my code

#include <Systray.au3>
#include <Misc.au3>
Opt("TrayMenuMode",1)
opt("TrayIconHide", 0)
TrayCreateItem("Tray Test")
GUICreate("Select Systray Icon to Right Click",320,130)
$Button = GUICtrlCreateButton("Right Click",10,100,100,20)
GUISetState ()

While 1
$msg = GUIGetMsg()
Select
    Case $msg = $Button
        ;MsgBox(0,"","")
$p = MouseGetPos()
;$Index = StringSplit(GUICtrlRead($Combo),"_")
$pos = _SysTrayIconPos("AutoITWrapper.exe")
_MouseTrap ($pos[0]+10, $pos[1]+10, $pos[0]+10, $pos[1]+10)
MouseClick("right")
_MouseTrap ($p[0], $p[1], $p[0], $p[1])
_MouseTrap ()
EndSelect
Wend
Edited by ReverendJ1
Link to comment
Share on other sites

Yep, I gues the problem is the script pauses when the right click occurs.

To get around this problem you could use this even less elegant script

CODE
#include <Systray.au3>

#include <Misc.au3>

If StringInStr($cmdlineraw, '/Right') Then

opt("TrayIconHide", 1)

;msgbox(0,"yep","")

$p = MouseGetPos()

$pos = _SysTrayIconPos("AutoITWrapper.exe")

_MouseTrap ($pos[0]+10, $pos[1]+10, $pos[0]+10, $pos[1]+10)

MouseClick("right")

_MouseTrap ($p[0], $p[1], $p[0], $p[1])

_MouseTrap ()

Exit

EndIf

Opt("TrayMenuMode",1)

opt("TrayIconHide", 0)

TrayCreateItem("Tray Test")

GUICreate("Select Systray Icon to Right Click",320,130)

$Button = GUICtrlCreateButton("Right Click",10,100,100,20)

GUISetState ()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $Button

If @Compiled Then

Run(@ScriptFullPath & ' /Right')

Else

Run(@AutoItExe & ' "' & @ScriptFullPath & '" /Right')

EndIf

EndSelect

Wend

My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic]
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...