Hallo allerseis, ich habe noch mal eine ganz allgemeine Frage. Nehmen wir an, ich habe eine EinstellungsGUI und ich möchte mit einer Filebox einen standarmässig, per ini eingestellten Pfad ändern. Wie bekomme ich es hin, dass der Inhalt im Inputfeld auch entsprechend synchronisiert wird, nachdem eine Auswahl getroffen wurde. Das Scriptfragment schaut so aus:
AutoIt
#include <Array.au3>
#include <Constants.au3>
#include <ScreenCapture.au3>
#include <File.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIError.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <StringSize.au3>
#include <InetConstants.au3>
Opt("TrayMenuMode",1) ; Hide default tray menu items
Opt("TrayAutoPause", 0); This will allow you to click on the TrayIcon without pause the script
TraySetIcon("Shell32.dll",-27)
TraySetClick(8) ;only show the menu when right clicking
#Tray Tip
TraySetToolTip ("Tomis USB FormaterTool")
Global $checkPathF = _PathFull("usf.ini", @ScriptDir)
;Traymenu
$Settings= TrayCreateItem("Einstellungen")
$exititem = TrayCreateItem("Exit")
;Function CALLS
Firststartcheck()
startcheck()
;CHECKS------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------
;Erster Prgrammstart
Func Firststartcheck()
If FileExists($checkPathF) = 1 Then ;Checkdatei auf Existenz prüfen
; Nichts tun
Else
_FileCreate($checkPathF) ;ini Datei erstellen
;Standard Settings setzen
$Path1 = "c:\"
IniWrite("USF.ini", "settings", "Path1", $Path1) ; StandardSetting LangFormat
FileCreateShortcut(@ScriptFullPath, @StartupDir & "\USB-Formatter.lnk", @ScriptDir, "", "AutoIT Script Description")
EndIf
EndFunc ;==>Firststartcheck
;------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------
Func startcheck();Auslesen Ini Datei
;Einlesen der Parameter aus IniDatei
Global $Path1 = IniRead("USF.ini","settings","Path1", "")
EndFunc
;------------------------------------------------------------------------------------------------------------
;MAIN LOOP---------------------------------------------------------------------------------------------------
While 1
Switch TrayGetMsg() ;switch seems nicer in this case
Case 0
ContinueLoop
Case $TRAY_EVENT_PRIMARYDOWN ;reaction to left clicking
Case $settings
TrayItemSetState($settings,$TRAY_UNCHECKED) ;stop the automated (un)checking when clicked
Settings()
Case $exititem
;GuiCtrlSetImage($exititem, "shell32.dll", 4)
ExitLoop
EndSwitch
WEnd
Exit
;------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------
Func Settings()
;Create a GUI with various controls.
Local $hGUI = GUICreate("SETTINGS", 400, 260)
Local $idInputPath1 = GUICtrlCreateInput($Path1, 170, 90, 150, 20)
local $idButton_Req1 = GUICtrlCreateButton("", 320, 90, 20, 20)
; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)
; Loop until the user exits.
While 1
Switch GUIGetMsg($hGUI)
Case $GUI_EVENT_CLOSE, $idOK
startcheck()
ExitLoop
Case $idButton_Req1
Local Const $sMessage = "Ordner wählen"
Local $sFileSelectFolder = FileSelectFolder($sMessage, "")
If @error Then
MsgBox($MB_SYSTEMMODAL, "", "NKein ordner gewählt.")
Else
MsgBox($MB_SYSTEMMODAL, "", "YFolgender Ordner wurde gewählt:" & @CRLF & $sFileSelectFolder)
EndIf
EndSwitch
WEnd
GUIDelete($hGUI)
EndFunc ;==>Settings
;-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Alles anzeigen