[Solved] Getting Access violation with AddTrayIcon

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: Getting Access violation with AddTrayIcon

Post by ocnuybear » Fri Jul 20, 2018 9:31 am

It says Error in : test1
Line: 10 - Error in ModTrayIcon

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Getting Access violation with AddTrayIcon

Post by Marcus Tettmar » Fri Jul 20, 2018 9:32 am

It could be the new .ico file isn't compatible. Are you able to use the new .ico file at the outset? I.e. take the second icon file that you are trying to use in ModTrayIcon and use that in the initial AddTrayIcon command. Does it work?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: Getting Access violation with AddTrayIcon

Post by ocnuybear » Fri Jul 20, 2018 9:37 am

Ok it worked after using a different icon on the one that was not working :D

Now to get clicking on ModTrayIcon to popup and also display help function at bottom.

Going to uninstall and reinstall now,

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: Getting Access violation with AddTrayIcon

Post by ocnuybear » Fri Jul 20, 2018 9:43 am

No luck with that one - does not popup after remove + reinstall

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Getting Access violation with AddTrayIcon

Post by Marcus Tettmar » Fri Jul 20, 2018 9:46 am

I'm not sure what you are trying to do. Can you explain and provide code?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Getting Access violation with AddTrayIcon

Post by Marcus Tettmar » Fri Jul 20, 2018 9:49 am

Are you trying to create a popup menu and have it pop up when you click on the icon? If so maybe this example will help:

Code: Select all

AddTrayIcon>C:\Users\Marcus\Documents\16x16icons\ico\1.ico,newICO,click me
AddTrayHandler>newICO,OnClick,DoPopup

//Idle loop to stop macro exiting before I can do anything ...
Label>idle_loop
  Wait>0.02
Goto>idle_loop

SRT>DoPopup
  Let>Items=Open;Close;About;Exit
  GetCursorPos>X,Y
  PopupMenu>X,Y,Items,res
  MessageModal>You selected item: %res%
END>DoPopup
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: Getting Access violation with AddTrayIcon

Post by ocnuybear » Fri Jul 20, 2018 9:50 am

I will get a couple of screenshots :D

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: Getting Access violation with AddTrayIcon

Post by ocnuybear » Fri Jul 20, 2018 10:13 am

Hi Marcus,

The screenshots is not working, but I will explain again:

When inside a project & Code Builders Tab is activated, under Miscellaneous when left clicking on KillProcess, it gives a new Code Bulder Window with Command reference, Insert & Cancel buttons.
Now close that window and back to Code Builders Tab when hovering over KillProcess ,a small white popup comes up with Terminates a process text.

Now moving the mouse down to ModTrayIcon just beneath and clicking on it, nothing happens and there is also no white little popup, but move the cursor to next one down is PlayWav and the white popup reappears and clicking on it gives a window popup with Wav File: and buttons.

Sorry I hope my explanation is more clear now :P

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Getting Access violation with AddTrayIcon

Post by Marcus Tettmar » Fri Jul 20, 2018 10:23 am

Right that has nothing to do with your code! I thought you were talking about getting your own pop up menu to work on your own icon.

This is the code builder / syntax highlighter / syntax helper. It is just the editor and does not prevent it from working.

I already explained that all this means is that the function definitions are missing from the EDITOR syntax helper. This just a code builder and DOES NOT AFFECT ITS USE. You will just have to write the code manually.

However, I have now fixed it in 14.4.10.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: Getting Access violation with AddTrayIcon

Post by ocnuybear » Fri Jul 20, 2018 10:27 am

My apologies for that misunderstanding.

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: Getting Access violation with AddTrayIcon

Post by ocnuybear » Sat Jul 21, 2018 1:57 pm

Got it working 100% now as required:

Code: Select all

Let>z=0
AddTrayIcon>C:\Users\John\Documents\Macro Scheduler 14\scan.ico,ClickOutlook,z
AddTrayHandler>ClickOutlook,OnClick,DoPopup
While>z<1000
WaitWindowOpen>Security Alert
//Clicks on annoying Outlook Security Alerts & counts them
UIClick>{"Security Alert"},{"Yes"}
Let>z=z+1
//When holding mouse over icon the clicked amount is displayed
ModTrayIcon>ClickOutlook,z,,True
EndWhile

//Adds option to easy exit
SRT>DoPopup
  //Let>Items=Open;Close;About;Exit
  Let>Items=Exit
  GetCursorPos>X,Y
  PopupMenu>X,Y,Items,res
  If>%res%=0
  Exit
  Endif
END>DoPopup
Thank you Marcus :D

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: [Solved] Getting Access violation with AddTrayIcon

Post by ocnuybear » Tue Jul 24, 2018 1:20 pm

Update: I noticed the app was running at about 3% in Win Task manager and replaced the WaitWindowOpen with IfWindowOpen with a delay of 100ms and it's resource usage went below 1%:

Code: Select all

Let>z=0
Let>x=0
AddTrayIcon>C:\Users\John\Documents\Macro Scheduler 14\scan.ico,ClickOutlook,x
AddTrayHandler>ClickOutlook,OnClick,DoPopup
While>z=0
  //Clicks on annoying Outlook Security Alerts & counts them
  IfWindowOpen>Security Alert
    UIClick>{"Security Alert"},{"Yes"}
    Let>x=x+1
  Endif
  Wait>0.1
  //When holding mouse over icon the clicked amount is displayed
  ModTrayIcon>ClickOutlook,x,,True
EndWhile

//Adds option to exit with left click
SRT>DoPopup
  //Let>Items=Open;Close;About;Exit
  Let>Items=Exit
  GetCursorPos>X,Y
  PopupMenu>X,Y,Items,res
  If>%res%=0
  Exit
  Endif
END>DoPopup

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts