Sign in to follow this  
Followers 0
Black Obsidian

ControlCommand parameters from .ini file

7 posts in this topic

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?

Share this post


Link to post
Share on other sites



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)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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

server1.ini

and 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?

Greets

Rudika


[font="Comic Sans Ms"][center]Powered by AutoIt3http://www.wik-eric.de/zips/Synchro2.2.2-4free.zip[/center][/font]

Share this post


Link to post
Share on other sites

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)

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.

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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 :o

Here is the full script:-

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

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