Jump to content
Macro Express Forums

Move To Tray Icon Help!


Rossco

Recommended Posts

Hi there,

I have been trying to figure out how I can use the "Move to Tray Icon" for the same icon but for 2 different names/titles...as follows.

 

I want to move the tray icon to the Zone Alarm icon, which I can do, however when there is no network activity, the icon name is "ZoneAlarm Security Suite" but if there is network traffic, the icon name is just "Traffic"

 

I have tried figuring out some if/else statements but can't seem to work around this issue....

 

....Is there a way I can tell the macro that if the icon reads as "Traffic or ZoneAlarm Security Suite" to still execute etc....?

 

I have tried using partial match and adding the word "Traffic" to the words, but still no go..

 

cheers & Regards

Rossco

Link to comment
Share on other sites

I entered a feature request for the commands If Tray Icon Exists and If Tray Icon Does Not Exist using the Request a Feature web page. This feature will be considered for a future version of Macro Express.

 

In the meantime there is a way to accomplish what you asked. It requires writing three macros.

 

The first macro tries to move the mouse to the ZoneAlarm system tray icon:

Macro Name: Try: Move to 'ZoneAlarm' System Tray icon

// Try to move to 'ZoneAlarm' icon. Log the error if it fails.
Log Errors
Move Mouse to Tray Icon: "ZoneAlarm"

The second macro tries to move the mouse to the Traffic system tray icon:

Macro Name: Try: Move to 'Traffic' System Tray icon

// Try to move to 'Traffic' icon. Log the error if it fails.
Log Errors
Move Mouse to Tray Icon: "Traffic"

The third macro is the main macro. It calls one or both of the other macros:

If File Exists "SysTrayError.txt"
 Delete File or Files: "SysTrayError.txt"
End If

Macro Run: Try: Move to 'ZoneAlarm' System Tray icon
Delay 0.5 Seconds
If File Exists "SysTrayError.txt"
 Macro Run: Try: Move to 'Traffic' System Tray icon
End If

How it works:

The Try: Move to 'ZoneAlarm' System Tray icon and Try: Move to 'Traffic' System Tray icon macros both work the same way. The Log Errors command tells the macro to write any errors to a file instead of stopping the macro. Then it attempts to run the Mouse Move to Tray Icon command. If the command fails, it will create the file specified in the Log Errors command. The key is that the macro will not stop.

 

The main macro first deletes the file SysTrayError.txt. Then it runs the first 'Try:' macro. If that macro fails the file SysTrayError.txt will exist and the macro will run the second 'Try:' macro.

 

I have tested this technique and it works fine on my computer that uses Zone Alarm.

Edited by kevin
Link to comment
Share on other sites

Absolutely brilliant,

I was not thinking outside the square...or should that be outside the realms of 1 macro....thanks kevin, very much appreciated...

 

That feature request would be a great help in situations like this...

 

cheers

Rossco

Link to comment
Share on other sites

In the meantime there is a way to accomplish what you asked. It requires writing three macros.

 

Kevin, I tried this idea some time ago, and again this morning.

 

I have 3 macros, M1, M1a and M1b.

 

M1 does this:

- erases the error log file if it exists

- calls M1a

- displays a message depending on whether the error log exists or not

- erases the error log file if it exists

- calls M1b

- displays a message depending on whether the error log exists or not

 

M1a and M1b do the same thing:

- logs errors to the error log file, and does not display error messages

- tries to move the mouse to tray icon xyz

- displays a message on success, and a different one on failure

 

But this does not work for me. When M1a fails to find the tray icon, it stops (i.e. it does not return control to macro M1). What am I doing wrong?

 

I'm using ME v3.7a build 1.

Link to comment
Share on other sites

Make sure you enable the 'Do not display error messages (log only)' option in the Log Errors commands.

 

I am attaching my macros in the attached macro file 'SysTrayDemo.mex'

 

*** Note: The attached macro file does not always work. See additional information below. ***

SysTrayDemo.mex

Edited by kevin
Link to comment
Share on other sites

This sample only requires two macros. However, you need to change the scheduled macro timer interval to 1 second. Click Options, Preferences, Schedule and set the Timer Interval to 'Check Every 1 second'.

 

The main macro looks like this:

Macro Name: Sample: System Tray ME

// Delete the error log file, if it exists
If File Exists "SysTray.txt"
 Delete File or Files: "SysTray.txt"
End If

// Enable the secondary macro
Macro Enable: Try: Move to 'Traf fic' System Tray icon
Log Errors
// Try to move to the ZoneAlarm tray icon
Move Mouse to Tray Icon: "ZoneAlarm"

The second macro is a scheduled macro. When creating the macro choose Schedule, Other, and 'Play Macro Indefinitely'. Set the schedule time to 0 minutes and 1 second. Enter these macro commands:

Macro Name: Try: Move to 'Traf fic' System Tray icon

// Log errors
Log Errors
// Disable this macro so it does not run again
Macro Disable: Try: Move to 'Traf  fic' System Tray icon
// Try to move to the 'Traffic' icon
Move Mouse to Tray Icon: "Traffic"

Notes:

  • The macro name I used is Try: Move to 'Traf fic' System Tray icon, not 'Traffic'. This keeps the Move Mouse to System Tray from moving to the Macro Express running man icon instead of Zone Alarm's 'Traffic' icon.
  • Setting the Scheduled Macro Timer Interval to 1 second will use more CPU cycles than the default value of 10 seconds. But there is no noticeable delay on my computers.

I have attached these new macros to this post.

SysTrayDemo2.mex

Edited by kevin
Link to comment
Share on other sites

You still need a third macro, to evaluate whether the second macro worked (i.e. it either did or did not locate the tray icon).

 

I have reworked Kevin's excellent example into generic code, as follows:

 

I have 3 macros, called M1, M2 and M3, where M2 and M3 are scheduled to run every second and start off disabled.

 

M1

If File Exists "Errorlog.txt"
 Delete File or Files: "Errorlog.txt"
End If

Variable Set String %T99% "UltraEdit-32"   --(see note 1)
Variable Save Text Variables
Macro Enable: M2

M2

Log Errors
Macro Disable: M2
Variable Restore Text Variables
If Variable %T99% <> ""
 Variable Set %T1% to ASCII Char of 01  --(see note 2)
 Variable Set String %T2% "<MOVETOTRAY:%T99%%T1%T:F:0:0>"
 Macro Enable: M3
 Run Macro in Variable %T2%
End If

M3

Macro Disable: M3
Clear Text Variables: All
Variable Save Text Variables  --see note 3

Note 1 T99 contains the partial name of some tray icon

Note 2 For some reason, using the command Move Mouse to Tray Icon does not work with a variable, so, instead, I create this command appending the passed-in variable T99 and run it.

Note 3 Here you should insert whatever code you need to deal with the Icon Found and Icon Not Found conditions.

If you are going to use this logic to handle several different tray icons, then you may need a series of conditions, as in:

Switch %T99%
 Case:UltraEdit-32
 End Case
 Case:ZoneAlarm
 End Case
 Case:Roboform
 End Case
End Switch

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...