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

Post your working scripts, libraries and tools
User avatar
cyruz
Posts: 243
Joined: 30 Sep 2013, 13:31

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

31 Dec 2013, 15:04

Hi guys,
I tried to fix the incompatibility of Sean's old TrayIcon library with AutoHotkey Unicode 32 and 64 bit.

Looks like it's working but I had some problem with the dwData field of the TBBUTTON structure, that is undocumented. If you find any inconsistency related to the "hWnd", "uID", "nMsg" and "hIcon" variables in the TrayIcon_GetInfo function, please provide some info.

Code: [Select all] [Expand] [Download] (TrayIcon.ahk)GeSHi © Codebox Plus



Some test code:

Code: [Select all] [Download] (Script.ahk)GeSHi © Codebox Plus

test := TrayIcon_GetInfo()
Loop, % test.MaxIndex()
str .= test[A_Index].place " - " test[A_Index].idx " - " test[A_Index].process " - " test[A_Index].hwnd " - " test[A_Index].idcmd
MsgBox, %str%


NOTE:
Other users worked on this library. My version is x64 compatible but is ONLY UNICODE, so for an alternative have a look at the following versions:
- Chef's TrayIcon: viewtopic.php?f=6&t=1229&p=9198#p8354
- FanaticGuru's TrayIcon: viewtopic.php?f=6&t=1229&p=9198#p9186
Last edited by cyruz on 15 Jan 2014, 19:29, edited 3 times in total.
ABCza on the old forum.
My GitHub.
FanaticGuru
Posts: 802
Joined: 30 Sep 2013, 22:25

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

31 Dec 2013, 18:28

Below is a link to one of my scripts that uses an updated version of TrayIcon.

Script with Updated TrayIcon

It seems to work for Ansi and Unicode 32 bit but not for Unicode 64 bit.

I also changed it to return results as an object instead of a string with delimiters which it looks like you did also.

TrayIcon is a really useful group of functions. Great job updating it for Unicode 64 bit.

I am going to play around with your TrayIcon and see if I can use it in place of my version.

Too bad you did not do this sooner. It took me forever to get a working version of TrayIcon!

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

Google Search, Dictionary, Thesaurus - Quickly Get Information from Specific Web Resources

[Function] Timer - Create and Manage Timers
User avatar
cyruz
Posts: 243
Joined: 30 Sep 2013, 13:31

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

31 Dec 2013, 19:38

FanaticGuru wrote:Below is a link to one of my scripts that uses an updated version of TrayIcon.

Script with Updated TrayIcon

It seems to work for Ansi and Unicode 32 bit but not for Unicode 64 bit.

I also changed it to return results as an object instead of a string with delimiters which it looks like you did also.

TrayIcon is a really useful group of functions. Great job updating it for Unicode 64 bit.

I am going to play around with your TrayIcon and see if I can use it in place of my version.

Too bad you did not do this sooner. It took me forever to get a working version of TrayIcon!

FG


Yeah I worked on it because I need in one of my script too... Really a nice piece of code.
ABCza on the old forum.
My GitHub.
User avatar
Chef
Posts: 50
Joined: 14 Nov 2013, 13:01

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

01 Jan 2014, 05:05

Worked on this too, I think some functions could be better tweaked to work with handles instead of index.
here is my version...

User avatar
PuzzledGreatly
Posts: 608
Joined: 29 Sep 2013, 22:18

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

14 Jan 2014, 19:48

cyruz wrote:Hi guys,
I tried to fix the incompatibility of Sean's old TrayIcon library with AutoHotkey Unicode 32 and 64 bit.


Can you give an example of how to get some information using this script, please. I'm using Windows 7, 64 bit and tried:

Code: [Select all] [Download] GeSHi © Codebox Plus

    test := TrayIcon_GetInfo()
msgbox %test%

But nothing was displayed in the msgbox
User avatar
Chef
Posts: 50
Joined: 14 Nov 2013, 13:01

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

15 Jan 2014, 03:20

