Identifying tray icon

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Marcell
Posts: 46
Joined: 26 Jul 2016, 05:47

Identifying tray icon

06 Apr 2017, 07:36

Hi all,

I've set up a script to print to text and to copy from text to excel, but here's where I have a problem. The script immediately starts copying to excel while the print to text is running and often skips certain lines and meshes some lines together. I would like to know, when I print to text, a tray icon appears and when it's done, the print icon disappears. I've tried finding this icon in task manger to no avail.

I would like to know, how do I identify that tray icon's name for use purposes in autohotkey. Is it as simple as the text that appears when I mouse over it and then add .ico?
Also, how would I pause the script or halt the script to wait until this icon disappears before pasting to excel?
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: Identifying tray icon

06 Apr 2017, 09:37

If it takes a predictable amount of time, the easiet solution might be to just add a Sleep to your script.

I'm assuming the tray icon doesn't open any windows, so WinWaitClose isn't an option. Does your script use Run to open the print to text process? If so, could you use RunWait instead? If you can figure out the name of the process, you could also use Process, Exist in a while loop to wait out the program.
Marcell
Posts: 46
Joined: 26 Jul 2016, 05:47

Re: Identifying tray icon

07 Apr 2017, 04:51

MaxAstro wrote:If it takes a predictable amount of time, the easiet solution might be to just add a Sleep to your script.

I'm assuming the tray icon doesn't open any windows, so WinWaitClose isn't an option. Does your script use Run to open the print to text process? If so, could you use RunWait instead? If you can figure out the name of the process, you could also use Process, Exist in a while loop to wait out the program.
Sorry, I communicated improperly. The program I'm using prints and the printer is set up to print to text instead, so when the program prints to text, a popup appears, this info might make the solution more attainable >.<. The popup is labeled "1 document pending for User" And I'm wondering if the solution is as simple as "1 document pending for User.ico"

Right now it is on a 4 second delay, but this delay has been reliable 90% of the time.

How would I get the process? Only way I've tried was via task manager to no avail. Is there perhaps a script I can run? Maybe a detecthidden type script?

Oh and the printer is called "generic/text only printer"
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: Identifying tray icon

07 Apr 2017, 09:48

If there is a popup, that popup should be a window that Window Spy can identify. Try getting Window Spy up and ready, then when the popup appears mouse over it and quickly take a screenshot to preserve the info.
Marcell
Posts: 46
Joined: 26 Jul 2016, 05:47

Re: Identifying tray icon

10 Apr 2017, 07:18

MaxAstro wrote:If there is a popup, that popup should be a window that Window Spy can identify. Try getting Window Spy up and ready, then when the popup appears mouse over it and quickly take a screenshot to preserve the info.
Spy, or at least my spy doesn't pick up any icons on the tray. All it picks up is Start button, the time and quicklaunch.
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: Identifying tray icon

10 Apr 2017, 13:02

Oh, so a tray icon appears but there isn't actually a popup. That does make things harder. You'd need to figure out what executable is associated with that tray icon, which could be tricky if it's a default windows function.

I'm not really familiar with how the generic text print driver works, unfortunately, so I'm not sure I can be much more help here.
Marcell
Posts: 46
Joined: 26 Jul 2016, 05:47

Re: Identifying tray icon

20 Apr 2017, 04:35

MaxAstro wrote:Oh, so a tray icon appears but there isn't actually a popup. That does make things harder. You'd need to figure out what executable is associated with that tray icon, which could be tricky if it's a default windows function.

I'm not really familiar with how the generic text print driver works, unfortunately, so I'm not sure I can be much more help here.
Thanks for trying though.

Anyone else can provide some assistance on the matter? I've got literally everything else working in my code except this part. Right now it's running on the delay timer, but isn't fully reliable.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: Identifying tray icon

20 Apr 2017, 07:24

It's not gonna be easy, you'll need to call some API(s).
Apparently calling GetPrinter() should return some useful info on the chosen printer according to the Level parameter.
As stated on the EnumJobs page, a value of 2 for Level should return the number of print jobs (cJobs) in the printer queue (among others) while a value of 6 would return only the printer status. Calling GetPrinter() in a loop after the print job started and filtering out the desired response(s) should help you out in your quest. For best results - in case the printer incidentally gets other jobs unrelated to your target task - you might wanna call EnumJobs() too and filter out anything unrelated.
You need to know about using DllCall() in AHK, using structures, allocating/freeing libraries and memory etc. Good luck! :)
Part of my AHK work can be found here.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Identifying tray icon

20 Apr 2017, 10:45

The following might help you to detect whether the printer icon is in the systray (system tray) (notification area):

[functions to list taskbar buttons/systray icons, require Acc:]
Windows Update: detect if important updates available - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 47#p126047
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?t=26201

[Also there is TrayIcon.ahk mentioned here:]
Showing a process window from a hidden icon - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=28671

Basically you would loop until the tray icon disappears.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Marcell
Posts: 46
Joined: 26 Jul 2016, 05:47

Re: Identifying tray icon

21 Apr 2017, 09:22

Thanks all, gonna do some reading and testing and report back.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AHK_user, Google [Bot], sharonhuston and 204 guests