Jump to content

Weird AutoIT behavior... need insight


Recommended Posts

When I open a browser window, go to an online application, and select "Download a file" - I get a pop-up window asking if I want to save the file. I am trying to write an AutoIT script that checks for that window then closes it. The following autoit code works fine.

MouseClick("Left", 221, 345,1,10)

MsgBox (4096,"Start","Starting...",3)

WinActivate("Opening Full")

WinClose("Opening Full")

exit

That is, it launches the pop-up window, activates it, then closes it. HOWEVER,...

This code

MouseClick("Left", 221, 345,1,10)

$ck = WinActivate("Opening Full",5)

If $ck = 1 Then

MsgBox (4096,"Check","ck is: " & $ck,5)

Else

MsgBox (4096,"Check","ck is: " & $ck,5)

EndIf

$ck = WinExists("Opening Full")

If $ck = 1 Then

MsgBox (4096,"Check","ck is:" &$ck, 5)

Else

MsgBox (4096,"Check","ck is:" &$ck, 5)

EndIF$ck = WinClose("Opening Full")

$ck = WinClose("Opening Full")

If $ck = 1 Then

MsgBox (4096,"Check","ck is:" &$ck, 5)

Else

MsgBox (4096,"Check","ck is:" &$ck, 5)

EndIF$ck = WinClose("Opening Full")

Prints,

ck is 0

ck is 0

ck is 0

... and fails to close the window. Why is that? I was expecting it to print ck is 1!

Stumped.

It seems to me it should be printing ck is 1. What am I missing?

Link to comment
Share on other sites

When I open a browser window, go to an online application, and select "Download a file" - I get a pop-up window asking if I want to save the file. I am trying to write an AutoIT script that checks for that window then closes it. The following autoit code works fine.

MouseClick("Left", 221, 345,1,10)

MsgBox (4096,"Start","Starting...",3)

WinActivate("Opening Full")

WinClose("Opening Full")

exit

That is, it launches the pop-up window, activates it, then closes it. HOWEVER,...

This code

MouseClick("Left", 221, 345,1,10)

$ck = WinActivate("Opening Full",5)

If $ck = 1 Then

MsgBox (4096,"Check","ck is: " & $ck,5)

Else

MsgBox (4096,"Check","ck is: " & $ck,5)

EndIf

$ck = WinExists("Opening Full")

If $ck = 1 Then

MsgBox (4096,"Check","ck is:" &$ck, 5)

Else

MsgBox (4096,"Check","ck is:" &$ck, 5)

EndIF$ck = WinClose("Opening Full")

$ck = WinClose("Opening Full")

If $ck = 1 Then

MsgBox (4096,"Check","ck is:" &$ck, 5)

Else

MsgBox (4096,"Check","ck is:" &$ck, 5)

EndIF$ck = WinClose("Opening Full")

Prints,

ck is 0

ck is 0

ck is 0

... and fails to close the window. Why is that? I was expecting it to print ck is 1!

Stumped.

It seems to me it should be printing ck is 1. What am I missing?

In your first pass, you're using "5" (no quotes) as your second parameter on WinActivate(). The second parameter of the function is for any additional text in the window you're trying to target - I'm assuming you were setting 5 as an assumed timeout value?

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

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...