Jump to content

Scropt doesn't see active window


Recommended Posts

I have a script that automates the installation of a program called second copy. It runs fine until the Installation Complete window becomes active. It is then suppose to send an alt + f key. Instead the script pauses and never sends the key stroke. It acts like the window is not active. I am not sure why it is stopping. Thank you for any assistance you can offer.

David

Dim $oSub[46]

Dim $strValue

Dim $profile

Dim $strFile

Dim $file

Dim $x

if FileExists("C:\Program Files\SecCopy")Then

ProcessClose("SecCopy.exe")

Run("sc7.exe")

WinWaitActive("Welcome", "Welcome to Second Copy (7.0) Setup")

Send("!n")

WinWaitActive("Second Copy (7.0) License", "SECOND COPY (7.0) LICENSE")

Send("!y")

WinWaitActive("Read Me File", "Second Copy")

Send("!n")

WinWaitActive("Choose Destination", "Setup will install")

Send("!n")

WinWaitActive("Select Program Manager", "Enter the name")

Send("!n")

WinWaitActive("Start Installation", "You are now ready")

Send("!n")

WinWaitActive("Overwrite", "Do you want to overwrite")

Send("{Enter}")

WinWaitActive("Installation Complete", "Second Copy")

Send("!f")

WinWaitActive("About Second Copy", "Enter SN")

Send("{ENTER}")

WinWaitActive("Second Copy License")

Send("LBMC")

Send("{TAB}")

Send("Y363-F64B-C3F7")

Send("{ENTER}")

WinWaitActive("Information")

Send("{ENTER}")

WinWaitActive("About Second Copy")

Send("{ENTER}")

Else

Run("sc7.exe")

WinWaitActive("Welcome", "Welcome to Second Copy (7.0) Setup")

Send("!n")

WinWaitActive("Second Copy (7.0) License", "SECOND COPY (7.0) LICENSE")

Send("!y")

WinWaitActive("Read Me File", "Second Copy")

Send("!n")

WinWaitActive("Choose Destination", "Setup will install")

Send("!n")

WinWaitActive("Select Program Manager", "Enter the name")

Send("!n")

WinWaitActive("Start Installation", "You are now ready")

Send("!n")

WinWaitActive("Installation Complete", "Second Copy")

Send("!f")

WinWaitActive("About Second Copy", "Enter SN")

Send("{ENTER}")

WinWaitActive("Second Copy License")

Send("XXXX")

Send("{TAB}")

Send("YYYY-FFFF-CCCC")

Send("{ENTER}")

WinWaitActive("Information")

Send("{ENTER}")

WinWaitActive("About Second Copy")

Send("{ENTER}")

EndIf

$strValue = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Personal")

$profile = EnvGet("UserProfile")

$strFile = $profile & "\Local Settings\Application Data\Centered Systems\Second Copy\profiles.dat"

$oSub[0] = "[General]"

$oSub[1] = "Settings=92B8"

$oSub[2] = "Version=6.0.1.29"

$oSub[3] = "ExePath=C:\Program Files\SecCopy\"

$oSub[4] = "RegName=LBMC"

$oSub[5] = "RegKey=Y363-F64B-C3F7"

$oSub[6] = "[Agenda]"

$oSub[7] = "Profile1=Desktop"

$oSub[8] = "Profile2=Favorites"

$oSub[9] = "Profile3=My Documents"

$oSub[10] = "[My Documents]"

$oSub[11] = "SetupType=Custom"

$oSub[12] = "SourceLocation=" & $strValue

$oSub[13] = "DestLocation=\\xxxx.net\bwood\users\%username%\scopy\md"

$oSub[14] = "Schedule=Manual"

$oSub[15] = "Hours=10"

$oSub[16] = "RunAtStartup=1"

$oSub[17] = "AllFiles=0"

$oSub[18] = "Exclude1=*.pst"

$oSub[19] = "Exclude2=*.ost"

