Jump to content

Help opening Network Connection Properties.


 Share

Recommended Posts

Ok, here's my problem first. I have a different static IP for at college and at home, so I have to change between the two manually alot. To stop some of the hassle, i'm trying to write an autoit program to do it for me.

The only problems I'm having...

Opening the Local Area Connection Properties box.

Clicking the Internet Protocol (TCP/IP) and then clicking properties.

Changing the IP and clicks within those all work fine.

I'm using the newest Beta.

ControlClick("Local Area Connection Properties", "", 16012,332,181)

ControlClick("Local Area Connection Properties", "", 16012,332,181)

ControlClick("Local Area Connection Properties", "", 16012,108,164)

That should send clicks to those x,y inside the box, but it doesn't for some reason. I use the same code under the properties box where it asks for the ip settings and it works there, but won't work under the Local Area Connection Properties box.

I could go with manual down,down,tab,enters, but that's pretty sloppy.

So I need help with clicking inside the LACP box and opening the LACP properties box.

Link to comment
Share on other sites

See this post:

http://www.autoitscript.com/forum/index.ph...st&p=296303

or any of the other 100s of posts about netsh.exe

If you still prefer to script the OS's GUIs, then read the help file for ControlClick - it does not use (x,y) coordinates as you show in your sample code.

The new beta uses x,y with control click but it must only work with certain instances.

Link to comment
Share on other sites

Thanks for the info - I'll look into the new beta ControlClick.

You can change this code for the NIC of interest:

AutoItSetOption("WinWaitDelay", 1)  ;(milliseconds)
AutoItSetOption("TrayIconDebug", 1)  ;0-off

Run("rundll32.exe shell32,Control_RunDLL ncpa.cpl")
WinWait("Network Connections")
WinActivate("Network Connections")
WinWaitActive("Network Connections")

$ret1 = ControlListView("Network Connections", "", "SysListView321", "FindItem", "Wireless Network Connection")
If @error = 1 Then MsgBox(0, "AutoIt", "Control could not be found.")
If $ret1 = -1 Then
    MsgBox(0, "AutoIt", 'No connection named "Wireless Network Connection" could be found.')
    Exit
EndIf

$ret2 = ControlListView("Network Connections", "", "SysListView321", "Select", $ret1)
If @error = 1 Then MsgBox(0, "AutoIt", "Control could not be found.")
If $ret2 = -1 Then
    MsgBox(0, "AutoIt", 'No connection named "Wireless Network Connection" could be found.')
    Exit
EndIf

$ret3 = ControlFocus("Network Connections", "", $ret2)
If $ret3 = 0 Then
    MsgBox(0, "AutoIt", 'No connection named "Wireless Network Connection" could be found.')
    Exit
EndIf

WinWait("Network Connections","Wireless")
WinActivate("Network Connections","Wireless")
WinWaitActive("Network Connections","Wireless")
Send("!{ENTER}")

WinWait("Wireless Network Connection Properties", "General")
WinActivate("Wireless Network Connection Properties", "General")
WinWaitActive("Wireless Network Connection Properties", "General")
$item_number = ControlListView("Wireless Network Connection Properties", "General", 16012, "FindItem", "Internet Protocol (TCP/IP)")
If $item_number = -1 Then
 MsgBox(0, "AutoIt", "Item not found")
 Exit
EndIf
ControlListView("Wireless Network Connection Properties", "General", 16012, "Select", $item_number)
ControlSend("Wireless Network Connection Properties", "General", 16012, "!r")

WinWait("Internet Protocol (TCP/IP) Properties", "General")
WinActivate("Internet Protocol (TCP/IP) Properties", "General")
WinWaitActive("Internet Protocol (TCP/IP) Properties", "General")
ControlCommand("Internet Protocol (TCP/IP) Properties", "General", "Button3", "Check", "")

;Static IP
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit4", "192")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit3", "168")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit2", "0")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit1", "2")

;Subnet Mask
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit8", "255")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit7", "255")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit6", "255")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit5", "0")

;Default Gateway
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit12", "192")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit11", "168")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit10", "0")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit9", "1")


