Hallo Zusammen,
ich sitze aktuell an einem Projekt, in dem es darum geht, unsere einzelnen Autologin Scripte (per Webdriver) in eine GUI zu bündeln.
Nun habe ich aus vorherigen Scripten folgenden Quellcode erstellt. Die Daten dazu kommen aktuell aus einer DB, im Beispiel mal eine MS Access.
Lässt sich der Bereich der Erstellung der dyn. Button schöner umsetzen?
Ein Besonderheit gibt es noch, wenn in Col3 (GUI) = 1 steht, soll vorher noch eine zweite GUI erstellt werden mit einem Dropdown Menü, da es bei verschiedenen Webseiten mehr wie 1 Zugang, also pro Agenturnummer gibt, aber das wäre erst der nächste Schritt.
AutoIt
#AutoIt3Wrapper_UseX64=y
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <Array.au3>
#include <D:\Scripte\MS_AccessCom\Access UDF\Access_UDF.au3>
local $URL_Array_pos
;--------- MSAccess DB ------------
$dbname = @ScriptDir & "\Data.accdb"
$tblname001 = "Websites"
Local $Connection = _Start_Connection($dbname & ";")
Local $URL_Array = _Get_Records("SELECT * FROM " & $tblname001 & " ;")
_Close_Connection()
IF _ArrayMax($URL_Array, 0, 1) = "" Then
Exit
Else
;MsgBox(0,"1",$DB_Array[1][0])
EndIf
_ArrayDisplay($URL_Array)
;~ For $i = 1 To UBound($URL_Array) -1
;~ MsgBox(0,"",$URL_Array[$i][1])
;~ Next
$GUI = GUICreate("Website AutoLogin " & FileGetVersion(@ScriptName), 474, 257)
GUISetState(@SW_SHOW)
#Region ### Create Button dynamisch
$iCols = UBound($URL_Array)
;definiere dyn. Button
Local $Button[$iCols]
$Btn_Start = GUICtrlCreateDummy()
;MsgBox(0,"",$Btn_Start)
For $t = 1 to UBound($URL_Array) -1
;-----------------------------------------------------------------
; Button1
IF $t = 1 Then
$Button[$t] = GUICtrlCreateButton($URL_Array[$t][1], 30, 30, 130, 25)
GUICtrlSetCursor($Button[$t], 0)
$B1 = 1
EndIf
; Button2
IF $t = 2 Then
$Button[$t] = GUICtrlCreateButton($URL_Array[$t][1], 170, 30, 130, 25)
GUICtrlSetCursor($Button[$t], 0)
$B2 = 1
EndIf
; Button3
IF $t = 3 Then
$Button[$t] = GUICtrlCreateButton($URL_Array[$t][1], 310, 30, 130, 25)
GUICtrlSetCursor($Button[$t], 0)
$B3 = 1
EndIf
;-----------------------------------------------------------------
; Button4
IF $t = 4 Then
$Button[$t] = GUICtrlCreateButton($URL_Array[$t][1], 30, 70, 130, 25)
GUICtrlSetCursor($Button[$t], 0)
$B4 = 1
EndIf
; Button5
IF $t = 5 Then
$Button[$t] = GUICtrlCreateButton($URL_Array[$t][1], 170, 70, 130, 25)
GUICtrlSetCursor($Button[$t], 0)
$B5 = 1
EndIf
; Button6
IF $t = 6 Then
$Button[$t] = GUICtrlCreateButton($URL_Array[$t][1], 310, 70, 130, 25)
GUICtrlSetCursor($Button[$t], 0)
$B6 = 1
EndIf
;-----------------------------------------------------------------
; Button7
IF $t = 7 Then
$Button[$t] = GUICtrlCreateButton($URL_Array[$t][1], 30, 110, 130, 25)
GUICtrlSetCursor($Button[$t], 0)
$B7 = 1
EndIf
; Button8
IF $t = 8 Then
$Button[$t] = GUICtrlCreateButton($URL_Array[$t][1], 170, 110, 130, 25)
GUICtrlSetCursor($Button[$t], 0)
$B8 = 1
EndIf
; Button9
IF $t = 9 Then
$Button[$t] = GUICtrlCreateButton($URL_Array[$t][1], 310, 110, 130, 25)
GUICtrlSetCursor($Button[$t], 0)
$B9 = 1
EndIf
;-----------------------------------------------------------------
; Button10
IF $t = 10 Then
$Button[$t] = GUICtrlCreateButton($URL_Array[$t][1], 30, 150, 130, 25)
GUICtrlSetCursor($Button[$t], 0)
$B10 = 1
EndIf
; Button11
IF $t = 11 Then
$Button[$t] = GUICtrlCreateButton($URL_Array[$t][1], 170, 150, 130, 25)
GUICtrlSetCursor($Button[$t], 0)
$B11 = 1
EndIf
; Button12
IF $t = 12 Then
$Button[$t] = GUICtrlCreateButton($URL_Array[$t][1], 310, 150, 130, 25)
GUICtrlSetCursor($Button[$t], 0)
$B12 = 1
EndIf
;-----------------------------------------------------------------
Next
;_ArrayDisplay($Button)
$Btn_End = GUICtrlCreateDummy()
;MsgBox(0,"",$Btn_End)
#EndRegion ### Create Button
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_MINIMIZE
Case $GUI_EVENT_CLOSE
Exit
Case $Btn_Start To $Btn_End
;MsgBox(0, "Test", GUICtrlRead($Msg))
IF GUICtrlRead($Msg) = "Autoit" Then
_search()
;MsgBox(0,"Array Position",$URL_Array_pos)
MsgBox(0,"URL",$URL_Array[$URL_Array_pos][2])
EndIf
IF GUICtrlRead($Msg) = "Heise" Then
_search()
;MsgBox(0,"Array Position",$URL_Array_pos)
MsgBox(0,"URL",$URL_Array[$URL_Array_pos][2])
EndIf
IF GUICtrlRead($Msg) = "Test1" Then _search()
IF GUICtrlRead($Msg) = "Test2" Then _search()
IF GUICtrlRead($Msg) = "Test3" Then _search()
IF GUICtrlRead($Msg) = "Test4" Then _search()
IF GUICtrlRead($Msg) = "Test5" Then _search()
IF GUICtrlRead($Msg) = "Test6" Then _search()
IF GUICtrlRead($Msg) = "Test7" Then _search()
EndSwitch
WEnd
Func _search()
$URL_Array_pos = _ArraySearch($URL_Array, GUICtrlRead($Msg), 0, 0, 0, 0, 1, 1)
;MsgBox(0,"Array Position",$URL_Array_pos)
EndFunc
Alles anzeigen
Danke und viele Grüße
Marcel