Jump to content
Sign in to follow this  

Newbie question

Recommended Posts

Never coded anything in autoit before but I've read about it so figured it was the way to go for this simple task.

I just need to make a basic script for my OpenVPN.

All I want it to do it is to simply click reconnect then fill password and click OK

$var_1 = "MyUsername"
$var_2 = "MyPassword"
MsgBox( 0, "Reconnecting OpenVPN", "Trying to reconnect openVPN", 30)
ControlClick("OpenVPN Connection (anonine)", "", "[ID:164]")
Sleep(2000) ;two seconds
ControlSend("OpenVPN - User Authentication", "", "[Class:Edit1]", "$var_1")
ControlSend("OpenVPN - User Authentication", "", "[Class:Edit2]", "$var_2")
Sleep(2000) ;two seconds
ControlClick("OpenVPN - User Authentication", "", "[ID:1]")
MsgBox( 0, "Reconnecting OpenVPN", "Done!", 30)

>>>> Window <<<<
Title:  OpenVPN - User Authentication
Class:  #32770
Position:   677, 365
Size:   246, 129
Style:  0x94C00A44
ExStyle:    0x00010100
Handle: 0x000000000014048C

>>>> Control <<<<
Class:  Edit
Instance:   1
ClassnameNN:    Edit1
Advanced (Class):   [CLASS:Edit; INSTANCE:1]
ID: 181
Position:   90, 10
Size:   141, 20
ControlClick Coords:    39, 16
Style:  0x50010080
ExStyle:    0x00000204
Handle: 0x0000000000310496

>>>> Mouse <<<<
Position:   132, 51
Cursor ID:  0
Color:  0xFFFFFF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<

Share this post

Link to post
Share on other sites

For a first script that's one of the best I've seen to date, but you don't describe your problem.

One thing that seems off is that you seem to use the CLASSNN, but specify CLASS for your edits.

If your issue is that the username and password are not being set, try to replace [Class:Edit1] and [Class:Edit2] with:



[CLASSNN:Edit1] and [CLASSNN:Edit2]

Share this post

Link to post
Share on other sites

Sorry, totally slipped my mind to describe my problem, but you are correct.

It was not filling in the username and password but [CLASS:Edit; INSTANCE:1] worked like a charm!

The variables did not work though, but easy fix was to change them to the real username and password.

It was just writing in $var_1 & $var_2. Really don't care if it uses them or not.

It's not like I plan to expand the script or anything.

Thanks a bunch Tvern! :graduated:

Share this post

Link to post
Share on other sites

When you describe variables with "" they don't get used, whatever goes inside the "" is just output as text, if you want to use the variables, then just take the "" out :(

For instance:

msgbox(0,"test","$variable1") ; gives a messagebox with the text $variable1
msgbox(0,"test",$variable1) ; gives a messagebox in which the text is the actual content of the variable

With "" the variable itself gets recognized as text, instead of it's contents :graduated:

EDIT: typos... must wake up...

Edited by DaRkf0x

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...