ControlCommand("Internet Protocol (TCP/IP) Properties", "General", "Button6", "Check", "")

;DNS 1
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit16", "192")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit15", "168")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit14", "0")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit13", "1")

;DNS 2
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit20", "192")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit19", "168")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit18", "0")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit17", "12")

ControlClick("Internet Protocol (TCP/IP) Properties", "General", "Button8") ;enter

;turn off Windows control of wireless card
WinWait("Wireless Network Connection Properties", "General")
WinActivate("Wireless Network Connection Properties", "General")
WinWaitActive("Wireless Network Connection Properties", "General")

ControlCommand("Wireless Network Connection Properties", "General", "SysTabControl321", "TabRight", "")
If @error = 1 Then MsgBox(0, "AutoIt", "Control could not be found.")

If WinWait("Wireless Network Connection Properties", "Wireless Networks", 1) = 1 Then
 WinActivate("Wireless Network Connection Properties", "Wireless Networks")
 WinWaitActive("Wireless Network Connection Properties", "Wireless Networks")

 ControlCommand("Wireless Network Connection Properties", "Wireless Networks", "Button1", "UnCheck", "")
 ControlClick("Wireless Network Connection Properties", "Wireless Networks", "Button11")
Else
 ControlClick("Wireless Network Connection Properties", "Advanced", "Button9")
EndIf

WinClose("Network Connections")

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

The new beta uses x,y with control click but it must only work with certain instances.

Does the new beta also allow you to skip optional parms

ControlClick ( "title", "text", controlID, button, clicks, x, y)

ControlClick("Local Area Connection Properties", "", 16012,332,181)

I have not read the entire new help file yet....

Edit: Under Function Notes in the help file for 3.2.3.2 (beta):

Many functions contain optional parameters that can be omitted. If you wish to specify an optional parameter, however, all preceding parameters must be specified!

Edit2: xsnow, I did not mean for any of my posts in this thread to sound rude - I truly was asking if the latest beta would allow you to skip optional parm - although I could not see how that could be done... and I do appreciate you teaching me about the new ControlClick.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Ok, here's my problem first. I have a different static IP for at college and at home, so I have to change between the two manually alot. To stop some of the hassle, i'm trying to write an autoit program to do it for me.

The only problems I'm having...

Opening the Local Area Connection Properties box.

Clicking the Internet Protocol (TCP/IP) and then clicking properties.

Changing the IP and clicks within those all work fine.

I'm using the newest Beta.

ControlClick("Local Area Connection Properties", "", 16012,332,181)

ControlClick("Local Area Connection Properties", "", 16012,332,181)

ControlClick("Local Area Connection Properties", "", 16012,108,164)

That should send clicks to those x,y inside the box, but it doesn't for some reason. I use the same code under the properties box where it asks for the ip settings and it works there, but won't work under the Local Area Connection Properties box.

I could go with manual down,down,tab,enters, but that's pretty sloppy.

So I need help with clicking inside the LACP box and opening the LACP properties box.

Here is a script which I think might do exactly what you want. It was the first thing I used Autoit for and I would do it differntly now but it was quite useful for me.

You will need to read the comments in the script at the start to see how to use it. Hope it makes sense.

and this is the icon I used for the compiled exe

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Does the new beta also allow you to skip optional parms

ControlClick ( "title", "text", controlID, button, clicks, x, y)

ControlClick("Local Area Connection Properties", "", 16012,332,181)

I have not read the entire new help file yet....

Edit: Under Function Notes in the help file for 3.2.3.2 (beta):

Many functions contain optional parameters that can be omitted. If you wish to specify an optional parameter, however, all preceding parameters must be specified!

Edit2: xsnow, I did not mean for any of my posts in this thread to sound rude - I truly was asking if the latest beta would allow you to skip optional parm - although I could not see how that could be done... and I do appreciate you teaching me about the new ControlClick.

Hey, I got the script working. I had to change a few things since I always plug in, so I had to use Local Area Connection in some spots but she works nicely.

Thanks.

Now I have to make a GUI for 2 different settings that will just run 2 different functions, won't be to hard.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...