Jump to content

AutoIT questions


kaje_ovo

Recommended Posts

OK, I have a problem in need of a working solution. I am trying to install Microsoft Update (MU) in unattended fashion. I drop the MU shortcut in the OEM structure so that it appears in the Start Menu, register the MUweb.dll, and all should be good. But not so. For some reason, it takes about five attempts to get the site working correctly on my testbed machine. For example, I click the MU link but then receive the error detailed HERE by raduking. Boardbabe notes that this can occur three or more times before the darned thing works properly. In my experience it can happen as many as five times, with the sixth time being the charm. I suppose the problem is caused by simply registering the .dll without benefit of using the IE interface to do it - takes it a few attempts to get in synch. Here's what I have so far:

Run( @ScriptDir & "\MUstart.cmd", "", @SW_HIDE)
WinWait("Microsoft Update")
Sleep(15000)
Send("{ENTER}")
Sleep(3000)
Send("{ENTER}")
Sleep(3000)
If WinExists("Automatic Updates") Then
Send("{!y}")
Sleep(1000)
EndIf
ProcessClose("iexplore.exe")

The batch launches MU (sorry, but I am not a COMSPEC guy). An annoyingly long sleep command is used to allow MU to fully load. Two keystrokes take care of the "Start Now" and "Continue" nag screens. Then we check for the error window and respond "yes" if it exists before closing IE. I run this five times for good measure.

Here's my question: Anybody have a "Do...Until" loop statement snippet handy that would do this in a clean fashion? We want this thing to loop until the error window is no longer present. Then the script would exit. In a perfect world. :lol:

@MHz/Nologic: you guys should get a publisher and get published. A book o' AutoIt snippets would be nice, under 300 pages, small type, great for bathroom reading. :P I'd buy it.

Edited by blinkdt
Link to comment
Share on other sites


Run( @ScriptDir & "\MUstart.cmd", "", @SW_HIDE)
WinWait("Microsoft Update")
Sleep(15000)
Send("{ENTER}")
Sleep(1500)
Send("{ENTER}")
If WinExists("Automatic Updates") Then
Send("{!y}")
Sleep(1000)
EndIf
ProcessClose("iexplore.exe")

Here's my question: Anybody have a "Do...Until" loop statement snippet handy that would do this in a clean fashion? We want this thing to loop until the error window is no longer present. Then the script would exit. In a perfect world. :lol:

; Using Do...Until
Do
Send("{!y}")
Sleep(1000)
Until Not WinExists("Automatic Updates")

; Using While...WEnd
While WinExists("Automatic Updates")
Send("{!y}")
Sleep(1000)
WEnd

; Using For...Next (only 5 loops)
For $i = 1 To 5
If WinExists("Automatic Updates") Then
Send("{!y}")
Sleep(1000)
Else
ExitLoop
EndIf
Next

Choose from 1 of the 3 loops shown.

The For...Next shown will save you being trapped in an endless loop if it fails to close the window.

Do not have to worry about turning tabs into spaces for code indenting. The IPB forum software destroys the viewing of both types of indenting. :(

Not sure about publishing a book as of yet. :P

Edit: Code indent check

Edit2: Tab and space indenting is working now. Thanks to the person who fixed this. :)

Edited by MHz
Link to comment
Share on other sites

Thanks, MHz! Let me incorporate your thoughts into a larger script and see what happens in the days ahead. I will post back the result.

As an aside, are there any AutoIt books out there that you recommend?

Link to comment
Share on other sites

Only good reference to AutoIt is the helpfile included with it. Everybody seems too busy making scripts to stop and write a devoted book for AutoIt. You could check the AutoItWiki for alittle more. There is also a Unattended Wiki here that has installation scripts.

Link to comment
Share on other sites

I sow where is problem in my previus app.

I

Send($text)

and that text have special chars.! I have to made

Send($text, 1)

and the it worked just fine.!

Now still it's question.!

How to made always on top.!

So when installing only interupt can be CANCEL of Scrip Exit.!

And when open oether app this installing will still RUN and Installing.!

Link to comment
Share on other sites

From where AutoIT gets it's template. So I can add few lines into AutoIT new script template.!

----

Formated text like this

-----

Line One

This Line I Need

----

Then I make TAB and Select text

When I make

