Hi people!!
I have the following script to automate an formulary fill process. This code is not actually de aplication itself but contains some samples of what the application is supposed to do.
Code:
;----------------manufacturer selection variables-------------
BrandChoice1 = |LG|Samsung|Phillips
BrandChoice2 = |Ford|Fiat|GM
BrandChoice3 = |HP|IBM|ASUS
;----------------tv screen size selection variables-----------
TVChoice1 = |19`"|21`"|29`"
TVChoice2 = |14`"|15`"|19`"
TVChoice3 = |29`"|32`"|40`"
;----------------car model selection variables----------------
CarChoice1 = |Fusion|Ka|Ecosport
CarChoice2 = |Uno|Punto|Idea
CarChoice3 = |Astra|Meriva|Vectra
;----------------computer model selection variables----------------
ComputerChoice1 = |Compaq|Pavilion|Pavilion Slimline
ComputerChoice2 = |Lenovo 3010|Lenovo 3020|Lenovo 4000
ComputerChoice3 = |Notebook W2V|Notebook W2JC|Notebook W2P
;----------------location selection variables----------------
LOCATION = |SAO PAULO|NEW YORK|TOKIO
;----------------GUI------------------------------------------
Gui, Add, Text, x21 y9 w200 h16, Please select an item from the Wish List:
Gui, Add, ListBox, x21 y25 w200 h90 vProduct gWishList AltSubmit, Digital TV|Car|Computer ; select product type
;
Gui, Add, Text, x21 y114 w200 h16, Select a manufacturer:
Gui, Add, DropDownList, x21 y130 w200 vManufacturer gManufacturer AltSubmit, ; select manufacturer
;
Gui, Add, Text, x21 y159 w200 h16, Select a model:
Gui, Add, DropDownList, x21 y175 w200 vMake , ; select model
;
Gui, Add, Button, x21 y207 w100 h30 , Submit
Gui, Show, w242 h255
return
WishList:
Gui, Submit, NoHide
Choice := BrandChoice%product% ; establishes the manufacturer dropdown
GuiControl, , manufacturer, %choice% ; puts that dropdown in place
GuiControl, , Make, | ; empties the model dropdown in case it contains data
return
Manufacturer:
Gui, Submit, NoHide
if Product = 1 ; will run if Digital TV was chosen
{
Model := TVChoice%Manufacturer%
GuiControl, , Make, %Model%
return
}
else if Product = 2 ; will run if Car was chosen
{
Model := CarChoice%Manufacturer%
GuiControl, , Make, %Model%
return
}
else if Product = 3 ; will run if Computer was chosen
{
Model := ComputerChoice%Manufacturer%
GuiControl, , Make, %Model%
return
}
ButtonSubmit:
Gui, Submit, NoHide
if Make = Lenovo 4000
{
Gosub Lenovo4000
Return
}
else if Make = Lenovo 3020
{
MsgBox, Lenovo 3020 has chosen!!!
Return
}
else if Make = Lenovo 3010
{
MsgBox, Lenovo 3010 has chosen!!!
Return
}
Lenovo4000:
Gui, 2:Add, Text, x26 y27 w100 h20 , Name
Gui, 2:Add, Edit, x26 y57 w250 h20 vName ,
Gui, 2:Add, Text, x26 y87 w100 h20 , Mail Address
Gui, 2:Add, Edit, x26 y117 w250 h20 vMail ,
Gui, 2:Add, Text, x26 y147 w100 h20 , Location
Gui, 2:Add, DropDownList, x26 y177 w250 vLocationchoice , %LOCATION%
Gui, 2:Add, Button, x26 y227 w100 h30 , Submit
Gui, 2:Show, x300 y278 h277 w305, Form Data
Return
2ButtonSubmit:
Gui, Submit, NoHide
WinActivate ahk_class Notepad
SendInput %Locationchoice%{Enter}
SendInput %Name%{Enter}
SendInput %Mail% {Enter}
MsgBox, Personal data Submited!!!!
return
GuiEscape:
GuiClose:
ExitApp
All functions are working correctly. The trouble is occurring when i do the following:
choose the options COMPUTER>IBM>LENOVO 4000 than a second GUI appear. Inserting data and submitting to fill a notepad file is ok too. But when i close the second GUI and try to reselect the same path (COMPUTER>IBM>LENOVO 400) again an error message appears: The same variable cannot be used.... Specifically vName.
What am i doin wrong? Is there a way to fix it?