[LIB] TrayIcon - Sean's TrayIcon for Unicode and 64 bit

Post your working scripts, libraries and tools
User avatar
JoeWinograd
Posts: 1315
Joined: 10 Feb 2014, 20:00

Re: [LIB] TrayIcon - Sean's TrayIcon for Unicode and 64 bit

20 Feb 2019, 09:41

First, I'd like to thank Sean, Cyruz, and FG for this superb library! It has been essential in the development of my latest program. I'm using the version with a Version Date of 2018-03-13 (my first attempt at this post included the library's URL, but that caused the post to be blocked by our new anti-spam methods).

My current effort is to make sure that my program is usable by the visually impaired. For this, they need to be able to right-click on an icon in the tray (without being able to see it, of course). I have set up several hotkeys (because there may be several instances of my program running at once, each with a different color icon in the tray) and a call to TrayIcon_Button with the "R" param is working perfectly. The only small problem, which isn't an issue for the visually impaired, but could be for the sighted who also use the feature, is that the context menu appears wherever the mouse cursor is when TrayIcon_Button is called. Is there any way to determine the X-Y coordinates of a tray icon so that I can do a MouseMove there before calling TrayIcon_Button? If not, is there a way to determine the X-Y coordinates of the upper left corner of the notification area (not of the whole taskbar)? Thanks very much, Joe

Edit: Btw, I had been wondering if "L" and "R" actually mean Left Click and Right Click, or if they really mean Primary Click and Secondary Click. In other words, if the left and right mouse buttons are swapped (often done by left-handed users), will the "R" param send a Right Click, which in this case would be a Primary Click, or a Left Click, which in this case would be a Secondary Click? I ran a test and found that the answer is the latter, i.e., the "R" param sends a Secondary Click, which is actually a Left Click when the left and right mouse buttons are swapped. In my opinion, this is great...exactly the behavior I want! My only suggestion is to document that in the comments at the function. I hope my experiment helps other users of this library.
User avatar
JoeWinograd
Posts: 1315
Joined: 10 Feb 2014, 20:00

Re: [LIB] TrayIcon - Sean's TrayIcon for Unicode and 64 bit

20 Feb 2019, 16:06

I just tried to edit this question with another "by the way" comment, but it got blocked by our new anti-spam methods. So, I'm trying to post it again via a new post instead of an edit of the first post (I think we're taking extra measures against edits because that's how our current spammer operates...via edits of his own initial posts).

My new BTW comment is to note that I tried ImageSearch to see if it could find the icon (which is in a 48x48 .ICO file that I created), but it always comes up with ErrorLevel=1 (not found). I set the X1,Y1,X2,Y2 params as 0,0,A_ScreenWidth,A_ScreenHeight (i.e., the whole screen) and tried numerous settings for *n *wn *hn — nothing worked. Regards, Joe
User avatar
JoeWinograd
Posts: 1315
Joined: 10 Feb 2014, 20:00

Re: [LIB] TrayIcon - Sean's TrayIcon for Unicode and 64 bit

03 Apr 2019, 09:08

Greetings to Sean, Cyruz, FG and anyone else who can help with this. It is important for the program that I mentioned in previous posts to have the tray icons in Shell_TrayWnd rather than NotifyIconOverflowWindow. I could put a section in the User Guide documenting the steps in Windows to show my program's icon (or show all icons), but it would be much better to have my program automatically put them in Shell_TrayWnd when "Always shows all icons..." is Off. Is there a way to do that? Thanks, Joe
User avatar
jeeswg
Posts: 6828
Joined: 19 Dec 2016, 01:58
Location: UK

Re: [LIB] TrayIcon - Sean's TrayIcon for Unicode and 64 bit

03 Apr 2019, 14:32

- @JoeWinograd: There's some code here for Windows 7 and possibly Windows 8. There were problems in Windows 10.
Is there a way to put an icon outside the hidden tray icons by default? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=58992
- Perhaps Microsoft doesn't want programs to be able to do this. And similarly they don't want programs to pin themselves to the taskbar. I.e. to prevent spammy software that places itself everywhere.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
JoeWinograd
Posts: 1315
Joined: 10 Feb 2014, 20:00

Re: [LIB] TrayIcon - Sean's TrayIcon for Unicode and 64 bit

03 Apr 2019, 16:15

Hi jeeswg,
Thanks for the link...I'll give it a look, but I'd like my program to work in everything from XP to W10, and it must work in at least W7, W8.1, and W10. Cheers, Joe
User avatar
cyruz
Posts: 295
Joined: 30 Sep 2013, 13:31

Re: [LIB] TrayIcon - Sean's TrayIcon for Unicode and 64 bit

03 Apr 2019, 22:02

Quick update and code merged in the OP.

@jeeswg that's interesting, if you or JoeWinograd come up with a solution for Windows 10 to "unhide" the icons it would be a nice addition.
ABCza on the old forum.
My GitHub.
julesverne
Posts: 13
Joined: 18 Apr 2017, 14:39
GitHub: JulesverneOnGitHub

Re: [LIB] TrayIcon - Sean's TrayIcon for Unicode and 64 bit

16 Jul 2019, 13:13

Was wondering if anyone was able to get this working on Win 10? Version 1709 or higher?
User avatar
JoeWinograd
Posts: 1315
Joined: 10 Feb 2014, 20:00

Re: [LIB] TrayIcon - Sean's TrayIcon for Unicode and 64 bit

16 Jul 2019, 14:32

Was wondering if anyone was able to get this working on Win 10? Version 1709 or higher?
Depends on what you mean by "this". If you mean the library, the answer is YES...it works perfectly on 1803, 1809, and 1903. If you mean being able to programmatically put the icons in Shell_TrayWnd when "Always shows all icons..." is Off, the answer is NO...haven't figured out how to do that...or whether it's even possible. Regards, Joe
julesverne
Posts: 13
Joined: 18 Apr 2017, 14:39
GitHub: JulesverneOnGitHub

Re: [LIB] TrayIcon - Sean's TrayIcon for Unicode and 64 bit

16 Jul 2019, 22:52

Working great now! Thanks @JoeWinograd
michael_jie
Posts: 10
Joined: 26 Nov 2018, 04:44

Re: [LIB] TrayIcon - Sean's TrayIcon for Unicode and 64 bit

08 Oct 2019, 02:52

Thanks for lib. It's awesome.

But when i used TrayIcon_Button, the network connection and sound didn't work, the other worked perfect.
Run as admin didn't work too.

Here is my code:
I used RiseUp's version, and add event in listview. Used hWnd as id.
And changed TrayIcon_GetInfo() If ( !sExeName || sExeName == sProcess || sExeName == nPid || sExeName == hwnd) to let it can gets info by use hwnd

Code: Select all

#NoEnv				
SendMode Input	

Gui Add, ListView, Grid r30 w700 Sort gMyListView, Process|Tooltip|Visible|Handle


oIcons := TrayIcon_GetInfo()
Loop, % oIcons.MaxIndex()
{
    proc := oIcons[A_Index].Process
    ttip := oIcons[A_Index].tooltip
	tray := oIcons[A_Index].Tray
    hWnd := oIcons[A_Index].hWnd
    
	vis := (tray == "Shell_TrayWnd") ? "Yes" : "No"
	
    LV_Add(, proc, ttip, vis, hWnd)
}

LV_ModifyCol()					 
LV_ModifyCol(3, "AutoHdr")          

Gui Show, Center, System Tray Icons
Return

MyListView:
	if A_GuiEvent = DoubleClick
	{
	    LV_GetText(hWnd, A_EventInfo, 4)  
	    TrayIcon_Button(hWnd,"L")
	}
return


GuiEscape:
GuiClose:
    ExitApp
return

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Delta Pythagorean and 29 guests