$var = ControlCommand ( "Key", "", "Edit1", "GetSelected", "" )

.

.

ControlCommand ( "Untitled -", "", "Edit1", "EditPaste", "" & $var )

It Paste into Notepad "Line One"

But I need "Not This Line I need"

A general AllUsers template is in @Windows & '\ShellNew\Template.au3' but you should make your own in @UserProfileDir & '\templates' and create a template.au3 in there. Add your own special something in it. My template is currently blank as Scite4AutoIt3 can fill in the information too easy with abbreviations.

Edited by MHz
Link to comment
Share on other sites

Thank you.!!!

Oh on my previus question.! I make it on top with

WinSetState. Yes it's on top.!

But let say if I sending something to Notepad and then I click on something else let say Exploler. Notepad is OnTop but now all send commandes are send there when I click on Explorer.

That is what I need, so that you can let say searching to explorer and Send($text) is sending into notepad (it can be on top, This is just if I installing on some oether computer or give him unattended.exe and he is clicking on computer while this working then script will not do it's job).

Link to comment
Share on other sites

It is never 100% sure of success as to running a script while someone is also actively using the computer at the same time. You can increase the chances of success alot by using the Control* functions.

Here is a Notepad example using ControlSend() to send directly to the edit control. No need for a window to be active with ControlSend().

$text1 = 'This is a string of text'
$text2 = 'Control functions are more reliable to use'
Run('Notepad')
WinWait('Untitled')
WinSetTitle('Untitled', '', 'Notepad 1')
WinWait('Notepad 1')
Run('Notepad')
WinWait('Untitled')
WinSetTitle('Untitled', '', 'Notepad 2')
WinWait('Notepad 2')
Sleep(1000)
ControlSend('Notepad 1', '', 'Edit1', $text1)
Sleep(1000)
ControlSend('Notepad 2', '', 'Edit1', $text2)
While WinExists('Notepad 1') And WinExists('Notepad 2')
WinActivate('Notepad 1')
Sleep(1000)
WinActivate('Notepad 2')
Sleep(1000)
WEnd

Link to comment
Share on other sites

  • 6 months later...

$SF_1 = "Everest2.80.EXE"				  ;		Setup File Name
$DL_1 = @ProgramFilesDir & "\Everest" ; Location For Installation
$SM_1 = "\Everest" ; Location For Start Menu

Run ( $SF_1 )

$Title_1 = "Setup - EVEREST Ultimate Edition"

; Welcome
WinWaitActive ( $Title_1 , "Welcome" )
ControlClick ( $Title_1 , "" , "TButton1" )

; License
WinWaitActive ( $Title_1 , "License" )
Send("!a")
Send("!n")

; Destination Location
WinWaitActive ( $Title_1 , "Select Destination Location" )
ControlSetText ( $Title_1 , "" , "TEdit1" , $DL_1 )
ControlClick ( $Title_1 , "" , "TButton3" )

; Start Menu Location
WinWaitActive ( $Title_1 , "Select Start Menu Folder" )
ControlSetText ( $Title_1 , "" , "TEdit2" , $SM_1 )
ControlClick ( $Title_1 , "" , "TButton4" )

; Additional Tasks
WinWaitActive ( $Title_1 , "Select Additional Tasks" )
ControlClick ( $Title_1 , "" , "TButton4" )

; Ready to install
WinWaitActive ( $Title_1 , "Ready to Install" )
ControlClick ( $Title_1 , "" , "TButton4" )

;Installation completed
WinWaitActive ( $Title_1 , "The application may be launched by selecting the installed icons")
Send ("{SPACE}")
Send ("{TAB}")
Send ("{TAB}")
Send ("{SPACE}")
Send ("!f")

Why it doesn't change Destination Location and Start Menu Location?

What's wrong?

When should I use $Title_1 (variables, parameters, constants... whatever it's called?) and when plain text?

Please help me, I have the problem with the locations with every single installer I try and this is driving me crazy :wacko:

Link to comment
Share on other sites

What would be the command to bring focus to the desktop?

(I want to make a programme to toggle hide and show desktop icons)

I tried using mouse movement and commands to click on to the desktop, and then use further command using keyboard send keys, but in case another window is already open, I am unable to get past it and autoit command halts with error.

Can someone suggest?

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...