Jump to content

Trying to use $handle in WinWaitClose opposed to CLASS


 Share

Recommended Posts

Hey everyone long time reader first time posting! I am currently needing some help. I have been hitting my head against the wall trying to figure out a way around this problem but I cannot think of a way. I have a script (it is posted below) that I am wanting go out onto a FTP server and retrieve the latest copy of X. The script uses a batch file to call a javascript to go out and retrieve the file. I then want the program(autoit) to wait until that download is done though it's not working. Once I get the file downloading I have an Autoit command that will unzip the contents into another folder(This is all in the same Autoit file).

That command jumps way ahead and doesn't wait for the file to be downloaded. (Sorry this is so long winded) 

What I am currently trying to do is figure out a way of doing a WinWaitClose($handle, "") if that is possible. I have tried having the autoit file to hold based on the class and the title (separate of course) but neither work. I have used the Autoit Window Info tool and this is the information displayed by it.

Sorry for this being such a long post just trying to get some help! Thanks guys!!!

-Rich

>>>> Window <<<<
Title: FVW - WinSCP
Class: ConsoleWindowClass
Position: 75, 75
Size: 677, 342
Style: 0x14EF0000
ExStyle: 0x00040310
Handle: 0x00930378

>>>> Control <<<<
Class: 
Instance: 
ClassnameNN: 
Name: 
Advanced (Class): 
ID: 
Text: 
Position: 
Size: 
ControlClick Coords: 
Style: 
ExStyle: 
Handle: 

>>>> Mouse <<<<
Position: 204, 100
Cursor ID: 0
Color: 0xD4E2EF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<

#include <MsgBoxConstants.au3>

;Launches JavaScript to retrieve the latest XPlan install
Run("C:\Users\NTS User\Desktop\Java\latestinstall.bat")

;Waits for the first dialog window to pop up
WinWaitActive("[CLASS:#32770]")
Send("{ENTER}")

;Waits for the second dialog window to pop up
WinWaitActive("[CLASS:#32770]")
Send("{ENTER}")

;Goes to the ftp server and retrieves file
WinWaitClose("CLASS:ConsoleWindowClass", "")

;Sleeps for 5 seconds
Sleep(5000)

;Unzips the installtion to another folder
ShellExecute("C:\Users\NTS User\Documents\AutoInstall\Zip.bat")

;Message window will popup and wait 10 seconds
sleep(60000)
MsgBox($MB_SYSTEMMODAL, "Pause", "This message box will timeout after 10 seconds or select the OK button.", 10)

;Will make cmdprmt.bat file wait 20 seconds before it will open, giving the javascript time to rename the file
Sleep(240000)

;Starts Batch file that will open C# installer and launches Installer.exe
ShellExecute("C:\Users\NTS User\Documents\AutoInstall\Autoit\cmdprmt.bat", "")
Sleep(25000)
Send("!n")

;Waits for XInstaller to display the word success
WinWaitActive("XInstaller","Success")

;Runs the bat file to shutdown the virtual
Run("C:\Users\NTS User\Desktop\Java\Shutdown.bat")

 

Link to comment
Share on other sites

It should work with the title/class as well.

 

The title/hWnd/class of the window to check

$handle = 0x00930378
WinWaitClose($handle, "")
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Could be, if it is the active window you could always..

$handle = WinGetHandle("[ACTIVE]")
WinWaitClose($handle, "")

or

$handle = WinGetHandle("FVW") ; partial text is matched
WinWaitClose($handle, "")

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

You can always check to make sure you have the right handle after you get it, before you call winWaitClose with:

Local $wExts = WinExists($handle)
If $wExts = 0 Then
    MsgBox(0, "", "You did not get the correct handle")
EndIf
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Thank you Mikah I would not have figured it out without your help! When it would open the command prompt window when launching the JavaScript it would open several windows. Some with a file directory to where the JavaScript was or the title of the window being WinSCP. I tried putting in the code

$handle = WinGetHandle("FVW") ; partial text is matched
WinWaitClose($handle, "")

 

It did not work (on the first go around) Looking at the windows as they came up I noticed that the name FVW - WinSCP was displayed once before it got to the final command prompt window with the same title.

So I just did

$handle = WinGetHandle("FVW") ; partial text is matched
WinWaitClose($handle, "")
Sleep(15000)
$handle = WinGetHandle("FVW") ; partial text is matched
WinWaitClose($handle, "")
 
Now when I close that window it continues on in the script. Thank you again MikahS!!!! :D
Link to comment
Share on other sites

You are very welcome! :)

I'm glad you were able to find a way with the code provided.

Now, if someone else is in this same situation I think it would be best to mark the code that helped you solve this as "marked solved" which is on the bottom right of the post that helped you.

Just helps newcomers looking for the same solution ;)

Again, you are very welcome :D

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

When you start to get more sophisticated with your scripting, you can then look for only windows created from the process produced by the Run() command.  That way, you don't pick up on a similarly named window, but your exact window.

Then, when there are popups, you can get the parent hwnd, and use that to get the 'enabled popups' via:

$hYourPopup = _WinAPI_GetWindow($hYourParent,6)



Enabled popups are: ("[CLASS:#32770]")

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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...