Hallo an alle AutoIt-User,
bin nun auch seit etwa 2 Wochen an AutoIt dran. Vieles konnte durch lesen der Hilfedatei (Englisch & Deutsch) als auch durch die Suchfunktion hier im Forum beantwortet werden. Im Hilfetext gab es ein kleines Codebeispiel was mir den Anreiz zu meinem Skript gab. Da meine Programmier- bzw. ScriptingSkills eher unterirdischer Natur sind, wollte ich mir doch einmal eine objektive Meinung der Fachmänner...äh...und -frauen einholen. Wie gesagt, ich bin in diesem Thema ziemlich unbedarft, aber gewillt, diesen Umstand endlich zu beenden.
Es ist zwar nicht das längste Skript und durchaus noch ausbaufähig, aber immerhin ein Anfang...
Spoiler anzeigen
#include <GuiConstants.au3>
#include <ie.au3>
;==============================================
; Rufumleitung - GUI
;==============================================
Global $oIE, $oForm, $oField, $Progress_1, $sConVal
[/autoit] [autoit][/autoit] [autoit]GuiCreate("Rufumleitung", 390, 90,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
[/autoit] [autoit][/autoit] [autoit]$Button_1 = GuiCtrlCreateButton("Aktivieren", 10, 20, 80, 30)
$Button_2 = GuiCtrlCreateButton("Deaktivieren", 110, 20, 80, 30)
$Button_3 = GUICtrlCreateButton("Status", 220, 20, 80, 30)
$Progress_1 = GuiCtrlCreateProgress(10, 60, 180, 10)
$Combo_1 = GuiCtrlCreateCombo("Rufnummer#", 220, 60, 150, 30) ; noch nicht aktiv
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_1
Login()
Act()
Logout()
Case $msg = $Button_2
Login()
Deact()
Logout()
Case $msg = $Button_3
Login()
Status()
Logout()
EndSelect
WEnd
Exit
#region - Funktionen
Func Login()
GUICtrlSetData($Progress_1, 10)
; Seite öffnen
$oIE = _IECreate("https://rufumleitung/logon.asp", 0, 0, 0)
;Zertifikatspopup bestätigen
For $i=0 To 4 Step 1
If WinExists("Sicherheitshinweis") Then
ControlClick("Sicherheitshinweis", "", "Button1")
EndIf
Sleep(250)
Next
;Warten bis Seite geladen
_IELoadWait($oIE)
GUICtrlSetData($Progress_1, 15)
If IsObj($oIE) Then
;Setzen des Benutzernamens, anhand der Formularfelder
$oForm = _IEFormGetObjByName($oIE, "theForm")
$oUsername = _IEFormElementGetObjByName($oForm, "userID")
_IEFormElementSetValue($oUsername, "USER")
GUICtrlSetData($Progress_1, 20)
;Siehe oben
$oPasswd = _IEFormElementGetObjByName($oForm, "password")
_IEFormElementSetValue($oPasswd, "PASSWORD")
;Bestätigen
_IEFormSubmit($oForm)
GUICtrlSetData($Progress_1, 25)
;Setzen des Profils, anhand des Formularfeldes
$oForm = _IEFormGetObjByName($oIE, "theForm")
$oProfile = _IEFormElementGetObjByName($oForm, "deviceID")
_IEFormElementSetValue($oProfile, "{deviceID}")
;Timer, bis Profil geladen
Sleep(2500)
;Navigiere zur Rufumleitung
_IENavigate($oIE, "https://rufumleitung/callforward.asp")
GUICtrlSetData($Progress_1, 50)
;Formular deklarieren - Checkbox
$oForm = _IEFormGetObjByName($oIE, "callForwardForm")
;Formular deklarieren - Rufnummernfeld
$oField = _IEFormElementGetObjByName($oForm, "destination_{deviceID}")
$sConVal = _IEFormElementGetValue($oField)
GUICtrlSetData($Progress_1, 60)
Else
MsgBox(48,"Fehler", "Es konnte keine Instanz geöffnet werden.")
EndIf
Return
EndFunc
Func Logout()
GUICtrlSetData($Progress_1, 90)
_IENavigate($oIE, "https://rufumleitung/logoff.asp")
GUICtrlSetData($Progress_1, 100)
_IEQuit($oIE)
GUICtrlSetData($Progress_1, 0)
Return
EndFunc
Func Status()
If $sConVal == 0 Then
MsgBox(32, "Status", "Es ist zur Zeit keine Rufumleitung aktiv.")
Else
MsgBox(32, "Status", "Anrufe sind auf folgende Rufnummer umgeleitet: '" & $sConVal & "'")
EndIf
Return
EndFunc
Func Act()
If $sConVal == 0 Then
;Rufnummer eingeben
_IEFormElementSetValue($oField, "Rufnummer#")
Click()
MsgBox(0, "Umleitung", "Aktiviert")
Else
MsgBox(48, "Achtung,...", "es wurde bereits auf die '" & $sConVal & "' umgeleitet!")
EndIf
Return
EndFunc
Func Deact()
If $sConVal == 0 Then
MsgBox(48, "Achtung...", "es ist keine Rufumleitung vorhanden!")
Else
Click()
MsgBox(0, "Umleitung", "Deaktiviert")
EndIf
Return
EndFunc
Func Click()
;Checkbox aktivieren, IEAction - Mausklick
;Checkbox auswählen, keine Funktion
;Leerzeichen senden, keine Funktion
$oClick = _IEFormElementGetObjByName($oForm, "forward_{deviceID}")
_IEAction($oClick, "click")
_IEFormSubmit($oForm)
GUICtrlSetData($Progress_1, 70)
Return
EndFunc
#endregion
Für konstrukive Kritik oder Änderungsvorschläge wäre ich äußerst dankbar!