$oSub[20] = "Exclude3=*.mp3"

$oSub[21] = "Exclude4=*.mp4"

$oSub[22] = "Exclude5=*.wav"

$oSub[23] = "Exclude6=*.rm"

$oSub[24] = "Exclude7=*.wma"

$oSub[25] = "Exclude8=*.wmv"

$oSub[26] = "Exclude9=*.mpeg"

$oSub[27] = "Exclude10=*.aac"

$oSub[28] = "Exclude11=*.m4a"

$oSub[29] = "CopyMode=4"

$oSub[30] = "SynchronizeDeletions=1"

$oSub[31] = "[Desktop]"

$oSub[32] = "SetupType=Custom"

$oSub[33] = "SourceLocation=%USERPROFILE%\Desktop"

$oSub[34] = "DestLocation=\\xxxx.net\bwood\users\%username%\scopy\desktop"

$oSub[35] = "Schedule=Manual"

$oSub[36] = "Hours=10"

$oSub[37] = "RunAtStartup=1"

$oSub[38] = "[Favorites]"

$oSub[39] = "SetupType=Custom"

$oSub[40] = "SourceLocation=%USERPROFILE%\Favorites"

$oSub[41] = "DestLocation=\\xxxx.net\bwood\users\%USERNAME%\scopy\favorites"

$oSub[42] = "Schedule=Manual"

$oSub[43] = "Hours=10"

$oSub[44] = "Days=1"

$oSub[45] = "RunAtStartup=1"

$file = FileOpen($strFile, 2)

for $x = 0 to 45

FileWriteLine($file, $oSub[$x])

next

FileClose($file)

Link to comment
Share on other sites

This is probably not much help. But I had a similar problem with a couple of installers that I created. I wound up having to just use a sleep instead of Winwaitactive. You might try a WinActivate to ensure that the window is active first. But I know that in my case it still didn't find the window and I had to go with a sleep. :rolleyes:

Link to comment
Share on other sites

You have an issue with a unsuspecting window. AdlibEnable() can handle that window. I added some tweaking to your script to help improve it's performance some. :rolleyes:

Opt("TrayIconDebug", 1)

Global $oSub[46]
Global $strValue
Global $profile
Global $strFile
Global $file
Global $x

ProcessClose("SecCopy.exe")

If Not FileExists("sc7.exe") And FileExists(@ScriptDir & "\sc7.exe") Then
    FileChangeDir(@ScriptDir)
EndIf

$pid = Run("sc7.exe")
_WinWaitActive("Welcome", "Welcome to Second Copy (7.0) Setup")
Send("!n")
_WinWaitActive("Second Copy (7.0) License", "SECOND COPY (7.0) LICENSE")
Send("!y")
_WinWaitActive("Read Me File", "Second Copy")
Send("!n")
_WinWaitActive("Choose Destination", "Setup will install")
Send("!n")
_WinWaitActive("Select Program Manager", "Enter the name")
Send("!n")
_WinWaitActive("Start Installation", "You are now ready")
Send("!n")

; Use Adlib function to watch for window that may open
AdlibEnable("_MyAdlibFunction")
_WinWaitActive("Installation Complete", "Second Copy")
Send("!f")
AdlibDisable()

_WinWaitActive("About Second Copy", "Enter SN")
Send("{ENTER}")
_WinWaitActive("Second Copy License")
Send("LBMC")
Send("{TAB}")
Send("NOCO-DEPL-EASE")
Send("{ENTER}")
_WinWaitActive("Information")
Send("{ENTER}")
_WinWaitActive("About Second Copy")
Send("{ENTER}")
ProcessWaitClose($pid)

$strValue = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Personal")

$profile = EnvGet("UserProfile") ; Hmmm, use @AppDataDir macro instead ?

$strFile = $profile & "\Local Settings\Application Data\Centered Systems\Second Copy\profiles.dat"

