Sign in to follow this  
Followers 0
sulfurious

how to get the tray handle

26 posts in this topic

#1 ·  Posted (edited)

I posted my original question in the graphical forum.. http://www.autoitscript.com/forum/index.php?showtopic=62801

Now I think it is possibly not a graphical question.

How does one trigger the tray? Not a button in the tray, or a menu in the tray, but the tray itself. Just like the windows key opens menu's and submenu's, I wish to do that with the autoit tray menu. However, I have been looking and find plenty of manipulations for buttons and objects OF the tray menu, but not the tray menu itself.

TraySetState() has nothing to 'pop up' the tray. Something along the lines of GUICtrlSetState('tray handle',$GUI_Show) would be sort of what I envision, but I cannot find the 'handle' of the tray menu to try anything on.

EDIT: I should state that I am using OnEvent mode, and that I do not wish to trigger anything in the tray menu, just display the tray menu so I can navigate it with the keyboard. I have been using a hotkey to trigger the tray menu pop up, but no luck yet...

Is this possible?

Believe me, I have plenty of posts bookmarked, but have found nothing to solve this.

Any suggestions?

Thanks.

Sul.

Edited by sulfurious

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If you just want to hide and show

Opt("TrayIconHide",1)
Sleep(2000)
Opt("TrayIconHide",0)
Sleep(2000)
Edited by Thatsgreat2345

Share this post


Link to post
Share on other sites

Hi,

Try the SysTray_UDF, i think it can help you.


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

If you just want to hide and show

I think he need to show the main menu of the tray icon, just like when you cllick on the icon :D

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

I think he need to show the main menu of the tray icon, just like when you cllick on the icon :P

I seem to have accidentally answered your initial post... Don't know if my suggestion helps but be sure to check it out :D


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Yes, I have been playing with the systray udf. However, it seems to hide/show the icon, not actually 'pop up' the tray menu. It can be called to move the mouse to the tray icon, then you can invoke say a mouse click at that x,y postition, which does spawn the tray menu.

While I am not completely opposed to doing it that way, it seems there should be a way to do it in code. Maybe not though.

And yes MsCreatoR, you are correct, I don't need to hide the icon or anything of that nature. Matter of fact, I don't need to manipulate anything within the tray menu, I can do that already. Just show it through code, preferably without the mouse action going on.

Like I say though, that may be the only way to achieve it.

Thanks for the input so far though. Appreciate it.

SadBunny -- that is an interesting approach. It does work to a degree, except you can never be certain how many tabs to move over. Moreover, if you have a toolbar on the taskbar, as I do, it seems to always want to open it when it tabs to it, and does not like to proceed to the next item. In that instance it also pops it open and then drops it away just as quick, spawning the send() action with a hotkey anyway. But thanks for the reply. I might try to work somethign off that idea. I wonder though what ramifications it would have to many open windows, perhaps shifting thier layering or something when not wanted. Thanks again.

Sul.

Share this post


Link to post
Share on other sites

SadBunny -- that is an interesting approach. It does work to a degree, except you can never be certain how many tabs to move over. Moreover, if you have a toolbar on the taskbar, as I do, it seems to always want to open it when it tabs to it, and does not like to proceed to the next item. In that instance it also pops it open and then drops it away just as quick, spawning the send() action with a hotkey anyway. But thanks for the reply. I might try to work somethign off that idea. I wonder though what ramifications it would have to many open windows, perhaps shifting thier layering or something when not wanted. Thanks again.

It shouldn't do anything to the opened windows... You'd just be TABbing through them like you tab through everything else in windows. Since it doesn't activate or de-activate any windows it shouldn't change anything.

Maybe just experiment manually with ctrl+esc and tab - you'll know fast enough :D


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Hey, how about this?

Send("^{ESC}{ESC}+{TAB}{TAB}")

It doesn't tab through quicklaunch or app, but shift+tab twice to tab backwards, going from start button > nothing > systray. It should avoid open apps, toolbars, quicklaunch and the like. Though I'm not sure about the toolbar. But I presume, tab-wise it's between start menu and systray? (So this new procedure doesn't come across it while the old one probably would.)

It's the same quick and dirty approach but it should be less dependant on rest of taskbar layout?

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Hmm. I am learning some new stuff it would appear. By manually triggering your dirtly little method :D , I can get it to land on where I want. Next, I am using the systray udf / example to find the icon to stop on. Here is what a compiled script has as a title

#0Title: AutoIt v3, process: AutoIt3Wrapper.exe

And here is another compiled script running (that is 2 icons in tray, one for each compiled script)