That's because info is being stored in an array, you can't messageBox it like that, you need a for loop.
Look at my code above.
User avatar
cyruz
Posts: 243
Joined: 30 Sep 2013, 13:31

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

15 Jan 2014, 06:35

PuzzledGreatly wrote:
cyruz wrote:Hi guys,
I tried to fix the incompatibility of Sean's old TrayIcon library with AutoHotkey Unicode 32 and 64 bit.


Can you give an example of how to get some information using this script, please. I'm using Windows 7, 64 bit and tried:

Code: [Select all] [Download] GeSHi © Codebox Plus

    test := TrayIcon_GetInfo()
msgbox %test%

But nothing was displayed in the msgbox


As Chef already said, you should loop the array, because the function returns an array of objects:

Code: [Select all] [Download] (Script.ahk)GeSHi © Codebox Plus

test := TrayIcon_GetInfo()
Loop % test.MaxIndex()
MsgBox, % test[A_Index].process


You can extract all the other properties. Just look at the function description.
ABCza on the old forum.
My GitHub.
FanaticGuru
Posts: 802
Joined: 30 Sep 2013, 22:25

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

15 Jan 2014, 14:49

I merged my version of an update to Sean's TrayIcon with Cyruz's update to 64 bit. My version did not work for Unicode64 and Cyruz did a great job on commenting.

The main additions to Cyruz's work is:
  • handling of the NotifyIconOverflowWindow in addition to the Shell_TrayWnd
  • addition of TrayIcon_Remove updated to handle Ansi, Unicode32, Unicode64 versions of AHK
  • functions restore DetectHiddenWindows state to its original settings before returning
  • some superficial changes in coding style and naming conventions
  • included some example code showing usage of TrayIcon_GetInfo
  • addition of TrayIcon_Button to simulate mouse button clicks of Tray Icons
  • updated 2016/01/20 to fix some data type issues that were effecting IDcmd
  • updated 2016/03/08 to handle Windows 10 NotifyIconOverflowWindow better

Code: [Select all] [Expand] [Download] (TrayIcon.ahk)GeSHi © Codebox Plus


FG
Last edited by FanaticGuru on 14 Apr 2016, 15:30, edited 6 times in total.
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

Google Search, Dictionary, Thesaurus - Quickly Get Information from Specific Web Resources

[Function] Timer - Create and Manage Timers
HomePlayer
Posts: 7
Joined: 09 Jan 2014, 08:01

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

15 Jan 2014, 17:48

Hey,

would you pls describe what it is does?
User avatar
cyruz
Posts: 243
Joined: 30 Sep 2013, 13:31

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

15 Jan 2014, 19:22

FanaticGuru wrote:I merged my version of an update to Sean's TrayIcon with Cyruz's update to 64 bit...


Thank you FanaticGuru. I merged some of your modifications in my code. I will reference your post in the OP.
ABCza on the old forum.
My GitHub.
User avatar
cyruz
Posts: 243
Joined: 30 Sep 2013, 13:31

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

15 Jan 2014, 19:24

HomePlayer wrote:Hey,

would you pls describe what it is does?


There is a description for every function in the code :)
It's a library to deal with tray icons (get info, move, delete, hide).
Last edited by cyruz on 15 Jan 2014, 20:29, edited 1 time in total.
ABCza on the old forum.
My GitHub.
User avatar
PuzzledGreatly
Posts: 608
Joined: 29 Sep 2013, 22:18

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

15 Jan 2014, 19:59

Thanks for the updated version. I follow about the array but still can't simulate a right-click. For an example I tried uncommenting the example and ended up with this:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



I'm seeing the msgbox populated as expected but no right-click. I've tried various combinations with PostMessage without success. How to make it work?
User avatar
cyruz
Posts: 243
Joined: 30 Sep 2013, 13:31

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

15 Jan 2014, 20:38

PuzzledGreatly wrote:Thanks for the updated version. I follow about the array but still can't simulate a right-click. For an example I tried uncommenting the example and ended up with this:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



