Jump to content
Macro Express Forums

if system tray icon exists


ejs
 Share

Recommended Posts

Is there any technique I can use on macro express 3.x to check if a specific system tray icon exists?

 

I know I can use a macro command to move the mouse to a specified system tray icon, but I'm trying to do this check without moving the mouse.

 

I don't see an option within the "If" family of commands to check for a system tray icon, but if I could generate a list of the system tray icons and put that list in a text variable, I could check that way.

 

I can't simply check if the program is running, because the program in question may or may not produce the system tray icon depending on environmental conditions.

Link to comment
Share on other sites

I think you can infer it:

 

Grab mouse position into var1

Move mouse to tray icon command

Grab mouse position into var2

if var1=var2 mouse didnt move and try icon is not present

if var1=/=var2 mouse moved and must have gone to tray icon

 

Note that if the icon is 'hidden' in the tray behind a collapsed view this would not work.

Link to comment
Share on other sites

I think you can infer it:

 

Grab mouse position into var1

Move mouse to tray icon command

Grab mouse position into var2

if var1=var2 mouse didnt move and try icon is not present

if var1=/=var2 mouse moved and must have gone to tray icon

 

Note that if the icon is 'hidden' in the tray behind a collapsed view this would not work.

 

That fails because macro reports error message. But prompted by your general idea I wrote the following which seems to work OK.

 

Get Mouse Position into (%N[1]%, %N[2]%) Relative to Screen // Capture existing position so that it can be restored later if required

Move Mouse to Tray Icon to AWC // Move mouse cursor to tray icon with a name including the string 'AWC'

On Error

Catch Error: The system tray icon does not exist

Text Box Display: Result // Message if tray icon is not present

End Catch Error

End Error

Mouse Move: %N[1]%, %N[2]% Relative to Screen // If mouse did move, return it to its original position.

(May instead want to leave it there, ready to click the icon.)

Macro Return

 

<GET MOUSE POSITION Option="\x00" X="%N[1]%" Y="%N[2]%" _COMMENT="Capture existing position so that it can be restored later if required"/>
<MOVE MOUSE TO TRAY ICON Icon="AWC" Exact="FALSE" Center="TRUE" Left="0" Top="0" _HANDLE="0x002F" _COMMENT="Move mouse cursor to tray icon with a name including the string 'AWC'"/>
<ON ERROR/>
<CATCH ERROR Code="47"/>
<TEXT BOX DISPLAY Title="Result" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 That tray icon does not exist\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _COMMENT="Message if tray icon is not present"/>
<END CATCH ERROR/>
<END ERROR/>
<MOUSE MOVE Option="\x01" X="%N[1]%" Y="%N[2]%" _PROMPT="0x000A" _COMMENT="If mouse did move, return it to its original position.\r\n(May instead want to leave it there, ready to click the icon.)"/>
<MACRO RETURN/>

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

That fails because macro reports error message. But prompted by your general idea I wrote the following which seems to work OK.

 

Get Mouse Position into (%N[1]%, %N[2]%) Relative to Screen // Capture existing position so that it can be restored later if required

Move Mouse to Tray Icon to AWC // Move mouse cursor to tray icon with a name including the string 'AWC'

On Error

Catch Error: The system tray icon does not exist

Text Box Display: Result // Message if tray icon is not present

End Catch Error

End Error

Mouse Move: %N[1]%, %N[2]% Relative to Screen // If mouse did move, return it to its original position.

(May instead want to leave it there, ready to click the icon.)

Macro Return

 

<GET MOUSE POSITION Option="\x00" X="%N[1]%" Y="%N[2]%" _COMMENT="Capture existing position so that it can be restored later if required"/>
<MOVE MOUSE TO TRAY ICON Icon="AWC" Exact="FALSE" Center="TRUE" Left="0" Top="0" _HANDLE="0x002F" _COMMENT="Move mouse cursor to tray icon with a name including the string 'AWC'"/>
<ON ERROR/>
<CATCH ERROR Code="47"/>
<TEXT BOX DISPLAY Title="Result" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 That tray icon does not exist\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _COMMENT="Message if tray icon is not present"/>
<END CATCH ERROR/>
<END ERROR/>
<MOUSE MOVE Option="\x01" X="%N[1]%" Y="%N[2]%" _PROMPT="0x000A" _COMMENT="If mouse did move, return it to its original position.\r\n(May instead want to leave it there, ready to click the icon.)"/>
<MACRO RETURN/>

 

--

Terry, East Grinstead, UK

When I saw this I was stunned. I've never seen an "On Error" option, and after scouring ME3 and finally just copying your code

into an editor I realized something: It's not available in ME 3.

 

Another reason to upgrade to ME Pro, because this On Error command is awesome (How did I miss its existence in Pro till now?)

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...
 Share

×
×
  • Create New...