Black Obsidian Posted February 20, 2006 Share Posted February 20, 2006 Hi folks, I'm writing a script which basically logs a user into a pre-defined server. The software in question operates thus:- Software starts. User must press "Next" User is prompted for a Username and Pass. User Presses "Next" At this point the user is presented with a number of radio boxes which define the server onto which they will log. Now I know I can simply use the full command:- ;ControlCommand("WindowName", "Server", "Button1", "Check", "+")However it'd be far more beneficial to use .ini files to prevent the need for a whole new script for each user on each server. I've used:- $user = IniRead("Settings.ini", "Username", "Username", "Not Found") $pass = IniRead("Settings.ini", "Password", "Password", "Not Found") Send($user) MouseClick("left",650,415,1) Send($pass) To define the username and password for a user and I'd like to add a Server to this so that a user can simply change their user/pass and server choice in one single .ini file. Settings.ini [username]Username=user1 [Password] Password=pass1 [server] Server=$server1 server1.ini [server1]server1="Application", "server1", "Button1", "Check", "+" and in the main script I've used:- $server1 = IniRead("server1.ini", "Server1", "Server1", "Not Found") $server = IniRead("Settings.ini", "Server", "Server", "Not Found") ControlCommand($server) It's probably something really simple but any ideas where I'm going wrong please? Link to comment Share on other sites More sharing options...
Valuater Posted February 20, 2006 Share Posted February 20, 2006 its hard to tell exactly what you are going to do butt... i would use Dim $Server_num, $Max_servers = 6 iniread-User iniread-pass $server_num = iniread-server chkbx1 = create chkbx if $server_num = 1 then setstate( -1, checked) chkbx2 = create chkbx if $server_num = 2 then setstate( -1, checked) ... etc ;do the normal checking for which chkbx is checked iniwrite the $server_num ;use the server number for the servers 1 to 6 call that function Server1 or server2 etc 8) Link to comment Share on other sites More sharing options...
rudika Posted February 20, 2006 Share Posted February 20, 2006 Hi folks,I'm writing a script which basically logs a user into a pre-defined server. The software in question operates thus:- Software starts.User must press "Next"User is prompted for a Username and Pass.User Presses "Next"At this point the user is presented with a number of radio boxes which define the server onto which they will log.Now I know I can simply use the full command:- However it'd be far more beneficial to use .ini files to prevent the need for a whole new script for each user on each server.I've used:- To define the username and password for a user and I'd like to add a Server to this so that a user can simply change their user/pass and server choice in one single .ini file.Settings.iniserver1.iniand in the main script I've used:- It's probably something really simple but any ideas where I'm going wrong please?moin, moin...D!Maybe I don´t understand what you want work out, but I´m missing the WinWaitActive or something like that and maybe the MouseCoordMode, too. Perhaps is ControlClick is a better way to press button?GreetsRudika [font="Comic Sans Ms"][center]Powered by AutoIt3http://www.wik-eric.de/zips/Synchro2.2.2-4free.zip[/center][/font] Link to comment Share on other sites More sharing options...
Black Obsidian Posted February 20, 2006 Author Share Posted February 20, 2006 its hard to tell exactly what you are going to do butt... i would useDim $Server_num, $Max_servers = 6iniread-Useriniread-pass$server_num = iniread-serverchkbx1 = create chkbxif $server_num = 1 then setstate( -1, checked)chkbx2 = create chkbxif $server_num = 2 then setstate( -1, checked)... etc;do the normal checking for which chkbx is checkediniwrite the $server_num;use the server number for the servers 1 to 6call that function Server1 or server2etc8)Thanks for the reply, much appreciated!It's not quite what I'm looking for, I should have mentioned... I'm basically writing a script to log onto a server using an already built piece of software, not a GUI I created.The software itself is as defined above, thus I need to automate the procedure of logging in. Link to comment Share on other sites More sharing options...
rudika Posted February 20, 2006 Share Posted February 20, 2006 Thanks for the reply, much appreciated!It's not quite what I'm looking for, I should have mentioned... I'm basically writing a script to log onto a server using an already built piece of software, not a GUI I created.The software itself is as defined above, thus I need to automate the procedure of logging in.certainly, and there must be started a GUI where the user has to enter name and password and for the window the script must wait before it send the values. [font="Comic Sans Ms"][center]Powered by AutoIt3http://www.wik-eric.de/zips/Synchro2.2.2-4free.zip[/center][/font] Link to comment Share on other sites More sharing options...
Valuater Posted February 20, 2006 Share Posted February 20, 2006 maybe just one question for the user $user = @username #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes, No, and Cancel, Icon=Info If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(67,"Auto-Login Settings","Yes = Use Settings for " & $user & " " & @CRLF & @CRLF & "No = Configure User Information" & @CRLF & @CRLF & "Cancel = Exit Auto-Login" & @CRLF) Select Case $iMsgBoxAnswer = 6;Yes ;Run Login Case $iMsgBoxAnswer = 7;No ; call the settings GUI Case $iMsgBoxAnswer = 2;Cancel ; Exit EndSelect #EndRegion --- CodeWizard generated code End --- 8) Link to comment Share on other sites More sharing options...
Black Obsidian Posted February 20, 2006 Author Share Posted February 20, 2006 certainly, and there must be started a GUI where the user has to enter name and password and for the window the script must wait before it send the values. It does wait Here is the full script:- expandcollapse popup; ---------------------------------------------------------------------------- ; AutoIt Version: 3 ; Author: ; Script Function: ; Log in to Software and select Server. ; ---------------------------------------------------------------------------- #NoTrayIcon ; Runs Software and make sure it's the active window. Run("C:\Program Files\Software\Software\Software.exe") WinWaitActive("Software") Sleep(500) ; Clicks "Next", fills out User Details from "Settings.ini" and submits them. MouseClick("left",752,742,1) Sleep(500) MouseClick("left",650,385,1) Sleep(500) $user = IniRead("Settings.ini", "Username", "Username", "Not Found") $pass = IniRead("Settings.ini", "Password", "Password", "Not Found") Send($user) Sleep(500) MouseClick("left",650,415,1) Sleep(500) Send($pass) Sleep(500) MouseClick("left",752,742,1) Sleep(3000) ; Clicks "Finish" after successful login. MouseClick("left",752,742,1) Sleep(2000) ; Selects Server. $Liffe = IniRead("server1.ini", "server1", "server1", "Not Found") $server = IniRead("Settings.ini", "Server", "Server", "Not Found") ControlCommand($server) [color=#33FF33];ControlCommand("Software", "server1", "Button1", "Check", "+")[/color] ; Clicks "Next" Sleep(500) MouseClick("left",752,742,1) Sleep(2000) If I strip out all the section on "selects server" and un-semicolon the green text it works fine but by having an .ini file parameter I can centralise the info instead of needing to create loads of similar scripts with roughly the same content. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now