Jump to content

Hello and Help


Recommended Posts

First would like to say hello to everyone, I'm new on here and new to AutoIt v3. I think this tool is awesome!

I started doind a small little install to get familiar with the commands, and functions. I came across this problem.

I've tried using winwaitactive but the title of the window is the same for all windows when the app is installing and the !f command never executes, making the need of a user to be present. I don't want to use sleep command, although this is a quick fix, but i'm alittle worry because some machines are different, is there another command that i can come up with. Any help or direction is greatly appreciated. Thanks

here is the code :D

;mapping the Patchlink folder for installation will delete when it's done

DriveMapAdd("o:","share folder",8,"domain/user","password")

dim $tab, $enter, $space

$tab = "{tab}"

$space= "{space}"

$enter="{enter}"

$alt="{alt}"

;running command

Run("cmd.exe")

send($space)

send("O:" & $enter)

;activating patchlink

send("UpdateAgent.msi" & $enter )

;exiting cmd

send("exit" & $enter )

;waiting for patchlink to initialize - only one window title

WinWait("PatchLink Update Agent - InstallShield Wizard")

Send($alt)

Send("!N")

Send("!A")

Send("!N")

Send("!N")

;sends the install command

send("!i")

Sleep(25000) <---.

Send("!f")

WinWaitClose("PatchLink Update Agent - InstallShield Wizard")

DriveMapDel("o:")

Edited by new2autoit
Link to comment
Share on other sites

Well to take care of the window thing, you could use WinGetHandle.

$handle = WinGetHandle("Title name", "text")
If @error Then
    MsgBox(4096, "Error", "Could not find the correct window")
Else
    ; Send some text directly to this window's edit control
    ControlSend($handle, "", "", !f")

Something like that

Edited by Sardith

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Link to comment
Share on other sites

Well to take care of the window thing, you could use WinGetHandle.

$handle = WinGetHandle("Title name", "text")
If @error Then
    MsgBox(4096, "Error", "Could not find the correct window")
Else
    ; Send some text directly to this window's edit control
    ControlSend($handle, "", "", !f")

and one other note, when you add code to your posts on the forum, you can surround them with [ code][ /code] or [ autoit][ /autoit] tags to seperate them from the regular text in the post. it helps readability.

to the top of your code to all for the searching of child windows...

Link to comment
Share on other sites

Thank you cameronsdad : D for helping me write my first autoit script. I also found out how to write it in a whole different way, but it took more typing time. : ), again Thanks alot!!!

Here is the code just incase anyone needs it.

DriveMapAdd("o:","share folder",8,"domain/user","password")

dim $tab, $enter, $space 
$tab="{tab}" 
$space="{space}"
$enter="{enter}"
$alt="{alt}" 
;running command
Run("cmd.exe") 
send($space)
send("O:" & $enter)
;activating patchlink
send("UpdateAgent.msi" & $enter )
;exiting cmd  
send("exit" & $enter )

;waiting for patchlink to initialize - only one window title
WinWaitActive ("PatchLink Update Agent - InstallShield Wizard")

Send($alt)
Send("!N")
Send("!A")
Send("!N")
Send("!N")
;sends the install command
send("!i")

WinWait("PatchLink Update Agent - InstallShield Wizard","Finish",Opt("WinsearchChildren",1))
ControlClick("PatchLink Update Agent - InstallShield Wizard","","&Finish")

WinWaitClose("PatchLink Update Agent - InstallShield Wizard")
    DriveMapDel("o:")
Edited by new2autoit
Link to comment
Share on other sites

Thank you cameronsdad : D for helping me write my first autoit script. I also found out how to write it in a whole different way, but it took more typing time. : ), again Thanks alot!!!

Here is the code just incase anyone needs it.

DriveMapAdd("o:","share folder",8,"domain/user","password")

dim $tab, $enter, $space 
$tab="{tab}" 
$space="{space}"
$enter="{enter}"
$alt="{alt}" 
;running command
Run("cmd.exe") 
send($space)
send("O:" & $enter)
;activating patchlink
send("UpdateAgent.msi" & $enter )
;exiting cmd  
send("exit" & $enter )

;waiting for patchlink to initialize - only one window title
WinWaitActive ("PatchLink Update Agent - InstallShield Wizard")

Send($alt)
Send("!N")
Send("!A")
Send("!N")
Send("!N")

;sends the install command
send("!i")
Send("!F")
WinWait("PatchLink Update Agent - InstallShield Wizard","Finish",Opt("WinsearchChildren",1))
ControlClick("PatchLink Update Agent - InstallShield Wizard","","&Finish")

WinWaitClose("PatchLink Update Agent - InstallShield Wizard")
    DriveMapDel("o:")
good job man! always glad to help.
Link to comment
Share on other sites

Also forgot to mention and I'm not sure if I can explain it right but here goes.

When running the script above couple times, it would crash and burn, and I'll receive my send (ex. send("hello") )

where ever the cursor is at in the Scite, but after a log off it works just fine. Is this a bug? or is it that i'm just a newbie and forgot something. Does this happen to anyone else?

Edited by new2autoit
Link to comment
Share on other sites

Also forgot to mention and I'm not sure if I can explain it right but here goes.

When running the script above couple times, it would crash and burn, and I'll receive my send (ex. send("hello") )

where ever the cursor is at in the Scite, but after a log off it works just fine. Is this a bug? or is it that i'm just a newbie and forgot something. Does this happen to anyone else?

Not sure if this answers your question, but you do have an error in your syntax for controlclick:
ControlClick("PatchLink Update Agent - InstallShield Wizard","","&Finish")
Should be:

...wizard","&Finish",ControlID)
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Also forgot to mention and I'm not sure if I can explain it right but here goes.

When running the script above couple times, it would crash and burn, and I'll receive my send (ex. send("hello") )

where ever the cursor is at in the Scite, but after a log off it works just fine. Is this a bug? or is it that i'm just a newbie and forgot something. Does this happen to anyone else?

Not sure exactly what you mean, but your script has some bugs in it. I see little need to try to automate a command prompt so why even try the unreliable attempt. Just run msiexec to run msi files.

Try this:

Opt("WinsearchChildren", 1)

If DriveMapAdd("o:", "share folder", 8, "domain/user", "password") Then
    ;running command
    Run('msiexec /i o:\UpdateAgent.msi')
    
    ;waiting for patchlink to initialize - only one window title
    If WinWaitActive("PatchLink Update Agent - InstallShield Wizard", "", 60) Then
        
        Send("{alt}")
        Send("!N")
        Send("!A")
        Send("!N")
        Send("!N")
        ;sends the install command
        Send("!i")
        
        WinWait("PatchLink Update Agent - InstallShield Wizard", "Finish")
        ControlClick("PatchLink Update Agent - InstallShield Wizard", "", "&Finish")
        
        WinWaitClose("PatchLink Update Agent - InstallShield Wizard")
    EndIf
    DriveMapDel("o:")
EndIf

:D

@jefhal

Using a Controls text is acceptable for the ControlID parameter. :D

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