Sign in to follow this  
Followers 0
jmvp

Can I use AutoIt to stop the user from clicking and typing on the form I'm automating with my AutoIt script?

7 posts in this topic

Problem: When the AutoIt script runs and the user get's ahead of it by clicking on the buttons or entering the data on the text boxes, it changes the order in which the script was expecting to perform, therefore, messing up the whole automation.

Can I use AutoIt to stop the user from clicking and typing on the form I'm automating?

AutoItSetOption( "WinSearchChildren",1) 
AutoItSetOption( "WinTitleMatchMode",3)
WinClose("ALLDATA")

run("MYPROGRAM")

AdlibRegister("MyAdlib",1000)

$name=@ComputerName
$box_num = StringInStr($name, "SHOP1")

sleep(1000) ;milliseconds

WinWait("ALLDATA Repair - InstallShield Wizard","Repair on your computer")
if WinExists("ALLDATA Repair - InstallShield Wizard", "Repair on your computer") Then
   WinSetOnTop("ALLDATA Repair - InstallShield Wizard","Repair on your computer",1)
   WinActivate ("ALLDATA Repair - InstallShield Wizard","Repair on your computer")
   sleep(1000)
   send("!n")
EndIf

WinWait("ALLDATA Repair - InstallShield Wizard","License Agreement")
if WinExists("ALLDATA Repair - InstallShield Wizard","License Agreement") Then
   WinSetOnTop("ALLDATA Repair - InstallShield Wizard","License Agreement",1)
   WinActivate ("ALLDATA Repair - InstallShield Wizard","License Agreement")
   sleep(1000)
   Send("!a")
   Send("!n")
EndIf

WinWait("ALLDATA Repair - InstallShield Wizard","Product Registration")
if WinExists("ALLDATA Repair - InstallShield Wizard","Product Registration") Then
   WinSetOnTop("ALLDATA Repair - InstallShield Wizard","Product Registration",1)
   WinActivate ("ALLDATA Repair - InstallShield Wizard","Product Registration")
   Send("Company Name")
   Send("{TAB}")
   Send("Phone Number")
   Send("{TAB}")
   Send("Address")
   Send("{TAB}")
   Send("!n")
Endif

WinWait("ALLDATA Repair - InstallShield Wizard","InstallShield Wizard Complete")
if WinExists("ALLDATA Repair - InstallShield Wizard","InstallShield Wizard Complete") Then
   WinSetOnTop("ALLDATA Repair - InstallShield Wizard","InstallShield Wizard Complete", 1)
   WinActivate("ALLDATA Repair - InstallShield Wizard","InstallShield Wizard Complete")
   Send("{SPACE}")
   Send("{ENTER}")
EndIf

WinWait("ALLDATA")
if WinExists("ALLDATA") Then
   WinSetOnTop("ALLDATA","",1)
   WinActivate ("ALLDATA")
   sleep(1000)
   Send("!d")
   sleep(1000)
   Send("s")
   sleep(1000)
   Send("u")
   sleep(1000)
   
if WinExists("Add Subscription and Option Codes") Then
 WinSetOnTop("Add Subscription and Option Codes","", 1)
 WinActivate("Add Subscription and Option Codes")
 sleep(1000)
 Send("{TAB}")
 $file = FileOpen("file path",0)
 While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
WinWaitActive("Add Subscription and Option Codes")
Send($line)
Send("!v")
Send("{ENTER}")
 WEnd

 FileClose($line)
 WinClose("Add Subscription and Option Codes")
EndIf

   WinSetOnTop("ALLDATA","",1)
   WinActivate("ALLDATA")
   Send("!d")
   Send("s")
   Send("i")
   sleep(1000)
   $file = FileOpen("filepath",2)
   Local $text = WinGetText ("[active]", "")
   FileWrite($file, $text)
   FileClose($file)
   Send("{ENTER}")

   WinSetOnTop("ALLDATA","",1)
   WinActivate("ALLDATA")
   WinClose("ALLDATA")
EndIf

exit
;#########################################################
Func MyAdlib()

   if WinExists("ALLDATA", "Security Initialization Failed") then
 WinSetOnTop("ALLDATA", "Security Initialization Failed",1)
 WinActivate("ALLDATA", "Security Initialization Failed")
 Send("{ENTER}")
 MsgBox(16,"ERROR","Security Initialization Failed. Please call the Help Desk at ext ####.")
   EndIf

   if WinExists("ALLDATA", "WARNING #2022") then
 WinSetOnTop("ALLDATA", "WARNING #2022",1)
 WinActivate("ALLDATA", "WARNING #2022")
 Send("!n") 
   EndIf
   

   
   If WinExists("ALLDATA Repair - InstallShield Wizard" ,"Repair in the following folder") Then
 WinSetOnTop("ALLDATA Repair - InstallShield Wizard" ,"Repair in the following folder",1)
 WinActivate("ALLDATA Repair - InstallShield Wizard" ,"Repair in the following folder")
 Send("!n")
   EndIf

   If WinExists("ALLDATA Repair is currently running") Then
 WinSetOnTop("ALLDATA Repair is currently running","", 1)
 WinActivate("ALLDATA Repair is currently running")
 Send("{ENTER}")
   EndIf

   If WinExists("Attach Subscription Key") Then
 WinSetOnTop("Attach Subscription Key","",1)
 WinActivate("Attach Subscription Key")
 Send("{ENTER}")
   EndIf

   If WinExists("Flash") Then
 WinSetOnTop("Flash","", 1)
 WinActivate("Flash")
 Send("!c")
   EndIf

   If WinExists("Hardware Installation") Then
 WinSetOnTop("Hardware Installation","",1)
 WinActivate("Hardware Installation")
 Send("!c")
   EndIf

   If WinExists("Self-Registration Error") Then
 WinSetOnTop("Self-Registration Error","",1)
 WinActivate("Self-Registration Error")
 Send("{ENTER}")
   EndIf

   If WinExists("Tip of the Day") Then
 WinSetOnTop("Tip of the Day","", 1)
 WinActivate("Tip of the Day")
 Send("!c")
   EndIf

EndFunc

Share this post


Link to post
Share on other sites



blockinput(1)


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Three suggestions:

1. Avoid "Send()" like the plague. use controlsend() to hook directly into the control.

2. Use BlockInput as boththose suggest. .

3. Seeing how it is an installshield package, see if the package support command line switches. You may be able to do the install silently and not have to worry about the user messing up the install.

Share this post


Link to post
Share on other sites

Run it behind the 'covers' (behind desktop).  Use PAEXEC, or a scheduled task.


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.

Share this post


Link to post
Share on other sites

Thanks everyone. I'll try your suggestions.

Boththose, I can't see your answer.

Share this post


Link to post
Share on other sites

BLOCKINPUT(1)

2 people like this

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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  
Followers 0