Jump to content
Sign in to follow this  
Guest LizJ

why does winwait not work

Recommended Posts

Guest LizJ

The following code does not wait until the cmd.exe has been 'killed'. Any ideas?

$drivetype=drivegetfilesystem("d:\")

if not ($drivetype="ntfs") then

Send("{LWINDOWN}{LWINUP}{UP}{UP}{ENTER}")

WinWait("Run","Type the name of a p")

If Not WinActive("Run","Type the name of a p") Then WinActivate("Run","Type the name of a p")

WinWaitActive("Run","Type the name of a p")

Send("cmd{ENTER}")

WinWait("C:\WINNT\system32\cmd.exe","")

If Not WinActive("C:\WINNT\system32\cmd.exe","") Then WinActivate("C:\WINNT\system32\cmd.exe","")

WinWaitActive("C:\WINNT\system32\cmd.exe","")

Send("convert{SPACE}d{SHIFTDOWN};{SHIFTUP}{SPACE}/fs{SHIFTDOWN};{SHIFTUP}ntfs{ENTER}")

WinWait("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")

If Not WinActive("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","") Then WinActivate("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")

WinWaitActive("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")

Send("data{ENTER}")

WinWait("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")

If Not WinActive("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","") Then WinActivate("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")

WinWaitActive("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")

ProcessClose("cmd.exe")

Endif

if not ($drivetype="fat32") and fileexists("d:\pharmdb\data") then

dircopy("c:\hhcs\database", "d:\pharmdb")

EndIf

Share this post


Link to post
Share on other sites
Blue_Drache

The following code does not wait until the cmd.exe has been 'killed'. Any ideas?

Send("{LWINDOWN}{LWINUP}{UP}{UP}{ENTER}")
   WinWait("Run","Type the name of a p")
   If Not WinActive("Run","Type the name of a p") Then WinActivate("Run","Type the name of a p")
   WinWaitActive("Run","Type the name of a p")
   Send("cmd{ENTER}")
   WinWait("C:\WINNT\system32\cmd.exe","")
   If Not WinActive("C:\WINNT\system32\cmd.exe","") Then WinActivate("C:\WINNT\system32\cmd.exe","")
   WinWaitActive("C:\WINNT\system32\cmd.exe","")
   Send("convert{SPACE}d{SHIFTDOWN};{SHIFTUP}{SPACE}/fs{SHIFTDOWN};{SHIFTUP}ntfs{ENTER}")
   WinWait("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")
   If Not WinActive("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","") Then WinActivate("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")
   WinWaitActive("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")
   Send("data{ENTER}")
   WinWait("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")
   If Not WinActive("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","") Then WinActivate("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")
   WinWaitActive("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")
ProcessClose("cmd.exe")   
Endif

if not ($drivetype="fat32") and fileexists("d:\pharmdb\data") then
   dircopy("c:\hhcs\database", "d:\pharmdb")
EndIf

<{POST_SNAPBACK}>

This code is clunky and can be inturrupted or has the possibility to have errors.

Is "Convert" the name of a program? ... OK, just checked ... I see what you're doing.

Take a look at RunWait(@comspec)

your whole first block can be replaced by one line.

$drivetype=drivegetfilesystem("d:\")
if not ($drivetype="ntfs") then

   RunWait(@ComSpec & " /c " & "convert d: /fs:ntfs")

   WinWait("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")
   If Not WinActive("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","") Then WinActivate("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")
   WinWaitActive("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")
   Send("data{ENTER}")
   WinWait("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")
   If Not WinActive("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","") Then WinActivate("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")
   WinWaitActive("C:\WINNT\system32\cmd.exe - convert d: /fs:ntfs","")
ProcessClose("cmd.exe")   
Endif

Getting information from the CMD box is rather difficult.

Since I don't convert FAT32 to NTFS all that often (read never) I don't know the prompts that convert throws out.... You'll have to time it with sleep commands and such, or build a screen scraper that puts the contents of the DOS buffer into the clipboard where you can read it and wait for a specific prompt, then you can send an "Exit" command to the dos box.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.