Sign in to follow this  
Followers 0
Noob

A Microsoft program gives error on exit when my script running

4 posts in this topic

The following relates to a free-ware application I made with my very limited AutoIt skills. Link to it is here: http://www.gpspassion.com/forumsen/topic.asp?TOPIC_ID=24519

(The exe is not password protected, if anyone wishes to look at the mess :whistle:

The latest versions of the application seem to work to the satisfation of people who use it, but there is this one annoyance that doesn't let me sleep well. The script is designed to control Microsoft Streets & Trips. Occasionally, upon the exit of Streets & Trips, the following error is generated:

Posted Image

I can reproduce the error by the following simple script:

Opt("WinTitleMatchMode", 2)

While 1
    If WinActive("- Microsoft Streets & Trips", "whatever") Then Sleep(1)
    ; Sleep(100)
WEnd

The CPU usage of the script will be high, because there is no sleep(), and the error will appear almost every time Streets & Trips exits. In my actual script I do have a sleep(100) in my loop, and CPU usage is fine, and the error appears only occasionally.

I suspect this has more to do with Microsoft Streets & Trips, than with anything else. I tried the same test script (as above) on Notepad, Internet Explorer, Word, but I cannot reproduce the same error message which Streets & Trips generates.

Perhaps there is nothing that can be done here, just to live with it. But I'm posting this here in case I'm overlooking something.

If there was an AutoIt function which would detect when Streets & Trips is going to close, I think that would help. I would pause my script for a moment while Streets & Trips is closing. I think that would do the trick.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If I had to guess, I'd say that Au3Check gives you a pretty good idea on why this is happening:

CODE

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /prod /AU3Check /in "C:\keys.au3"

+> 18:27:05 Starting AutoIt3Wrapper v.1.7.7

>Running AU3Check (1.54.6.0) params: from:C:\Program Files\AutoIt3

C:\keys.au3(175,113) : ERROR: Start() called with wrong number of args.

If IniRead(@HomeDrive & @HomePath & "\Keys.ini", "Section1", "F2enabled", 1) = 1 Then HotKeySet("{F2}", "Start")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~^

C:\keys.au3(142,14) : REF: definition of Start().

Call("Start")

~~~~~~~~~~~~^

C:\keys.au3(201,27) : ERROR: help() called with wrong number of args.

HotKeySet("{F1}", "help")

~~~~~~~~~~~~~~~~~~~~~~~~^

C:\keys.au3(189,14) : REF: definition of help().

Call("help")

~~~~~~~~~~~^

C:\keys.au3(957,103) : WARNING: $GuidanceL: possibly used before declaration.

Case IniRead(@HomeDrive & @HomePath & "\Keys.ini", "Section1", "DynamicL", 0) = 1 And $GuidanceL =

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\keys.au3(1215,67) : ERROR: ControlClick() called with illegal argument 4: ""

ControlClick("classname=#32770", "P&ostal code:","Button3", "")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\keys.au3(1254,67) : ERROR: ControlClick() called with illegal argument 4: ""

ControlClick("classname=#32770", "P&ostal code:","Button3", "")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\keys.au3(1275,46) : ERROR: ControlClick() called with illegal argument 4: ""

ControlClick($productname, "","Button35", "")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\keys.au3(1296,46) : ERROR: ControlClick() called with illegal argument 4: ""

ControlClick($productname, "","Button35", "")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\keys.au3(1317,46) : ERROR: ControlClick() called with illegal argument 4: ""

ControlClick($productname, "","Button35", "")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\keys.au3(1348,46) : ERROR: ControlClick() called with illegal argument 4: ""

ControlClick($productname, "","Button35", "")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\keys.au3(957,103) : ERROR: $GuidanceL: undeclared global variable.

Case IniRead(@HomeDrive & @HomePath & "\Keys.ini", "Section1", "DynamicL", 0) = 1 And $GuidanceL =

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\keys.au3 - 9 error(s), 1 warning(s)

!>18:27:05 AU3Check ended.rc:2

+>18:27:05 AutoIt3Wrapper Finished

>Exit code: 0 Time: 0.511

Edit:

You can also look at this:

MsgBox(0,0,@HomeDrive & @HomePath & @CRLF & @UserProfileDir)
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I can reproduce the error by the following simple script:

I can do it with Notepad with the idea that i see your script does see a Save As window open and then it closes the program. So I considered trying with Notepad and I get a crash of Notepad. It is closing the main window while the child window is still open which causes a crash.

Run('notepad')
WinWaitActive('Untitled')
WinMenuSelectItem('Untitled', '', '&File', '&Save')
WinClose('Untitled')

Solution: Close the Save As window first.

:whistle:

Share this post


Link to post
Share on other sites

SmOke_N and MHz, thank you very much for looking at it!

* I never before used Au3Check. Thanks for bringing it to my attention. It pointed at a few errors in my syntax. Now it is: 0 error(s), 0 warning(s). I just uploaded the corrected version. But during my brief testing I still continue getting the same error when I'm exiting Microsoft Streets & Trips.

* My script doesn't normally control closing of the MS Streets & Trips program. Only if users choose to enable the "auto-save on exit" feature in my app, then when prompted by MS Streets & Trips to save on exit, my app would controlclick the "Yes" to save. So the child window would be closed prior to closing the program.

But it is enough to just open MS Streets & Trips, and then immediately close it, to get (occasionally) the error message. As long as there is some (any) AutoIt script running at the time of closing of Streets & Trips, and as long as the script searches for a Streets & Trips window with some text, for example If WinActive("- Microsoft Streets & Trips", "whatever") Then...

As mentioned above, the following simple script can help generate the error upon Streets & Trips exiting:

Opt("WinTitleMatchMode", 2)

While 1
    If WinActive("- Microsoft Streets & Trips", "whatever") Then Sleep(1)
WEnd

Interestingly, I observed that if I add opt(WinTextMatchMode, 2), the quick mode, instead of the default mode, the above script no longer causes problem for MS Streets & Trips. Yet, after attempting to modify my application to be able to work with opt(WinTextMatchMode, 2), I continue getting the error.

Also I observed that removing Opt("WinTitleMatchMode", 2), and going to the default WinTitleMatchMode has the same positive effect on the above code. And yes, I did modify the window name in the If WinActive("... But it would take me quite a bit of time to modify my actual application to be able to work in the default WinTitleMatchMode, and I doubt it would solve my issue, so I'm not considering to try it at this time.

My question is, is it possible that this is just due to MS Streets & Trips not liking to be controlled by AutoIt? Is it known that some other programs act in a way similar to my problems? (Actually, everything works just fine, only the occasionally annoying pop-up when a user exits his MS Streets & Trips.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0