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

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: [LIB] TrayIcon - Sean's TrayIcon for Unicode and 64 bit

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

Post by cyruz » 28 Mar 2018, 07:49

Looks like this lib is still getting some love :D

I will reference the most updated versions in the OP, because I stopped looking at it while ago!

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

Post by SquirrelHugger » 15 Mar 2018, 10:13

@FanaticGuru thank you for your input. I'll eventually find a way through this somehow :D

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

Post by FanaticGuru » 14 Mar 2018, 13:31

SquirrelHugger wrote:EDIT: well it worked when I tried to double click another tray icon, but not for qbittorrent.exe
Any idea why?
The reason some tray icons work and others do not probably has to do with permissions. Some tray icons are probably running as a higher-privileged process that basically don't want to be messed with by a lower-privileged process. The function uses a PostMessage to tell the program its tray icon has been clicked but PostMessage could be used to control the program in lots of other ways which the program does not want without the right permissions.

It is probably more complicated than just running your script as an administrator. There are probably ways to get around it but I am no expert on User Account Control and User Interface Privilege Isolation. The function is actually pretty simple and small but the code to get around the permissions is probably going to be much more complicated and long.

FG

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

Post by SquirrelHugger » 14 Mar 2018, 05:41

SL5 wrote:
SquirrelHugger wrote:Hey @FanaticGuru ...

Code: [Select all]GeSHi © Codebox Plus

TrayIcon_Button( "qbittorrent.exe" )

But it did not work. ...


hi and sorry. :) how you did that? to me the follwiing has no effect:

Code: [Select all]GeSHi © Codebox Plus

#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.

#Include TrayIcon.ahk ; https://autohotkey.com/download/1.1/

TrayIcon_Button( "skype.exe" ) ; <== no effect? normal? 14.03.2018 07:16

; Create a ListView to display the list of info gathered
; Gui Add, ListView, Grid r30 w700 Sort, Process|Tooltip|Visible|Handle ; <== no effect?


That's the thing, it didn't work for me. That's why I am asking for help.
From the documentation, it appears that it should work the way I wrote it.

EDIT: well it worked when I tried to double click another tray icon, but not for qbittorrent.exe
Any idea why?

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

Post by SL5 » 14 Mar 2018, 01:18

SquirrelHugger wrote:Hey @FanaticGuru ...

Code: [Select all]GeSHi © Codebox Plus

TrayIcon_Button( "qbittorrent.exe" )

But it did not work. ...


hi and sorry. :) how you did that? to me the follwiing has no effect:

Code: [Select all]GeSHi © Codebox Plus

#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.

#Include TrayIcon.ahk ; https://autohotkey.com/download/1.1/

TrayIcon_Button( "skype.exe" ) ; <== no effect? normal? 14.03.2018 07:16

; Create a ListView to display the list of info gathered
; Gui Add, ListView, Grid r30 w700 Sort, Process|Tooltip|Visible|Handle ; <== no effect?

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

Post by SquirrelHugger » 13 Mar 2018, 22:05

Hey @FanaticGuru

I am having difficulty using your script. I tried your script and the example script and I am getting this:
host.ahk.png
host.ahk.png (12.32 KiB) Viewed 537 times


No problem there, see the qbittorrent.exe at #13? I am trying to simulate a left mouse button click.
I tried the following:

Code: [Select all]GeSHi © Codebox Plus

TrayIcon_Button( "qbittorrent.exe" )


But it did not work. Would appreciate your input on this. Am I doing something wrong?

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

Post by FanaticGuru » 13 Mar 2018, 18:52

RiseUp wrote:Hopefully, this should work for both the hidden and the visible tray icons.


I updated my script at: https://autohotkey.com/boards/viewtopic.php?p=9186#p9186

My first attempt at fixing this for Windows 10 was something of a hack that only worked mostly by accident. Your solution of just looping again works but is kind of a hack to in that basically in Windows 10 you want ToolbarWindow323 for the Shell_TrayWnd.

I did a hack of checking Windows version and trying to if-then the right ToolbarWindow32?.

Windows seems to just keep making ToolbarWindow32 and putting a number on the end as needed, so even looping to 3 is no guarantee to continue working. The Shell_TrayWnd is not always 3.

I took what is hopefully a better approach and modified the function TrayIcon_GetTrayBar which all along was supposed to be the function to get the correct number before Windows introduced the NotifyIconOverflowWindow.

Maybe someone will find it useful although there is not really a definitive TrayIcon.ahk update from the original work Sean.

FG

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

Post by FanaticGuru » 13 Mar 2018, 17:19

nnnik wrote:@FanaticGuru your code tries to free hProc with VirtualFreeEx though the actual variable that should be freed is pRB - I hop you can correct this otherwise this script leaks memory.
Man, you have a sharp eye.

I believe it should be something like this:

Code: [Select all]GeSHi © Codebox Plus

hProc := DllCall("OpenProcess", UInt, 0x38, Int, 0, UInt, pidTaskbar)
; returns base address actually used; parameters = hProcess (from above), lpAddress, dwSize, flAllocationType, flProtect
pRB := DllCall("VirtualAllocEx", Ptr, hProc, Ptr, 0, UPtr, 20, UInt, 0x1000, UInt, 0x4)


; parameters = hProcess (from above "OpenProcess"), lpAddress (from above returned by "VirtualAllocEx"), dwSize, dwFreeType
DllCall("VirtualFreeEx", Ptr, hProc, Ptr, pRB, UPtr, 0, Uint, 0x8000)
DllCall("CloseHandle", Ptr, hProc)

Will also modify the script in my post.

FG

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

Post by SL5 » 13 Mar 2018, 09:22

i created a TrayIcon_test.ahkL
linked ahkL to "F:\portable\AutoHotkey_L1.1.28\AutoHotkeyU64.exe"
an tried this with no result:

