Jump to content

Combo box problem


Dylan
 Share

Recommended Posts

Hi everyone, this is my first post here. I've been reading the forums quite a bit and using them to solve my problems but this time I couldn't find the problem:

I'm working at a computer help desk at a university and a huge chunk of my time is taken up setting up laptops to connect to our network. A friend showed me autoit and I've been making a script to automatically set these computers up but am having an annoying problem:

Under the Authentication tab of your wired network connection in the combobox I want to select PEAP. For some reason the first time it's run on most machines the combo box drops down but nothing is selected and it just sits there (hard to explain but you'll see if you run it). But as soon as you drag the mouse over the box it suddenly selects peap and continues to run.

I don't want to use the whole string because I do a lot of chinese, polish, spanish, french, german laptops etc and I want it to work for all languages when it's finished.

The script is just for wired connections at the moment and I've cut this one short to get rid of stuff that happens after the problem point. If anyone would like to see/use the whole thing in another situation I'll put the whole file up.

The code for selecting PEAP is from another post on the forums.

CODE

$sp = @OSServicePack

$sp2= "Service Pack 2"

if $sp <> $sp2 Then

MsgBox(0, "Service Pack 2 Required", "Please install service pack 2 before continuing")

Exit

EndIf

; Turn on auto detect settings in browsers

;Run("auto_detect_on.exe")

; Set Wireless Zero Configuration Service to Automatic and start it then open Network Connections Window

;Run("run.bat")

Run(@ComSpec & " /c " & 'ncpa.cpl', "C:\WINDOWS\system32\dllcache", @SW_HIDE)

;Wait for Network Connections Window to be ready for input

Do

Until WinActive("Network Connections")

;Find Local Area Connection and select it - keeps trying until connection is selected

Do

$ConnectionIndex = ControlListView("Network Connections", "", "SysListView321", "FindItem", "Local Area Connection")

ControlListView("Network Connections", "", "SysListView321", "Select", $ConnectionIndex, "")

$getSelected = ControlListView("Network Connections", "", "SysListView321", "IsSelected", $ConnectionIndex)

Until $getSelected = 1

;Enter properties window for connection

Send("!{Enter}")

;Wait for Connection properties window to be ready and tab right to Authentication

Do

Until WinExists("Local Area Connection Properties")

WinActivate("Local Area Connection Properties")

ControlCommand("Local Area Connection Properties", "", "SysTabControl321", "TabRight", "" )

;Select PEAP from the combo box (the problem bit)

$k = 0

While -1

ControlCommand("Local Area Connection Properties", "", "ComboBox1", "ShowDropDown", "")

ControlCommand ("Local Area Connection Properties","", "ComboBox1","SetCurrentSelection",$k)

$index = ControlCommand ("Local Area Connection Properties","","ComboBox1","GetCurrentSelection","")

If ( StringInStr($index,'PEAP')) Then ExitLoop

$k = $k + 1

WEnd

;Uncheck "Authenticate As Computer"

if ControlCommand ("Local Area Connection Properties", "", "Button3", "IsChecked", "1" ) Then

ControlClick("Local Area Connection Properties", "", "Button3")

EndIf

;Hit the properties button to open PEAP Properties

ControlClick("Local Area Connection Properties", "", "Button2")

WinClose("Network Connections")

Any help would be great,

Many thanks.

Link to comment
Share on other sites

instead of

;Select PEAP from the combo box (the problem bit)
$k = 0
While -1
ControlCommand("Local Area Connection Properties", "", "ComboBox1", "ShowDropDown", "")
ControlCommand ("Local Area Connection Properties","", "ComboBox1","SetCurrentSelection",$k)
$index = ControlCommand ("Local Area Connection Properties","","ComboBox1","GetCurrentSelection","")
If ( StringInStr($index,'PEAP')) Then ExitLoop
$k = $k + 1
WEnd

try

;Select PEAP from the combo box (the problem bit)
ControlCommand ("Local Area Connection Properties","", "ComboBox1","SelectString",'PEAP')
Edited by Zedna
Link to comment
Share on other sites

instead of

;Select PEAP from the combo box (the problem bit)
$k = 0
While -1
ControlCommand("Local Area Connection Properties", "", "ComboBox1", "ShowDropDown", "")
ControlCommand ("Local Area Connection Properties","", "ComboBox1","SetCurrentSelection",$k)
$index = ControlCommand ("Local Area Connection Properties","","ComboBox1","GetCurrentSelection","")
If ( StringInStr($index,'PEAP')) Then ExitLoop
$k = $k + 1
WEnd

try

;Select PEAP from the combo box (the problem bit)
ControlCommand ("Local Area Connection Properties","", "ComboBox1","SelectString",'PEAP')

That doesn't seem to work, doesn't SelectString need the full string? I'm trying to just select the string that contains PEAP

Link to comment
Share on other sites

Just to clarify since this is such a weird problem:

The code in my original post works. The only problem is the first time you run it after your computer has started up. The combo box drops down but nothing gets selected, then once you drag the mouse over it, it selects PEAP and continues. Every time you run it after that, even if you change the options it just corrects them.

I don't really want to solve it by moving the mouse over it.

Any suggestions of other ways to select a string containing PEAP from the combobox? Or maybe a way to get some sort of focus on the combobox? I tried using controlfocus with no real success.

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