[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

[Solved] Getting Access violation with AddTrayIcon

Post by ocnuybear » Thu Jul 19, 2018 6:41 am

Description:
Outlook 2016 has an annoying popup "Security Alert" that comes up a lot and I need to close this popup automatically and also give a count when mouse over the tray icon.
It works for a short while until it gives an Access violation at address 009E3a31 in module 'msched.exe'

Code: Select all

let>x=0
AddTrayIcon>C:\scan.ico,ClickOutlook,x
While>x<1000
x=x+1
WaitWindowOpen>Security Alert
SetFocus>Security Alert
Press ENTER
DelTrayIcon>ClickOutlook
AddTrayIcon>C:\scan.ico,ClickOutlook,x
EndWhile
Last edited by ocnuybear on Sat Jul 21, 2018 1:59 pm, edited 1 time in total.

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

Re: Getting Access violation with AddTrayIcon

Post by Marcus Tettmar » Thu Jul 19, 2018 12:49 pm

Wondering if the add or delete hasn't had time to happen before the next delete / add. I would try adding some short delays between the DelTrayIcon and AddTrayIcon commands.
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 » Thu Jul 19, 2018 1:18 pm

Hi Marcus,
Even adding a 5 second delay is not helping:

Code: Select all

let>x=0
AddTrayIcon>C:\scan.ico,ClickOutlook,x
While>x<1000
x=x+1
WaitWindowOpen>Security Alert
SetFocus>Security Alert
Press ENTER
DelTrayIcon>ClickOutlook
Wait>5
AddTrayIcon>C:\scan.ico,ClickOutlook,x
EndWhile
Another thing I have noticed is that when first designing the popup remover is when I used Function "CloseWindow" in stead of just sending ENTER key it sometimes complains did not find the window even putting in a delay as well. It seems Outlook tends to sends three or more "Security Alert" popups at the same time.

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

Re: Getting Access violation with AddTrayIcon

Post by ocnuybear » Thu Jul 19, 2018 4:15 pm

Got it working using AddTrayHandler, but not with MouseOver Tray like I want to:

Code: Select all

let>x=0
AddTrayIcon>C:\Users\John\Documents\Macro Scheduler 14\scan.ico,ClickOutlook,x
AddTrayHandler>ClickOutlook,OnClick,DoTrayClick
While>x<1000
WaitWindowOpen>Security Alert
Let>x=x+1
UIClick>{"Security Alert"},{"Yes"}
EndWhile

SRT>DoTrayClick
Let>MSG_STAYONTOP=1
Message>x
End>DoTrayClick
It seems the Create & Delete Tray Icon takes a long time to update

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

Re: Getting Access violation with AddTrayIcon

Post by ocnuybear » Thu Jul 19, 2018 4:41 pm

Is Function ModTrayIcon disabled? - when clicking on it nothing happens and typing it in does not display its help function on the bottom like other functions.

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

Re: Getting Access violation with AddTrayIcon

Post by Marcus Tettmar » Thu Jul 19, 2018 4:44 pm

It isn't disabled but could just be missing from the syntax helper/code builder config.
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 7:14 am

ModTrayIcon is not working on any of my two PC's - maybe a bug wit this version?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
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 8:22 am

ModTrayIcon works for me:

Code: Select all

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

//change the hint
ModTrayIcon>newICO,new hint,,True

//hide it
ModTrayIcon>newICO,,,False

//show it again
ModTrayIcon>newICO,,,True

//change the icon:
ModTrayIcon>newICO,click me,C:\Users\Marcus\Documents\16x16icons\ico\2.ico,True
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:10 am

Just bought & installed Sched Pro, but still not working - probably have to uninstall it without loosing my projects - what is the best way to do this?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
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:14 am

Uninstalling won't lose your scripts.

However, I cannot understand what isn't working. Did you try my code? That works for me. Maybe it's your .ico files. Do you want me to send the ones I'm using?
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:21 am

Just tried your script, but it says there is an error in line 10, but I checked both my icons is there and their pathnames was copied from explorer

Aslo clicking on ModTrayIcon does not popup the function in script view
Last edited by ocnuybear on Fri Jul 20, 2018 9:23 am, edited 1 time in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
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:23 am

Step through the script slowly. Running it will be too fast and you won't see the changes. Step through it line by line so you can see the changes to the icon for each line.
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:23 am

ok

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
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:25 am

When you say "error in line 10" was that the actual message!? Could you try to provide more verbose error/logging?
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:30 am

Stepping with F8 works and the hint changes from click me to new hint.

It gives the error when changing to new icon.

Just tried to swap the icon names in line 1 & 10, but it is not taking the new icon at the last line

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