#1Title: AutoIt v3, process: AutoIt3Wrapper.exe

Which, I suppose if I only had 1 compiled script running, I could search for that and then find the index and know how many to tab to. However, unless I have missed the way to declare what the process is called, I don't know what to do for logic on it now.

Perhaps I could search on a tooltip using systray udf.

It sure seems there would be a handle one could get to the tray itself though.

Keep em coming, learning new stuff here.

Thanks again.

Sul.

Share this post


Link to post
Share on other sites

Hmm. I am learning some new stuff it would appear. By manually triggering your dirtly little method :D , I can get it to land on where I want. Next, I am using the systray udf / example to find the icon to stop on. Here is what a compiled script has as a title

And here is another compiled script running (that is 2 icons in tray, one for each compiled script)

Which, I suppose if I only had 1 compiled script running, I could search for that and then find the index and know how many to tab to. However, unless I have missed the way to declare what the process is called, I don't know what to do for logic on it now.

Perhaps I could search on a tooltip using systray udf.

It sure seems there would be a handle one could get to the tray itself though.

Keep em coming, learning new stuff here.

Thanks again.

Sul.

Don't know any more... :P

Too late here, calling it a day at 23:30... Hope you find out anything!


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

How does one trigger the tray...menu [to open?]

MsCreatoR pointed you in the right direction when he gave you the link to the UDF:

You just use taupe's function, add a couple of pixels to the (x, y) result, and use MouseClick to right-click at those coord's:

;===============================================================================
;
; Function Name:    _SysTrayIconPos($iIndex=0)
; Description:    Gets x & y position of systray icon
; Parameter(s):  $iIndex = icon index (Note: starting from 0)
;                   
; Requirement(s):   AutoIt3 Beta
; Return Value(s):  On Success - Returns x [0] and y [1] position of icon
;                  On Failure - Returns -1 if icon is hidden (Autohide on XP etc.)
;                                Sets error to 1 if some internal error happens
;                                
; Author(s):        Tuape
;
;===============================================================================
Edited by Squirrely1

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

MsCreatoR pointed you in the right direction when he gave you the link to the UDF:

You just use taupe's function, add a couple of pixels to the (x, y) result, and use MouseClick to right-click at those coord's:

Yes, thank you. I have that working by using the mouse. However, that may work, but it is not the most elegant way to do this. I have used mouse movements in some projects, but try to steer clear of anything that rips the mouse from my hand. I suppose just preference.

SadBunny's method does have some merit in regards to being invisible and not taking away the mouse from user control.

Here is what is supposed to work from the systray udf

For $u = 0 To _SystrayIconCount ()
    ConsoleWrite(@CR & "#" & $u & ' : ' & _SysTrayIconTooltip($u)  & ' --> ' & _SysTrayIconIndex(_SysTrayIconTooltip($u),2))
Next

Let us say that the compiled script is called script.exe. I can find the PID = AutoIt v3.exe. I can however find the script.exe in the tooltip variable, so I have a target to search for. Now I search for the index, which I am to assume is where it is located in the tray. Once I find that I could use a method to TAB to it as SadBunny suggests. However, the snippet returns always index of -1, which is being declared as

; Return Value(s): On Success - Returns index of found icon

; On Failure - Returns -1 if icon for given process/wintitle

; was not found.

; - Sets error to 1 and returns -1 in case of bad

; arguments

So, I am unsure of what is going wrong. According to function descriptions, this should work, or maybe I am not correct.

Thank you for your reply.

Sul.

Edited by sulfurious

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

So here we have in interesting find. If I use systray udf, I can find the count of all tray icons. Next I wish to show the process names, using the systray example like this

; -- Example 1 --
; Get window titles of all windows that have icon on systray
$iTitles = _SysTrayIconTitles ()
; Get process names of all processes that have icon on systray
$iProcesses = _SysTrayIconProcesses ()
For $i = 0 To UBound($iTitles) - 1
 ; write the info to consolewindow
   ConsoleWrite(@CR & "#" & $i & "Title: " & $iTitles[$i] & ", process: " & $iProcesses[$i])
Next

This returns the processes OK. But not a compiled autoit script. What is returned, again, is #0Title: AutoIt v3, process: AutoIt3Wrapper.exe.

This short circuits using the _SysTrayIconIndex($name, $mode=0), where $name can be a 'process name / window title text' and $mode can be 0=process name, 1=window title or 2=tooltip

It is interesting that if you even hard code in the 'tooltip' text, the iconindex always returns -1.

It is highly likely that I am not doing this correctly. Here is my test code, obviously change the compiled .exe name (tooltip text) to match a test exe.

For $u = 0 To _SystrayIconCount ()
    ConsoleWrite(@CR & "#" & $u & ' : ' & _SysTrayIconTooltip($u)  & ' --> ' & _SysTrayIconIndex("sg-menu.exe",2))
Next
;~ Exit
; -- Example 1 --
; Get window titles of all windows that have icon on systray
$iTitles = _SysTrayIconTitles ()
; Get process names of all processes that have icon on systray
$iProcesses = _SysTrayIconProcesses ()
For $i = 0 To UBound($iTitles) - 1
 ; write the info to consolewindow
   ConsoleWrite(@CR & "#" & $i & "Title: " & $iTitles[$i] & ", process: " & $iProcesses[$i])
Next
Exit

Thanks for any help.

Sul.

EDIT: as a matter of fact, using the example script for systray udf, changing the example processes (bittorrent.exe and feedreader.exe) to my compiled script name (both case sensitive and not), caused the icon index not to work at all unless the compiled script resided at the first slot. If you load up a compiled script, and then start another app that has a tray icon, the default seems to go to the left most icon. Very intersting that the iconindex funtion, while working on a normal app with name=tooltip text and mode=2, does not work an autoit compiled script. Hmm.

Edited by sulfurious

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

SadBunny's method does have some merit in regards to being invisible and not taking away the mouse from user control.

The experimental methods of going about getting the tray menu to open seem very interesting. For me, I am old and life is too short. This takes only 86 milliseconds out of my life:

$x = TimerInit()
MouseClick("right", 931, 752, 1, 0)
MsgBox(0,"",TimerDiff($x));returns "86" milliseconds

Be sure to backup the mouse cursor position, because I found out that MouseClick does not, in this case at least, move the mouse cursor back to where he got it - an additional 90 milliseconds out of my life - gone forever.

Edited by Squirrely1

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

The other way you are going about getting the tray menu to open seem very interesting. For me, I am old and life is too short. This takes only 86 milliseconds out of my life:

lol, very true, tis the long way around. I just can't stand not knowing though.

Sul.

Share this post


Link to post
Share on other sites

The other way you are going about getting the tray menu to open seem very interesting. For me, I am old and life is too short. This takes only 86 milliseconds out of my life:

$x = TimerInit()
MouseClick("right", 931, 752, 1, 0)
MsgBox(0,"",TimerDiff($x));returns "86" milliseconds
It won't be in the same position every time.... I know your trying to help and all but if you are going to post something thats just a send, or a mouseclick that isn't all to useful don't post.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

It won't be in the same position every time.... I know your trying to help and all but if you are going to post something thats just a send, or a mouseclick that isn't all to useful don't post.

My suggestion was not intended as a complete solution. Since MSCreatoR gave the whole solution away on a silver platter, and some people still didn't get it, I was trying to add another clue for people still scratching their heads.

MsCreatoR's technique, which uses taupe's neatly-written wonderful new functions, will reliably and inevitably open those menus every time it's tried, within about a quarter of a second, no matter where in the tray the icon has moved to - Thatsgreat2345.

That said - I do have respect for those pursuing an even quicker and more reliable way to open the tray menu.

Maybe you need some brain food or something, but I'm going to have to refer you directly from here to Verse 2 of the Official Canon of Valik, found below in my signature.

Edited by Squirrely1

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

It's so simple you'll kick yourself...

WinGetHandle("[CLASS:Shell_TrayWnd]")

Using

Opt("WinTitleMatchMode", 4)

or

AutoItSetOption("WinTitleMatchMode", 4)

Share this post


Link to post
Share on other sites

You plainly haven't read much of this thread at all. It is nothing personal, but just so you can be in on the fun too, I hereby refer you to Verse 1 of the Official Canon of Valik, listed below in my signature. :D


Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

You plainly haven't read much of this thread at all. It is nothing personal, but just so you can be in on the fun too, I hereby refer you to Verse 1 of the Official Canon of Valik, listed below in my signature. :D

Thanks for your contribution so far to solving this problem but I think I can take it from here. If I didn't skim over threads I'd spend my whole day reading useless dribble from people like you. The guy was just asking for a good solution, he wasn't happy with yours. It is nothing personal, get over it.

So how about this then...

Opt("WinSearchChildren", 1)

Opt("WinTitleMatchMode", 4)

WinActivate("[CLASS:TrayNotifyWnd]")

Does that do exactly what he wants now?

Share this post


Link to post
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
Sign in to follow this  
Followers 0