Jump to content

AdlibEnable("")


Recommended Posts

The following code does not work. I want it to check throught the lifecyle of the script for any message boxes that appear which have a substring of the word 'error'. The MsgBox(4096, "Baji", "Unexpected error occurred", "") statement did not execute as expected.

Please correct the code for me:

;/* check for unforeseen errors every 250 MS (i.e. checks for an error window to pop up unpredictably, etc)

AdlibEnable("myadlib")

Func myadlib()

;Searches for substring title search of "error"

Opt("WinTitleMatchMode",2)

Opt("WinWaitDelay",10)

If WinActive("Error") OR WinActive("error") OR WinActive("ERROR") Then

MsgBox(4096, "Baji", "Unexpected error occurred", "")

Exit

EndIf

EndFunc

sleep(2000)

MsgBox(4096, "Error", "Test", "")

Link to comment
Share on other sites

don't think you can check for a message box using the adlib in the same script, i believe the message box stops the script untill it is closed.

<{POST_SNAPBACK}>

Are you stating that i include it in another script and use a #include in the main script?

I tried this and I don't think it worked:

;Main script

#include "WriteToFile.au3"

;Need code to read in fields from other tables

$Pre = 1

sleep(2000)

MsgBox(4096, "H Error H", "Test", "")

;WriteToFile.au3 script

;/* check for unforeseen errors every 250 MS (i.e. checks for an error window to pop up unpredictably, etc)

Func myadlib()

;Searches for substring title search of "error"

Opt("WinTitleMatchMode",2)

Opt("WinWaitDelay",10)

;If WinActive("Error") OR WinActive("error") OR WinActive("ERROR") Then

If WinActive("Error") Then

MsgBox(4096, "Baji", "Unexpected error occurred", "")

Exit

EndIf

EndFunc

In the AutoIt help file it give me this as an example:

AdlibEnable("myadlib")

;...

Exit

Func myadlib()

If WinActive("Error") Then

;...

EndIf

EndFunc

Link to comment
Share on other sites

nope - I do not think gafrost was attempting to convey that idea...

Within your main script you can launch a totally separate script that checks for your error windows.

<{POST_SNAPBACK}>

What is the code to launch this separate script please?
Link to comment
Share on other sites

Run("blah.exe")

<{POST_SNAPBACK}>

Sorry i tried the following, but it did not work:

;Main script

Run("d:\documents and settings\wwa2b\Desktop\WriteToFile.exe")

sleep(2000)

MsgBox(4096, "H Error H", "Test", "")

sleep(2000)

;WriteToFile.exe

;/* check for unforeseen errors every 250 MS (i.e. checks for an error window to pop up unpredictably, etc)

AdlibEnable("myadlib")

Func myadlib()

;Searches for substring title search of "error"

Opt("WinTitleMatchMode",2)

Opt("WinWaitDelay",10)

;If WinActive("Error") OR WinActive("error") OR WinActive("ERROR") Then

If WinActive("Error") Then

MsgBox(4096, "Baji", "Unexpected error occurred", "")

;Exit

EndIf

EndFunc

Am I doing this right or do you know the solution please?

Link to comment
Share on other sites

Let me try and show you the concept:

Download the two files attached to this post:

Mainscript.au3 and MessageWatcher.au3

Put them in a folder named C:\Temp

Run the script named Mainscript.au3 and read the message box from each script.

Open each script and read the code and comments.

I do not know why you would want to do this - so I may not understand exactly what you want. I do not understand this sentence at all: "...check throught the lifecyle of the script for any message boxes that appear which have a substring of the word 'error'..."

...but based on your code, I think that I've made something that you could use.

hope this helps

Edit - old attachments removed

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Let me try and show you the concept:

Download the two files attached to this post:

Mainscript.au3 and MessageWatcher.au3

Put them in a folder named C:\Temp

Run the script named Mainscript.au3 and read the message box from each script.

Open each script and read the code and comments.

I do not know why you would want to do this - so I may not understand exactly what you want. I do not understand this sentence at all: "...check throught the lifecyle of the script for any message boxes that appear which have a substring of the word 'error'..."

...but based on your code, I think that I've made something that you could use.

hope this helps

<{POST_SNAPBACK}>

Sorry, I may have caused some confusion. If the application that i'm testing causes an error box to appear will the function AdlibEnable("myadlib"), below, work:

AdlibEnable("myadlib")

Func myadlib()

;Searches for substring title search of "error"

Opt("WinTitleMatchMode",2)

Opt("WinWaitDelay",10)

;If WinActive("Error") OR WinActive("error") OR WinActive("ERROR") Then

If WinActive("Error") Then

MsgBox(4096, "Baji", "Unexpected error occurred", "")

Exit

EndIf

EndFunc

Link to comment
Share on other sites

Have you tried for the Adlib function to use if winexists instead of winactive? it's possible that the error message is displaying but not actually active.

edit: As for the messagbox halting the script that is correct. I threw this together to test. if you use the sleep then the adlib works fine. if you use the message box then the adlib does nothing.

$i = 1
SplashTextOn("This is a test", "Testing the splash screen" & $i, 160, 80, 10, 10)
AdlibEnable("Adlib")
MsgBox(0, "This is a test", "Testing testing 1,2,3")
;sleep(3000)

Func Adlib()
ControlSetText("This is a test", "", "Static1", "Testing the splash screen" & $i)
$i = $i + 1
EndFunc
Edited by MikeOsdx
Link to comment
Share on other sites

...will the function AdlibEnable("myadlib"), below, work:

<{POST_SNAPBACK}>

It depends on your definition of "work".

As currently written:

The app that you are testing (test-app) generates an error message.

The script above (adlib-code) "sees" that error and pops up a msgbox.

The test-app gens a second error message.

The adlib-code will not see it because it has halted on the msgbox.*

*I've not tested this. Both gafrost and I think that the adlib-code will wait for the message box to be closed.

later

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...