Seid gegrüßt!
Ich bin ja nun schon relativ lange mit AutoIt 'unterwegs', aber habe gerade was die Kontrolle von GUIs angeht, während das Script normal weiterlaufen soll noch immer meine Probleme.
Bisher habe ich das Problem immer umgangen und das Script entsprechend angepasst, aber nun eben nicht mehr.
Das Script ist ein Updater für meine zahlreichen Tools hier in der Firma. Es ist eine UDF die in das jeweilige Script mit eingebunden wird und dann nur mit wenigen Funktionsaufrufen gesteuert wird (den Rest macht die UDF selbst, da die Tools & Server jeweils die selbe Struktur haben).
Problem: Kontrolle des Updater-GUIs (Buttons, Labels etc. klicken), während der Updater im Hintergrund seine Arbeit verrichtet.
Das GUI wird von der UDF gestellt und gesteuert, nicht von dem Mainscript.
Ich hatte mich damals schon damit beschäftigt und mit Adlib rumgespielt und auch damals etwas funktionstüchtiges, einfaches zusammenbekommen (klickbare Buttons, obwohl das Script in einer Schleife irgendwas anderes gemacht hat).
Keine Ahnung wie ich es damals gemacht habe, aber ich probiere hier schon eine Weile rum und hab schon gut gegoogelt, aber naja... vielleicht kann mir einer von euch das fehlende Bauteil verraten.
Was ich im Script mache ist, zunächst das GUI per Funktion zu erstellen (klappt) und im Anschluss per Adlib die "master function" (_lib_update_master) aufzurufen, welche den Update Prozess steuert.
Während diese Funktion arbeitet, soll das GUI jedoch weiterhin ansprechbar sein... was es nicht ist.
Genauer gesagt, möchte ich das $GUI_B_Patchnotes (Label) anklickbar ist und dann als Event (_lib_changelog()) eine Datei öffnet.
Wo liegt der (Denk-)Fehler?
Zum Testen des Scripts:
Ordnerstrktur erstellen: %userprofile%\DublinTools\CTI\download
In \download die Datei "CTI.notes" mit min 1 Zeile erstellen, sowie die Datei "changelog.txt".
Source vom Updater (bei weitem noch nicht vollständig):
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
;~ Opt("GUIOnEventMode", 1)
Global $GUI_W_Splash, $GUI_W_Image, $GUI_Progress_Main, $GUI_Progress_Sub, $GUI_L_Headline, $GUI_L_Patchnotes, $GUI_B_Patchnotes, $GUI_Box_Patchnotes, $GUI_L_Progress_Main, $GUI_L_Progress_Sub
Global $int_BetaUpdate = 0, $int_ProjectName, $int_Logfile
Global $upd_PathServer, $upd_PathClient, $upd_PathRestart, $upd_VersServer, $upd_VersClient, $upd_FileInformation, $upd_FileNotes, $upd_FileRads, $upd_ArrayInformation, $upd_ArrayNotes, $upd_DataNotes
$upd_PathServer = "\\riot3\File Transfer\DublinTools\"
$upd_PathClient = @UserProfileDir & "\DublinTools\"
$upd_VersClient = FileGetVersion(@ScriptFullPath)
Func _lib_update_GuiCreate()
$GUI_W_Splash = GUICreate("Updater", 650, 391, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_POPUP,$WS_GROUP))
GUISetFont(9, 400, 0, "Cambria")
$GUI_W_Image = GUICtrlCreatePic("C:\Users\dbusch\Desktop\Tools\CTI\assets\splash.jpg", 0, 0, 668, 404, BitOR($SS_NOTIFY,$WS_GROUP))
$GUI_Progress_Sub = GUICtrlCreateProgress(24, 315, 270, 11, BitOR($PBS_SMOOTH,$WS_BORDER))
$GUI_Progress_Main = GUICtrlCreateProgress(24, 350, 270, 11, BitOR($PBS_SMOOTH,$WS_BORDER))
$GUI_L_Headline = GUICtrlCreateLabel("", 24, 24, 271, 18)
$GUI_L_Patchnotes = GUICtrlCreateLabel("Changelog Preview", 24, 65, 175, 15)
$GUI_B_Patchnotes = GUICtrlCreateLabel("full changelog", 220, 65, 75, 15, $WS_BORDER)
$GUI_Box_Patchnotes = GUICtrlCreateLabel("", 24, 80, 271, 202, $WS_BORDER)
$GUI_L_Progress_Sub = GUICtrlCreateLabel("", 24, 300, 270, 15)
$GUI_L_Progress_Main = GUICtrlCreateLabel("", 24, 335, 270, 15)
GUICtrlSetBkColor($GUI_L_Headline, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor($GUI_L_Patchnotes, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor($GUI_Box_Patchnotes, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor($GUI_B_Patchnotes, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor($GUI_L_Progress_Main, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor($GUI_L_Progress_Sub, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState($GUI_Box_Patchnotes, $GUI_HIDE)
GUICtrlSetState($GUI_L_Patchnotes, $GUI_HIDE)
GUICtrlSetState($GUI_B_Patchnotes, $GUI_HIDE)
GUICtrlSetColor($GUI_L_Headline, 0xBF9B3B) ; gold
GUICtrlSetColor($GUI_L_Patchnotes, 0xBF9B3B) ; gold
GUICtrlSetColor($GUI_Box_Patchnotes, 0x3061BE) ; blue
GUICtrlSetColor($GUI_B_Patchnotes, 0x3061BE) ; blue
GUICtrlSetColor($GUI_L_Progress_Main, 0xBF9B3B) ; gold
GUICtrlSetColor($GUI_L_Progress_Sub, 0xBF9B3B) ; gold
GUICtrlSetFont($GUI_L_Headline, 12, 800, 0, "Cambria")
GUICtrlSetFont($GUI_L_Patchnotes, 10, 800, 0, "Cambria")
;~ GUICtrlSetFont($GUI_Box_Patchnotes, 9, 400, 0, "Cambria")
;~ GUICtrlSetOnEvent($GUI_B_Patchnotes, "_lib_changelog")
GUISetState(@SW_SHOW)
EndFunc
_lib_update_GuiCreate()
AdlibRegister('_adlib')
While 1
$msg = GUIGetMsg()
If $msg = $GUI_B_Patchnotes Then _lib_changelog()
Sleep(100)
WEnd
Func _adlib()
_lib_update_Master("CTI", 1)
;~ AdlibUnRegister("_adlib")
EndFunc
Func _lib_changelog()
ShellExecute($upd_PathClient & "\download\changelog.txt")
EndFunc
Func _lib_update_Master($pProjectName, $pUpdateStep, $pBetaUpdate = 0)
Local $tUpdate = 0
$int_ProjectName = $pProjectName
$int_BetaUpdate = $pBetaUpdate
$int_Logfile = $pProjectName & ".log"
$upd_PathClient &= $int_ProjectName
$upd_PathServer &= $int_ProjectName
$upd_FileInformation = $int_ProjectName & ".update" ; update information
$upd_FileNotes = $int_ProjectName & ".notes" ; patchpreview
$upd_FileRads = $int_ProjectName & ".rads" ; tool structure information (for RADS check)
If $int_BetaUpdate = 1 Then $upd_PathServer &= "\Beta"
GUICtrlSetData($GUI_L_Headline, "Launching " & $int_ProjectName)
[/autoit] [autoit][/autoit] [autoit]Select
Case $pUpdateStep = 1
If Not FileExists($upd_PathClient & "\download") Then DirCreate($upd_PathClient & "\download")
_lib_update_GuiSetState(11)
_lib_update_getInformation()
_lib_update_GuiSetState(12)
$tUpdate = _lib_update_checkVersion()
If $tUpdate = 1 Then
_lib_update_GuiSetState(13)
_lib_update_getNotes()
_lib_update_GuiSetState(14)
;~ _lib_update_getRads()
Else
_lib_update_GuiSetState(50) ; no update / launch tool
Return
EndIf
EndSelect
EndFunc
Func _lib_update_getInformation()
Local $answer
If FileExists($upd_PathClient & "\" & $upd_FileInformation) Then
_FileReadToArray($upd_PathClient & "\" & $upd_FileInformation, $upd_ArrayInformation)
Else
FileCopy($upd_PathServer & "\" & $upd_FileInformation, $upd_PathClient & "\" & $upd_FileInformation, 1)
_FileReadToArray($upd_PathClient & "\" & $upd_FileInformation, $upd_ArrayInformation)
EndIf
If Not IsArray($upd_ArrayInformation) Then MsgBox(48, "ERROR", "ERROR - No Information Array!")
EndFunc
Func _lib_update_getNotes()
Local $answer, $i
If FileExists($upd_PathClient & "\download\" & $upd_FileNotes) Then
_FileReadToArray($upd_PathClient & "\download\" & $upd_FileNotes, $upd_ArrayNotes)
Else
FileCopy($upd_PathServer & "\" & $upd_FileNotes, $upd_PathClient & "\download\" & $upd_FileNotes, 1)
_FileReadToArray($upd_PathClient & "\download\" & $upd_FileNotes, $upd_ArrayNotes)
EndIf
If Not IsArray($upd_ArrayNotes) Then
MsgBox(48, "ERROR", "ERROR - No Patchnotes Array!")
Else
For $i=1 To $upd_ArrayNotes[0] Step 1
$upd_DataNotes &= $upd_ArrayNotes[$i] & @CRLF
Next
GUICtrlSetData($GUI_Box_Patchnotes, $upd_DataNotes)
GUICtrlSetState($GUI_Box_Patchnotes, $GUI_SHOW)
GUICtrlSetState($GUI_L_Patchnotes, $GUI_SHOW)
GUICtrlSetState($GUI_B_Patchnotes, $GUI_SHOW)
EndIf
EndFunc
Func _lib_update_GuiSetState($pState)
Select
Case $pState = 11
GUICtrlSetData($GUI_Progress_Sub, 5)
GUICtrlSetData($GUI_Progress_Main, 2)
GUICtrlSetData($GUI_L_Progress_Sub, "retrieving information")
GUICtrlSetData($GUI_L_Progress_Main, "checking for updates")
Case $pState = 12
GUICtrlSetData($GUI_Progress_Sub, 40)
GUICtrlSetData($GUI_Progress_Main, 10)
GUICtrlSetData($GUI_L_Progress_Sub, "comparing versions")
Case $pState = 13
GUICtrlSetData($GUI_Progress_Sub, 60)
GUICtrlSetData($GUI_Progress_Main, 15)
GUICtrlSetData($GUI_L_Progress_Sub, "retrieving changelogs")
Case $pState = 14
GUICtrlSetData($GUI_Progress_Sub, 80)
GUICtrlSetData($GUI_Progress_Main, 20)
GUICtrlSetData($GUI_L_Progress_Sub, "retrieving update details")
Case $pState = 50
GUICtrlSetData($GUI_Progress_Sub, 100)
GUICtrlSetData($GUI_Progress_Main, 100)
GUICtrlSetData($GUI_L_Progress_Sub, "Done")
GUICtrlSetData($GUI_L_Progress_Main, "Launching " & $int_ProjectName)
Sleep(2500)
EndSelect
EndFunc
Func _lib_update_checkVersion()
Local $answer
;~ $upd_VersServer = $upd_ArrayInformation[1]
$upd_VersServer = 1
If $upd_VersServer > $upd_VersClient Then
$answer = MsgBox(64+4, "Updater", "Update available!" & @CRLF & @CRLF & _
"Targeted Tool: " & $int_ProjectName & @CRLF & _
"Your Version: " & $upd_VersClient & @CRLF & _
"Server Version: " & $upd_VersServer & @CRLF & @CRLF & _
"Proceed and update to latest version?")
If $answer = 6 Then
Return 1
Else
Return 0
EndIf
EndIf
EndFunc