Jump to content

Recommended Posts

Posted

Hello,

I am creating a script to remote force logoff computers.

This part is working:

$data = InputBox("Test", "Enter computername.")

if $data = "*" Then

MsgBox (16, "Info", "Not allowed" & @CRLF & @CRLF & "Restart the program" ,30)

Else

ShellExecute("psshutdown.exe", "-o -f -accepteula -u administrator -p 1234567 \\" & $data, @SW_MINIMIZE)

EndIf

Now i want to add a dropdown list with computers from a .ini file of .txt file. And also is not allowed to enter a computername by typing...

Can anybody help me out?

Thx

Posted

Just look at building your own gui with a ComboBox.

Give it a try by looking at the examples in the helpfile.

Jos

Done that :graduated:

Look:

#include <File.au3>

#include <Array.au3>

#include <GUIConstants.au3>

#include <GUIConstantsEx.au3>

;read file and load it to array

Dim $aPcs

_FileReadToArray("wks.txt",$aPCs)

;Create window

$Form1 = GUICreate("MCH Remote Force Logoff", 300, 139)

$Combo1 = GUICtrlCreateCombo(" -Computer Selecteren- ", 40, 23, 229, 125)

$Check = GUICtrlCreateButton("Force Logoff", 96, 76, 113, 35)

;Load Pc's into combobox

For $i=1 To $aPcs[0]

GUICtrlSetData($Combo1,$aPCs[$i] & "|")

Next

;Show GUI

GUISetState(@SW_SHOW)

;Main Loop

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Check

ShellExecute("psshutdown.exe", "-o -f -accepteula -u administrator -p 123456 \\" & GUICtrlRead($Combo1))

EndSwitch

WEnd

Now only i need a way to protect the combo box for manual typing info in the box... i cannot find that :S. I have tried to work with $CBS_DROPDOWNLIST but where i have to put this?

Posted

oke, i understand but how can i protect the combobox for manual typing data?

Is there another way? this is my first script.

Thx for your help

Posted (edited)

Have you tried what Jos has recommended before re-asking your question? To use $CBS_DROPDOWNLIST in the style parameter of the GUICtrlCreateCombo function call? You will need to add #include <ComboConstants.au3> to your include list to do this. So, if you've already done this, what happened?

Edited by Fubarable

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
×
×
  • Create New...