$oSub[0] = "[General]"
$oSub[1] = "Settings=92B8"
$oSub[2] = "Version=6.0.1.29"
$oSub[3] = "ExePath=C:\Program Files\SecCopy\"
$oSub[4] = "RegName=LBMC"
$oSub[5] = "RegKey=Y363-F64B-C3F7"
$oSub[6] = "[Agenda]"
$oSub[7] = "Profile1=Desktop"
$oSub[8] = "Profile2=Favorites"
$oSub[9] = "Profile3=My Documents"
$oSub[10] = "[My Documents]"
$oSub[11] = "SetupType=Custom"
$oSub[12] = "SourceLocation=" & $strValue
$oSub[13] = "DestLocation=\\xxxx.net\bwood\users\%username%\scopy\md"
$oSub[14] = "Schedule=Manual"
$oSub[15] = "Hours=10"
$oSub[16] = "RunAtStartup=1"
$oSub[17] = "AllFiles=0"
$oSub[18] = "Exclude1=*.pst"
$oSub[19] = "Exclude2=*.ost"
$oSub[20] = "Exclude3=*.mp3"
$oSub[21] = "Exclude4=*.mp4"
$oSub[22] = "Exclude5=*.wav"
$oSub[23] = "Exclude6=*.rm"
$oSub[24] = "Exclude7=*.wma"
$oSub[25] = "Exclude8=*.wmv"
$oSub[26] = "Exclude9=*.mpeg"
$oSub[27] = "Exclude10=*.aac"
$oSub[28] = "Exclude11=*.m4a"
$oSub[29] = "CopyMode=4"
$oSub[30] = "SynchronizeDeletions=1"
$oSub[31] = "[Desktop]"
$oSub[32] = "SetupType=Custom"
$oSub[33] = "SourceLocation=%USERPROFILE%\Desktop"
$oSub[34] = "DestLocation=\\xxxx.net\bwood\users\%username%\scopy\desktop"
$oSub[35] = "Schedule=Manual"
$oSub[36] = "Hours=10"
$oSub[37] = "RunAtStartup=1"
$oSub[38] = "[Favorites]"
$oSub[39] = "SetupType=Custom"
$oSub[40] = "SourceLocation=%USERPROFILE%\Favorites"
$oSub[41] = "DestLocation=\\xxxx.net\bwood\users\%USERNAME%\scopy\favorites"
$oSub[42] = "Schedule=Manual"
$oSub[43] = "Hours=10"
$oSub[44] = "Days=1"
$oSub[45] = "RunAtStartup=1"


$file = FileOpen($strFile, 2)
If $file <> -1 Then
    For $x = 0 To 45
        FileWriteLine($file, $oSub[$x])
    Next
Else
    MsgBox(0x40030, @ScriptName, 'FileOpen error', 5)
EndIf
FileClose($file)

Exit

Func _MyAdlibFunction()
    If WinExists("Overwrite", "Do you want to overwrite") Then
        _WinWaitActive("Overwrite", "Do you want to overwrite")
        Send("{Enter}")
    EndIf
EndFunc

Func _WinWaitActive($title, $text = "")
    WinWait($title, $text)
    WinActivate($title, $text)
    WinWaitActive($title, $text)
EndFunc

Edit:

Oh, and welcome to the AutoIt forums. :rambo:

Edited by MHz
Link to comment
Share on other sites

You might try this on that one window:

WinWait("Installation Complete", "Second Copy")

WinActivate("Installation Complete", "Second Copy")

WinWaitActive("Installation Complete", "Second Copy")

Send("!f")

Maybe it just looks to be active - grasping at straws here...

edit: sorry MHz - I did not notice that you made UDF

Edited by herewasplato

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

Link to comment
Share on other sites

theres these things called code boxes that when you post code you should use

autoit does syntax highlighting for autoit

 
While 1
Wend

and code just places a box around it

[code][code]

And you must close with a [/tagused] click on bb code help if you need more help

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