Ich würde es so machen:
Spoiler anzeigen
#include <ComboConstants.au3>
#include <GuiConstantsEx.au3>
#include <GUIConstants.au3>
; update-funktion
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Global $hFile = FileOpen(@DesktopDir & "\Test.txt", 1)
Global $sUserName = "benutzer"
Global $sDomain = "domäne"
Global $sPassword = "passwort"
Global $sStartDatei
GUICreate("Test", 250, 200)
[/autoit] [autoit][/autoit] [autoit]GUICtrlCreateLabel("Benutzername:", 20, 10)
Global $cInput_1 = GUICtrlCreateInput("", 20, 25, 200, 20)
GUICtrlCreateLabel("Programm:", 20, 60)
Global $cProgram = GUICtrlCreateCombo("", 20, 75, 200, 20, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Firefox|Chrome|IE")
GUICtrlCreateLabel("Grund:", 20, 110)
Global $cInput_3 = GUICtrlCreateInput("", 20, 125, 200, 20)
Global $cSave = GUICtrlCreateButton("Speichern", 80, 160, 80, 25)
[/autoit] [autoit][/autoit] [autoit]GUISetState()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]While 1
If GUICtrlRead($cInput_1) <> "" And GUICtrlRead($cProgram) <> "" And GUICtrlRead($cInput_3) <> "" Then
If BitAND(GUICtrlGetState($cSave), $GUI_DISABLE) Then GUICtrlSetState($cSave, $GUI_ENABLE)
Else
If BitAND(GUICtrlGetState($cSave), $GUI_ENABLE) Then GUICtrlSetState($cSave, $GUI_DISABLE)
EndIf
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
FileClose($hFile)
Exit
Case $cSave
$sTime = @YEAR & "-" & @MON & "-" & @MDAY & "/" & @HOUR & ":" & @MIN & ":" & @SEC
FileWriteLine($hFile, $sTime & ":" & @TAB & GUICtrlRead($cInput_1) & @TAB & GUICtrlRead($cProgram) & @TAB & GUICtrlRead($cInput_3))
RunAs($sUserName, $sDomain, $sPassword, 0, $sStartDatei)
;RunAs($sUserName, $sDomain, $sPassword, 0, @AutoItExe & ' /AutoIt3ExecuteLine "ShellExecute(''' & $commands[$i] & ''')"', @SystemDir)
;RunAsWait($sUserName, $sDomain, $sPassword, 0, $sStartDatei)
Case $cProgram
Switch GUICtrlRead($cProgram)
Case "Firefox"
$sStartDatei = "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
Case "Chrome"
$sStartDatei = "C:\Users\Thomann\AppData\Local\Google\Chrome\Application\chrome.exe"
Case "IE"
$sStartDatei = "C:\Program Files\Internet Explorer\iexplore.exe"
EndSwitch
EndSwitch
WEnd