ejs Posted January 26, 2009 Report Share Posted January 26, 2009 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. Quote Link to comment Share on other sites More sharing options...
kevin Posted January 27, 2009 Report Share Posted January 27, 2009 You may be able to use the Repeat with Windows command. I don't know if this will help but maybe it's worth a try. Quote Link to comment Share on other sites More sharing options...
randallf Posted January 27, 2009 Report Share Posted January 27, 2009 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. Quote Link to comment Share on other sites More sharing options...
terrypin Posted January 28, 2009 Report Share Posted January 28, 2009 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 Quote Link to comment Share on other sites More sharing options...
stevecasper Posted January 28, 2009 Report Share Posted January 28, 2009 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?) Quote Link to comment Share on other sites More sharing options...
terrypin Posted January 28, 2009 Report Share Posted January 28, 2009 This was the first time I'd used it too! -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.