I'm seeing the msgbox populated as expected but no right-click. I've tried various combinations with PostMessage without success. How to make it work?


I didn't know about the possibility to simulate a right click with this library, that seems the example FanaticGuru provided in his code. You cannot pass %hWnd% to the PostMessage without initializing the variable first... In the for loop you need something like:

Code: [Select all] [Download] (Script.ahk)GeSHi © Codebox Plus

hWnd := element.hWnd

Anyway I suggest that you read the array documentation. You will need it to work with this library.
ABCza on the old forum.
My GitHub.
User avatar
PuzzledGreatly
Posts: 608
Joined: 29 Sep 2013, 22:18

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

15 Jan 2014, 22:00

cyruz wrote:
I didn't know about the possibility to simulate a right click with this library, that seems the example FanaticGuru provided in his code. You cannot pass %hWnd% to the PostMessage without initializing the variable first... In the for loop you need something like:

Code: [Select all] [Download] (Script.ahk)GeSHi © Codebox Plus

hWnd := element.hWnd

Anyway I suggest that you read the array documentation. You will need it to work with this library.


Arh! Yes, I see. Thanks for pointing that out.
FanaticGuru
Posts: 802
Joined: 30 Sep 2013, 22:25

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

16 Jan 2014, 16:29

PuzzledGreatly wrote:Thanks for the updated version. I follow about the array but still can't simulate a right-click. For an example I tried uncommenting the example and ended up with this:


I made a function for tray icon mouse button clicking that should make it easier for you.

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus



FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

Google Search, Dictionary, Thesaurus - Quickly Get Information from Specific Web Resources

[Function] Timer - Create and Manage Timers
User avatar
PuzzledGreatly
Posts: 608
Joined: 29 Sep 2013, 22:18

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

16 Jan 2014, 18:53

That's great - thank you very much.
magusneo
Posts: 23
Joined: 30 Sep 2013, 06:34

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

02 Aug 2014, 08:10

Thanks.But it seems there is no TrayIcon can work with SetTrayIcon().
FanaticGuru
Posts: 802
Joined: 30 Sep 2013, 22:25

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

04 Aug 2014, 13:31

magusneo wrote:Thanks.But it seems there is no TrayIcon can work with SetTrayIcon().

As best as I can tell, Sean's TrayIcon Library did not included SetTrayIcon. Even though it has TrayIcon in the name the library was all commands that started with TrayIcon_.

If it was part of the library it should be named TrayIcon_Set. This is more than just schematics as a library must have this naming convention to be used as a library by AHK.

All that aside it would be nice to add TrayIcon_Set. I might look at what it would take to add it but at first glance I am not familiar with everything it is doing and what would need to change to make it work with 64 bit.

Here are the two versions I have:

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus


FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

Google Search, Dictionary, Thesaurus - Quickly Get Information from Specific Web Resources

[Function] Timer - Create and Manage Timers
kidbit
Posts: 168
Joined: 02 Oct 2013, 16:05

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

25 Oct 2014, 13:07

FG, what's the difference between TrayIcon_Remove and TrayIcon_Delete?
Also, what is 'Command identifier associated with the button (cmdID)'?
question := (2b) || !(2b) © Shakespeare.
FanaticGuru
Posts: 802
Joined: 30 Sep 2013, 22:25

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

25 Oct 2014, 23:25

kidbit wrote:FG, what's the difference between TrayIcon_Remove and TrayIcon_Delete?
Also, what is 'Command identifier associated with the button (cmdID)'?


I believe TrayIcon_Remove and TrayIcon_Delete both end up doing the same thing by different means. One uses SendMessage to get it done the other uses a DLL call to get it done.

The main difference to the user is Delete uses the tray index which is prone to changing while Remove uses the uID which tends to be more fixed.

cmdID, as I understand it, has to do with what command will do what to the button. I have never used it but it is part of Windows' structure of a tray icon so it's value is reported by the function.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

Google Search, Dictionary, Thesaurus - Quickly Get Information from Specific Web Resources

[Function] Timer - Create and Manage Timers

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 14 guests