Code: [Select all]GeSHi © Codebox Plus

#SingleInstance force
#Include TrayIcon.ahk ; https://autohotkey.com/download/1.1/
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
; Create a ListView to display the list of info gathered
Gui Add, ListView, Grid r30 w700 Sort, Process|Tooltip|Visible|Handle

Whats wrong? thanks

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

Post by SquirrelHugger » 13 Mar 2018, 07:02

I am trying to use this to simulate a double click on a specific system tray icon. I am really stupid and new when it comes to this, how should I go about doing what I am trying to do?

I know that I need to use the 'TrayIcon_Button' function, but do I have to include the file in my script? Or should the script be running? Excuse my noobness :D

EDIT: I am not getting any errors while using the following code, but nothing is happening

Code: [Select all]GeSHi © Codebox Plus

#Include %A_ScriptDir%\Miscellaneous\TrayIcon.ahk
TrayIcon_Button("qbittorrent.exe")

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

Post by nnnik » 12 Feb 2018, 09:24

@FanaticGuru your code tries to free hProc with VirtualFreeEx though the actual variable that should be freed is pRB - I hop you can correct this otherwise this script leaks memory.

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

Post by Vince42 » 25 Nov 2017, 17:00

:bravo: OMG! What can I say! It works!!! Thank you so much!

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

Post by RiseUp » 24 Nov 2017, 23:33

Aenfa wrote:I have tested it in Windows 10 and have found the library in the first post only sees visible icons while the library at post https://autohotkey.com/boards/viewtopic ... 9186#p9186 only sees hidden icons.

Using Windows 10 v 1709 build 16299.64 and AHK 1.1.26.01

Thank you, Aenfa, for your testing and reporting. :thumbup:

Vince42 wrote:Maybe there will be a "universal" version of TrayIcon, which would a) display visible and hidden icons and b) deliver information about the state of visibility in the future - I will try it again, as soon as I get all my SysTray icons listed.

it would also be cool, if the system icons like network connection, battery, sound, language and clock would be clickable as well.

I've made a change to the library's code and put it up on Github, but I'll post it here, too:
TrayIcon.ahk
(12.36 KiB) Downloaded 77 times

Hopefully, this should work for both the hidden and the visible tray icons. Once you have the newest TrayIcon.ahk in one of your library locations, try this code that should list all of your tray icons, both visible and hidden:

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

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

Post by Vince42 » 24 Nov 2017, 16:38

Maybe there will be a "universal" version of TrayIcon, which would a) display visible and hidden icons and b) deliver information about the state of visibility in the future - I will try it again, as soon as I get all my SysTray icons listed.

it would also be cool, if the system icons like network connection, battery, sound, language and clock would be clickable as well.

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

Post by Aenfa » 24 Nov 2017, 16:12

RiseUp wrote:
Vince42 wrote:I already unsuccessfully tried "java.exe" als Parameter - obviously something is missing or they changed something in Windwos 10 again.

Yes, a single click with the left mouse button is exactly what I need.

Do you have a sample code to iterate over the icons in the TrayIcon?

Sure, try the following code. It should bring up a ListView with all of your system tray icons' process names, tooltips, and handles.

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


This works for me on Windows 10. Let me know if it works for you.

I have tested it in Windows 10 and have found the library in the first post only sees visible icons while the library at post https://autohotkey.com/boards/viewtopic ... 9186#p9186 only sees hidden icons.

Using Windows 10 v 1709 build 16299.64 and AHK 1.1.26.01

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

Post by Vince42 » 23 Nov 2017, 16:11

Sorry for the late reply, I have not been notified of your reply. :(

Thank you very much for the code! I ran the script and five of twelve SysTray icons are listed - and the java one is missing amongst others. I guess that's the point, where my endeavour comes to an abrupt end?

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

Post by RiseUp » 21 Nov 2017, 16:13

Vince42 wrote:I already unsuccessfully tried "java.exe" als Parameter - obviously something is missing or they changed something in Windwos 10 again.

Yes, a single click with the left mouse button is exactly what I need.

Do you have a sample code to iterate over the icons in the TrayIcon?

Sure, try the following code. It should bring up a ListView with all of your system tray icons' process names, tooltips, and handles.

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


This works for me on Windows 10. Let me know if it works for you.

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

Post by Vince42 » 21 Nov 2017, 15:17

RiseUp wrote:If it appears in Task Manager as java.exe, then surely that could be the issue. Also, the uncommented call to the library function in your code simulates a single-click with the left mouse button. Is that what you're trying for?

Using TrayIcon_GetInfo() would definitely help to debug your issue, but it isn't necessary to get it working once you have the right parameter(s) figured out for TrayIcon_Button().


I already unsuccessfully tried "java.exe" als Parameter - obviously something is missing or they changed something in Windwos 10 again.

Yes, a single click with the left mouse button is exactly what I need.

Do you have a sample code to iterate over the icons in the TrayIcon?

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

Post by RiseUp » 20 Nov 2017, 20:17

Vince42 wrote:I am using the current official version of SysTray.ahk and the code snippet that is not working currently reads like this:

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



One thing came to my mind: The executable is called "tvbrowser.exe" but as this is a Java executable it is - according to the task manager - invoking "java.exe". I already unsuccessfully tried the function call with "java.exe". Maybe I should first try to read all tray icon information with TrayIcon_GetInfo()?

Cheers
Vince

If it appears in Task Manager as java.exe, then surely that could be the issue. Also, the uncommented call to the library function in your code simulates a single-click with the left mouse button. Is that what you're trying for?

Using TrayIcon_GetInfo() would definitely help to debug your issue, but it isn't necessary to get it working once you have the right parameter(s) figured out for TrayIcon_Button().

Top