AutoBert hat mir im engl. Forum den Hinweis gegegen.
Den Button mit GUICtrlDelete($File_Button) löschen und mit anderem Text erstellen.
Gruß gmmg
AutoBert hat mir im engl. Forum den Hinweis gegegen.
Den Button mit GUICtrlDelete($File_Button) löschen und mit anderem Text erstellen.
Gruß gmmg
Hallo Zusammen,
für ein Projekt benutze ich die MetroGUI UDF.
Hier gibt es leider keine Funktion um den Text eines Buttons zur Laufzeit zu ändern. Das GUICtrlSetData($Button, "text") geht nicht, da der Metro Button per GDIPlus erzeugt wird.
$File_Button = _Metro_CreateButton("Screenshot oder Datei anfügen", 286, 605, 220, 25)
Hier mal das Demo File. Die UDF selbst ist als Attachment angehangen.
; ===============================================================================================================================
; Name ..........: MetroGUI UDF Example
; Version .......: v5.1
; Author ........: BB_19
; ===============================================================================================================================
;!Highly recommended for improved overall performance and responsiveness of the GUI effects etc.! (after compiling):
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /rm /pe
;YOU NEED TO EXCLUDE FOLLOWING FUNCTIONS FROM AU3STRIPPER, OTHERWISE IT WON'T WORK:
#Au3Stripper_Ignore_Funcs=_iHoverOn,_iHoverOff,_iFullscreenToggleBtn,_cHvr_CSCP_X64,_cHvr_CSCP_X86,_iControlDelete
;Please not that Au3Stripper will show errors. You can ignore them as long as you use the above Au3Stripper_Ignore_Funcs parameters.
;Required if you want High DPI scaling enabled. (Also requries _Metro_EnableHighDPIScaling())
#AutoIt3Wrapper_Res_HiDpi=y
; ===============================================================================================================================
#NoTrayIcon
#include "MetroGUI-UDF\MetroGUI_UDF.au3"
#include "MetroGUI-UDF\_GUIDisable.au3" ; For dim effects when msgbox is displayed
#include <GUIConstants.au3>
;=======================================================================Creating the GUI===============================================================================
;Enable high DPI support: Detects the users DPI settings and resizes GUI and all controls to look perfectly sharp.
_Metro_EnableHighDPIScaling() ; Note: Requries "#AutoIt3Wrapper_Res_HiDpi=y" for compiling. To see visible changes without compiling, you have to disable dpi scaling in compatibility settings of Autoit3.exe
;Set Theme
_SetTheme("LightGreen");DarkTeal") ;See MetroThemes.au3 for selectable themes or to add more
;Create resizable Metro GUI
$Form1 = _Metro_CreateGUI("Example", 500, 300, -1, -1, True)
;Add/create control buttons to the GUI
$Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True) ;CloseBtn = True, MaximizeBtn = True, MinimizeBtn = True, FullscreenBtn = True, MenuBtn = True
;Set variables for the handles of the GUI-Control buttons. (Above function always returns an array this size and in this order, no matter which buttons are selected.)
$GUI_CLOSE_BUTTON = $Control_Buttons[0]
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
$GUI_RESTORE_BUTTON = $Control_Buttons[2]
$GUI_MINIMIZE_BUTTON = $Control_Buttons[3]
$GUI_FULLSCREEN_BUTTON = $Control_Buttons[4]
$GUI_FSRestore_BUTTON = $Control_Buttons[5]
$GUI_MENU_BUTTON = $Control_Buttons[6]
;======================================================================================================================================================================
;Create Buttons
$Button1 = _Metro_CreateButton("Button Style 1", 50, 245, 115, 40)
$Button2 = _Metro_CreateButtonEx("Button Style 2", 195, 245, 115, 40)
$Button3 = _Metro_CreateButtonEx2("Button Style 3", 340, 245, 115, 40)
;Create Checkboxes
$Checkbox1 = _Metro_CreateCheckbox("Checkbox 1", 30, 70, 125, 30)
$Checkbox2 = _Metro_CreateCheckboxEx("Checkbox 2", 30, 107, 125, 30)
$Checkbox3 = _Metro_CreateCheckboxEx2("Checkbox 3", 29, 142, 125, 30)
;Set status to checked
_Metro_CheckboxCheck($Checkbox1, True)
_Metro_CheckboxCheck($Checkbox2, True)
_Metro_CheckboxCheck($Checkbox3, True)
;Create 3 Radios that are assigned to Radio Group 1
$Radio1 = _Metro_CreateRadio("1", "Radio 1", 180, 70, 100, 30)
$Radio2 = _Metro_CreateRadio("1", "Radio 2", 180, 110, 100, 30)
$Radio3 = _Metro_CreateRadioEx("1", "Radio 3", 180, 150, 100, 30) ;Style with colored checkmark
_Metro_RadioCheck("1", $Radio1) ;check $Radio1 which is assigned to radio group "1" and uncheck any other radio in group "1"
;Create Toggles
$Toggle1 = _Metro_CreateToggle("Toggle 1", 320, 70, 130, 30)
$Toggle2 = _Metro_CreateToggleEx("Toggle 2", 322, 107, 128, 30)
$Toggle3 = _Metro_CreateOnOffToggle("Enabled", "Disabled", 320, 144, 130, 30) ; Creates a toggle with different texts for on/off. Alternatively you can use _Metro_CreateOnOffToggleEx for the secondary toggle style.
;Create Progressbar
$Progress1 = _Metro_CreateProgress(100, 195, 300, 26)
;Set resizing options for the controls so they don't change in size or position. This can be customized to match your gui perfectly for resizing. See AutoIt Help file.
GUICtrlSetResizing($Button1, 768 + 8)
GUICtrlSetResizing($Button2, 768 + 8)
GUICtrlSetResizing($Button3, 768 + 8)
GUICtrlSetResizing($Checkbox1, 768 + 2 + 32)
GUICtrlSetResizing($Checkbox2, 768 + 2 + 32)
GUICtrlSetResizing($Checkbox3, 768 + 2 + 32)
GUICtrlSetResizing($Radio1, 768 + 2 + 32)
GUICtrlSetResizing($Radio2, 768 + 2 + 32)
GUICtrlSetResizing($Radio3, 768 + 2 + 32)
GUICtrlSetResizing($Toggle1, 768 + 2 + 32)
GUICtrlSetResizing($Toggle2, 768 + 2 + 32)
GUICtrlSetResizing($Toggle3, 768 + 2 + 32)
GUICtrlSetResizing($Progress1[0], 768 + 2 + 32)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON
_Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
Exit
Case $GUI_MAXIMIZE_BUTTON
GUISetState(@SW_MAXIMIZE, $Form1)
Case $GUI_MINIMIZE_BUTTON
GUISetState(@SW_MINIMIZE, $Form1)
Case $GUI_RESTORE_BUTTON
GUISetState(@SW_RESTORE, $Form1)
Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON
ConsoleWrite("Fullscreen toggled" & @CRLF) ;Fullscreen toggle is processed automatically when $ControlBtnsAutoMode is set to true, otherwise you need to use here _Metro_FullscreenToggle($Form1)
Case $GUI_MENU_BUTTON
;Create an Array containing menu button names
Local $MenuButtonsArray[5] = ["Themes Demo", "Settings", "About", "Contact", "Exit"]
; Open the metro Menu. See decleration of $MenuButtonsArray above.
Local $MenuSelect = _Metro_MenuStart($Form1, 150, $MenuButtonsArray)
Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array.
Case "0"
ConsoleWrite("Returned 0 = Starting themes demo. Please note that the window border colors are not updated during this demo." & @CRLF)
_ThemesDemo()
Case "1"
ConsoleWrite("Returned 1 = Settings button clicked." & @CRLF)
Case "2"
ConsoleWrite("Returned 2 = About button clicked." & @CRLF)
Case "3"
ConsoleWrite("Returned 3 = Contact button clicked." & @CRLF)
Case "4"
ConsoleWrite("Returned 4 = Exit button clicked." & @CRLF)
_Metro_GUIDelete($Form1)
Exit
EndSwitch
Case $Button3
_GUIDisable($Form1, 0, 30) ;For better visibility of the MsgBox on top of the first GUI.
_Metro_MsgBox(0, "Metro MsgBox Example", "Try a rightclick on this button for rightclick menu demo.", 400, 11, $Form1) ; with 3 secs timeout
_GUIDisable($Form1)
Case $GUI_EVENT_SECONDARYDOWN ;Demo for starting rightclick menu
Local $aCInfo = GUIGetCursorInfo($Form1)
If $aCInfo[4] = $Button3 Then
;Create an Array containing menu button names
Local $MenuButtonsArray[4] = ["Button 1", "Button 2", "Button 3", "Button 4"]
; Open the rightclick Menu. See decleration of $MenuButtonsArray above.
Local $MenuSelect = _Metro_RightClickMenu($Form1, 300, $MenuButtonsArray)
Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array.
Case "0"
ConsoleWrite("Returned 0 = Button 1 clicked." & @CRLF)
Case "1"
ConsoleWrite("Returned 1 = Button 2 clicked." & @CRLF)
Case "2"
ConsoleWrite("Returned 2 = Button 3 clicked." & @CRLF)
Case "3"
ConsoleWrite("Returned 3 = Button 4 clicked." & @CRLF)
EndSwitch
EndIf
Case $Button2
_GUIDisable($Form1, 0, 30) ;For better visibility of the MsgBox on top of the first GUI.
_Metro_MsgBox(0, "Metro MsgBox Example", "Button 2 clicked. (Button with 3 secs timeout)", 400, 11, $Form1, 3) ; with 3 secs timeout
_GUIDisable($Form1)
Case $Button1
_GUIDisable($Form1, 0, 30)
Local $mInput = _Metro_InputBox("Please enter your name.", 11, "", False, True)
If Not @error Then _Metro_MsgBox(0, "Metro MsgBox Example", "Hello " & $mInput & ", Press ok to set the progressbar.", 350, 11, $Form1)
_GUIDisable($Form1)
For $i = 0 To 85 Step +2
Sleep(1)
_Metro_SetProgress($Progress1, $i)
Next
_GUIDisable($Form1, 0, 30)
Local $Select_YesNo = _Metro_MsgBox(4, "Metro MsgBox Example", "Select yes to create a second GUI.", 350, 11, $Form1)
If $Select_YesNo = "Yes" Then _SecondGUI()
_GUIDisable($Form1)
Case $Toggle1
If _Metro_ToggleIsChecked($Toggle1) Then
_Metro_ToggleUnCheck($Toggle1)
ConsoleWrite("Toggle unchecked!" & @CRLF)
Else
_Metro_ToggleCheck($Toggle1)
ConsoleWrite("Toggle checked!" & @CRLF)
EndIf
Case $Toggle2
If _Metro_ToggleIsChecked($Toggle2) Then
_Metro_ToggleUnCheck($Toggle2)
ConsoleWrite("Toggle unchecked!" & @CRLF)
Else
_Metro_ToggleCheck($Toggle2)
ConsoleWrite("Toggle checked!" & @CRLF)
EndIf
Case $Toggle3
If _Metro_ToggleIsChecked($Toggle3) Then
_Metro_ToggleUnCheck($Toggle3)
ConsoleWrite("Disabled!" & @CRLF)
Else
_Metro_ToggleCheck($Toggle3)
ConsoleWrite("Enabled!" & @CRLF)
EndIf
Case $Checkbox1
If _Metro_CheckboxIsChecked($Checkbox1) Then
_Metro_CheckboxUnCheck($Checkbox1)
ConsoleWrite("Checkbox unchecked!" & @CRLF)
Else
_Metro_CheckboxCheck($Checkbox1)
ConsoleWrite("Checkbox checked!" & @CRLF)
EndIf
Case $Checkbox2
If _Metro_CheckboxIsChecked($Checkbox2) Then
_Metro_CheckboxUnCheck($Checkbox2)
ConsoleWrite("Checkbox unchecked!" & @CRLF)
Else
_Metro_CheckboxCheck($Checkbox2)
ConsoleWrite("Checkbox checked!" & @CRLF)
EndIf
Case $Checkbox3
If _Metro_CheckboxIsChecked($Checkbox3) Then
_Metro_CheckboxUnCheck($Checkbox3)
ConsoleWrite("Checkbox unchecked!" & @CRLF)
Else
_Metro_CheckboxCheck($Checkbox3)
ConsoleWrite("Checkbox checked!" & @CRLF)
EndIf
Case $Radio1
_Metro_RadioCheck(1, $Radio1)
ConsoleWrite("Radio 1 selected!" & @CRLF)
Case $Radio2
_Metro_RadioCheck(1, $Radio2)
ConsoleWrite("Radio 2 selected = " & _Metro_RadioIsChecked(1, $Radio2) & @CRLF)
Case $Radio3
_Metro_RadioCheck(1, $Radio3)
ConsoleWrite("Radio 3 (ExStyle) selected!" & @CRLF)
EndSwitch
WEnd
Func _SecondGUI()
Local $Form2 = _Metro_CreateGUI("Example2", 600, 400, -1, -1, True)
;Add control buttons
Local $Control_Buttons_2 = _Metro_AddControlButtons(True, True, True, True)
Local $GUI_CLOSE_BUTTON = $Control_Buttons_2[0]
Local $GUI_MAXIMIZE_BUTTON = $Control_Buttons_2[1]
Local $GUI_RESTORE_BUTTON = $Control_Buttons_2[2]
Local $GUI_MINIMIZE_BUTTON = $Control_Buttons_2[3]
Local $Button1 = _Metro_CreateButton("Close", 250, 340, 100, 40)
GUICtrlSetResizing($Button1, 768 + 8)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $Button1, $GUI_CLOSE_BUTTON
_Metro_GUIDelete($Form2) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs!
Return 0
Case $GUI_MAXIMIZE_BUTTON
GUISetState(@SW_MAXIMIZE, $Form2)
Case $GUI_MINIMIZE_BUTTON
GUISetState(@SW_MINIMIZE, $Form2)
Case $GUI_RESTORE_BUTTON
GUISetState(@SW_RESTORE, $Form2)
EndSwitch
WEnd
EndFunc ;==>_SecondGUI
Func _ThemesDemo() ;Loop through all themes by recreating all controls
Local $ThemesArray[25] = ["DarkMidnightTeal", "DarkMidnightBlue", "DarkMidnightCyan", "DarkMidnight", "DarkTeal", "DarkBlueV2", "DarkBlue", "DarkCyan", "DarkRuby", "DarkGray", "DarkGreen", "DarkGreenV2", "DarkPurple", "DarkAmber", "DarkOrange", "LightTeal", "LightGray", "LightBlue", "LightCyan", "LightGreen", "LightRed", "LightOrange", "LightPurple", "LightPink", "DarkTealV2"]
For $i = 0 To 24
GUISetState($Form1, @SW_LOCK)
ConsoleWrite($ThemesArray[$i] & @CRLF)
_SetTheme($ThemesArray[$i]) ;See MetroThemes.au3 for selectable themes or to add more
GUICtrlDelete($Button1)
GUICtrlDelete($Button2)
GUICtrlDelete($Button3)
GUICtrlDelete($Checkbox1)
GUICtrlDelete($Checkbox2)
GUICtrlDelete($Checkbox3)
GUICtrlDelete($Radio1)
GUICtrlDelete($Radio2)
GUICtrlDelete($Radio3)
GUICtrlDelete($Toggle1)
GUICtrlDelete($Toggle2)
GUICtrlDelete($Toggle3)
GUICtrlDelete($Progress1[0])
GUICtrlDelete($GUI_CLOSE_BUTTON)
GUICtrlDelete($GUI_MAXIMIZE_BUTTON)
GUICtrlDelete($GUI_RESTORE_BUTTON)
GUICtrlDelete($GUI_MINIMIZE_BUTTON)
GUICtrlDelete($GUI_FULLSCREEN_BUTTON)
GUICtrlDelete($GUI_FSRestore_BUTTON)
GUICtrlDelete($GUI_MENU_BUTTON)
GUISetBkColor($GUIThemeColor, $Form1)
$Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True)
$GUI_CLOSE_BUTTON = $Control_Buttons[0]
$GUI_MAXIMIZE_BUTTON = $Control_Buttons[1]
$GUI_RESTORE_BUTTON = $Control_Buttons[2]
$GUI_MINIMIZE_BUTTON = $Control_Buttons[3]
$GUI_FULLSCREEN_BUTTON = $Control_Buttons[4]
$GUI_FSRestore_BUTTON = $Control_Buttons[5]
$GUI_MENU_BUTTON = $Control_Buttons[6]
$Button1 = _Metro_CreateButton("Button Style 1", 50, 245, 115, 40)
$Button2 = _Metro_CreateButtonEx("Button Style 2", 195, 245, 115, 40)
$Button3 = _Metro_CreateButtonEx2("Button Style 3", 340, 245, 115, 40)
$Checkbox1 = _Metro_CreateCheckbox("Checkbox 1", 30, 70, 125, 30)
$Checkbox2 = _Metro_CreateCheckboxEx("Checkbox 2", 30, 107, 125, 30)
$Checkbox3 = _Metro_CreateCheckboxEx2("Checkbox 3", 29, 142, 125, 30)
_Metro_CheckboxCheck($Checkbox1, True)
_Metro_CheckboxCheck($Checkbox2, True)
_Metro_CheckboxCheck($Checkbox3, True)
$Radio1 = _Metro_CreateRadio("1", "Radio 1", 180, 70, 100, 30)
$Radio2 = _Metro_CreateRadio("1", "Radio 2", 180, 110, 100, 30)
$Radio3 = _Metro_CreateRadioEx("1", "Radio 3", 180, 150, 100, 30)
_Metro_RadioCheck("1", $Radio1)
$Toggle1 = _Metro_CreateToggle("Toggle 1", 320, 70, 130, 30)
$Toggle2 = _Metro_CreateToggleEx("Toggle 2", 322, 107, 128, 30)
$Toggle3 = _Metro_CreateOnOffToggle("Enabled", "Disabled", 320, 144, 130, 30)
$Progress1 = _Metro_CreateProgress(100, 195, 300, 26)
GUICtrlSetResizing($Button1, 768 + 8)
GUICtrlSetResizing($Button2, 768 + 8)
GUICtrlSetResizing($Button3, 768 + 8)
GUICtrlSetResizing($Checkbox1, 768 + 2 + 32)
GUICtrlSetResizing($Checkbox2, 768 + 2 + 32)
GUICtrlSetResizing($Checkbox3, 768 + 2 + 32)
GUICtrlSetResizing($Radio1, 768 + 2 + 32)
GUICtrlSetResizing($Radio2, 768 + 2 + 32)
GUICtrlSetResizing($Radio3, 768 + 2 + 32)
GUICtrlSetResizing($Toggle1, 768 + 2 + 32)
GUICtrlSetResizing($Toggle2, 768 + 2 + 32)
GUICtrlSetResizing($Toggle3, 768 + 2 + 32)
GUICtrlSetResizing($Progress1[0], 768 + 2 + 32)
GUISetState($Form1, @SW_UNLOCK)
Sleep(1500)
Next
EndFunc ;==>_ThemesDemo
Alles anzeigen
Hat da einer von Euch eine Idee?
Gruß gmmg
@Schnuffel: Danke funktioniert prima. Hab das nur noch etwas angepasst. Da das Array einen "0" Wert hat, wenn weniger als 4 Felder erzeugt werden, musste ich diese noch anfangen.
$date = _Now()
$sp = "-----------------------------------------"
$mbody = @CRLF & $sp & @CRLF & "gesendet am: " & $date & @CRLF & $sp & @CRLF & _
"von: " & $user & " " & $mail_txt & @CRLF & $sp & @CRLF & _
"Client: " & $computer & @CRLF & $sp & @CRLF & _
"System: " & $DataArray[0][0] & @CRLF & $sp & @CRLF & _
"Fehlerauswahl: " & $DataArray[1][0] & @CRLF ;& $sp & @CRLF
For $i = 2 To UBound($DataArray) -1
;$mbody &= $DataArray[$i][0] & ": " & $DataArray[$i][1] & @CRLF & $sp & @CRLF
If $DataArray[$i][0] = "0" Then
Else
$mbody &= $sp & @CRLF & $DataArray[$i][0] & ": " & $DataArray[$i][1] & @CRLF
EndIf
Next
$mbody &= $sp & @CRLF
Alles anzeigen
Gruß gmmg
Schnuffel: Das sieht ja gut aus. Ich teste das aber erst am Montag
Vielen Dank für dein Hilfe
Gruß gmmg
Hallo Zusammen,
ich möchte gern mit den Daten aus einem Array einen Mailbody dynamisch erzeugen.
Beispiel:
autoit.de/wcf/attachment/90622/
Mein Statischer Mailbody sieht so aus bzw. habe ich in meinem Fall 5 davon, weil sich ja die Anzahl im Array verändern kann.
Wie kann ich das denn in einer Schleife am Besten zusammenbauen, dass immer die Festen Texte " gesendet am: usw. immer vorkommen + die dDaten aus dem Array ?
;-------------------mail body------------------
$date = _Now()
$sp = "-----------------------------------------"
$mbody = "gesendet am: " & $date & @CRLF & $sp & @CRLF & "von: " & $user & " " & $mail_txt & @CRLF & $sp & @CRLF & "Client: " & _
$computer & @CRLF & $sp & @CRLF & "System: " & $DataArray[0][0] & @CRLF & $sp & @CRLF & "Fehlerauswahl: " & $DataArray[1][0] & @CRLF & _
$sp & @CRLF & $DataArray[2][0] & ": " & $DataArray[2][1] & @CRLF & $sp & @CRLF & $DataArray[3][0] & ": " & $DataArray[3][1] & @CRLF & $sp & _
@CRLF & $DataArray[4][0] & ": " & $DataArray[4][1] & @CRLF & $sp & @CRLF & $DataArray[5][0] & ": " & $DataArray[5][1]
Alles anzeigen
Hat da einer eine Idee?
Gruß gmmg
Hallo Zusammen,
danke für die Zahlreichen Infos.
UEZ: dein Skript startet bei mir mit der Autoit Version v3.3.16.1 aktuell nicht. Da sind bestimmte Variablen nicht definiert oder es fehlt ein Include.
Gruß gmmg
Andy,
Ich benötige die Screenshot Erweiterung in unserem in AutoIT gescripteten IT-Helpdesk Tool. Da gibt es zwar schon die Screenshotfunktion, aber da wird nur der komplette Bildschirm mitgeschnitten. Und die User haben oft die falschen Fenster im Vordergrund.
Den Dateinamen passe ich noch an, ebventuell auch mit der Möglichkeit mehrere Dateien zu erzeugen. Aus den Auswahlinfos des Tools + Screenshot wird dann im Endeffekt eine Email erzeugt und per SMTP verschickt.
Die IT-Helpdesk GUI bzw. die Icons | Label | Button | Input /Edit Felder + entsprechende Texte, werden dabei aktuell dynamisch mit Daten aus einer Access DB erzeugt.
Gruß gmmg
Hallo Zusammen,
für mein Thema "Button / Icons aus DB bzw. Array erstellen", bei dem ich unser IT Helpdesk Tool auf den neuen Stand bringe, benötige ich noch ein angepasstes "Screenshot Tool", bei dem der Screenshot per Mausauswahl (markierter Bereich) gespeichert wird. Im engl. Forum bin ich da auch fündig geworden und habe mir folgenden Quellcode angepasst.
Meine Frage dazu , passt das so oder kann man hier optimieren?
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <ScreenCapture.au3>
#Include <Misc.au3>
Global $iX1, $iY1, $iX2, $iY2, $aPos, $sMsg, $jpg_Path
;--- Create GUI ---
$hMain_GUI = GUICreate("Screenshot-Tool", 240, 50)
$hRect_Button = GUICtrlCreateButton("NEU", 10, 10, 80, 25)
GUISetState(@SW_SHOW)
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
Exit
Case $hRect_Button
$jpg_Path = @ScriptDir & "\Rect.jpg"
If FileExists($jpg_Path) Then FileDelete($jpg_Path)
GUISetState(@SW_HIDE, $hMain_GUI)
Mark_Rect()
; Capture selected area
_ScreenCapture_Capture($jpg_Path, $iX1, $iY1, $iX2, $iY2, False)
GUISetState(@SW_SHOW, $hMain_GUI)
_Display_image() ; Display image
EndSwitch
WEnd
Func _Display_image()
; Display image
$hscreen_GUI = GUICreate("Image Vorschau ...", $iX2 - $iX1 + 1, $iY2 - $iY1 + 1, 100, 100)
$hPic = GUICtrlCreatePic(@ScriptDir & "\Rect.jpg", 0, 0, $iX2 - $iX1 + 1, $iY2 - $iY1 + 1)
GUISetState(@SW_SHOW)
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
GUIDelete($hscreen_GUI)
ExitLoop
EndSwitch
WEnd
EndFunc
Func Mark_Rect()
Local $aMouse_Pos, $hMask, $hMaster_Mask, $iTemp
Local $UserDLL = DllOpen("user32.dll")
; Create transparent GUI with Cross cursor
$hCross_GUI = GUICreate("Screenshot", @DesktopWidth, @DesktopHeight - 20, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
WinSetTrans($hCross_GUI, "", 8)
GUISetState(@SW_SHOW, $hCross_GUI)
GUISetCursor(3, 1, $hCross_GUI)
Global $hRectangle_GUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
GUISetBkColor(0xFF0000)
; Wait until mouse button pressed
While Not _IsPressed("01", $UserDLL)
Sleep(10)
WEnd
; Get first mouse position
$aMouse_Pos = MouseGetPos()
$iX1 = $aMouse_Pos[0]
$iY1 = $aMouse_Pos[1]
; Draw rectangle while mouse button pressed
While _IsPressed("01", $UserDLL)
$aMouse_Pos = MouseGetPos()
$hMaster_Mask = _WinAPI_CreateRectRgn(0, 0, 0, 0)
$hMask = _WinAPI_CreateRectRgn($iX1, $aMouse_Pos[1], $aMouse_Pos[0], $aMouse_Pos[1] + 1) ; Bottom of rectangle
_WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2)
_WinAPI_DeleteObject($hMask)
$hMask = _WinAPI_CreateRectRgn($iX1, $iY1, $iX1 + 1, $aMouse_Pos[1]) ; Left of rectangle
_WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2)
_WinAPI_DeleteObject($hMask)
$hMask = _WinAPI_CreateRectRgn($iX1 + 1, $iY1 + 1, $aMouse_Pos[0], $iY1) ; Top of rectangle
_WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2)
_WinAPI_DeleteObject($hMask)
$hMask = _WinAPI_CreateRectRgn($aMouse_Pos[0], $iY1, $aMouse_Pos[0] + 1, $aMouse_Pos[1]) ; Right of rectangle
_WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2)
_WinAPI_DeleteObject($hMask)
; Set overall region
_WinAPI_SetWindowRgn($hRectangle_GUI, $hMaster_Mask)
If WinGetState($hRectangle_GUI) < 15 Then GUISetState()
Sleep(10)
WEnd
; Get second mouse position
$iX2 = $aMouse_Pos[0]
$iY2 = $aMouse_Pos[1]
; Set in correct order if required
If $iX2 < $iX1 Then
$iTemp = $iX1
$iX1 = $iX2
$iX2 = $iTemp
EndIf
If $iY2 < $iY1 Then
$iTemp = $iY1
$iY1 = $iY2
$iY2 = $iTemp
EndIf
GUIDelete($hRectangle_GUI)
GUIDelete($hCross_GUI)
DllClose($UserDLL)
EndFunc ;==>Mark_Rect
Alles anzeigen
Danke
Gruß gmmg
für das 2 label klappt die Änderung jetzt auch. Lässt sich aber sicherlich noch optimieren oder in eine Funktion packen.
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <Array.au3>
; Create an array to hold the button data and the control Ids
Global $aLabels1[5][2]
; Add the data
For $i = 0 To 4
$aLabels1[$i][0] = "Label " & $i & " clicked"
Next
$hGUI = GUICreate("Test", 500, 500)
; Create the Lables and add their ControlIDs to the array
For $i = 0 To UBound($aLabels1) - 1
;$aLables[$i][1] = GUICtrlCreateButton("Button " & $i, 10, 10 + (40 * $i), 80, 30)
$aLabels1[$i][1] = GUICtrlCreateLabel("Label " & $i, 10 + (60 * $i), 20, 60, 30, 0x01)
GUICtrlSetTip($aLabels1[$i][1], "Test Label " & $i)
$l1 = 0
Next
GUISetState()
While 100
$GGCI = GUIGetCursorInfo($hGUI)
If $GGCI[4] = $aLabels1[1][1] Then
If $l1 = 0 Then
GUICtrlSetTip($aLabels1[1][1], "Test Label - 1 - 0815")
GUICtrlSetFont($aLabels1[1][1], 9, 700, 0, "Arial")
$l1 = 1
EndIf
Else
If $l1 = 1 Then
GUICtrlSetFont($aLabels1[1][1], 9, 250, 0, "Arial")
$l1 = 0
EndIf
EndIf
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
Exit
; Was the ControlID a button?
Case Else
For $i = 0 To UBound($aLabels1) - 1
If $iMsg = $aLabels1[$i][1] Then
; If so then display the data
MsgBox($MB_SYSTEMMODAL, "Label clicked", $aLabels1[$i][0])
ConsoleWrite($aLabels1[$i][0])
; No point in looking further
ExitLoop
EndIf
Next
EndSwitch
WEnd
Alles anzeigen
Gruß gmmg
Den ToolTip kann ich mit folgendem Beispiel manipulieren.
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
; Create an array to hold the button data and the control Ids
Global $aLabels[5][2]
; Add the data
For $i = 0 To 4
$aLabels[$i][0] = "Label " & $i & " clicked"
Next
$hGUI = GUICreate("Test", 500, 500)
; Create the Lables and add their ControlIDs to the array
For $i = 0 To UBound($aLabels) - 1
;$aLables[$i][1] = GUICtrlCreateButton("Button " & $i, 10, 10 + (40 * $i), 80, 30)
$aLabels[$i][1] = GUICtrlCreateLabel("Label " & $i, 10 + (60 * $i), 20, 60, 30, 0x01)
GUICtrlSetTip($aLabels[$i][1], "Test Label " & $i)
Next
GUISetState()
While 1
$GGCI = GUIGetCursorInfo($hGUI)
If $GGCI[4] = 0 Then GUICtrlSetTip($aLabels[1][1], "Test Label - 1 - 0815")
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
Exit
; Was the ControlID a button?
Case Else
For $i = 0 To UBound($aLabels) - 1
If $iMsg = $aLabels[$i][1] Then
; If so then display the data
MsgBox($MB_SYSTEMMODAL, "Label clicked", $aLabels[$i][0])
ConsoleWrite($aLabels[$i][0])
; No point in looking further
ExitLoop
EndIf
Next
EndSwitch
WEnd
Alles anzeigen
Hallo BugFix,
mit den dynamisch erzeugten Label und Icons, habe ich es noch nicht geschafft, die Infos mit GUIGetCursorInfo(4) auszulesen.
Als Grundlage dient ja der Quelltext aus Post2. Ich habe hier bestimmt einen Denkfehler.
Gruß gmmg
Ja, das passt.
Habe aber noch eine ToDo. Ist es möglich die Schriftgröße zu ändern, wenn ich die Maus über das Icon oder Label bewege?
Wie ein Hover effekt.
Moin @Velved,
Stimmt, mit der SQL OrderBY Option klappt es auch. Das ändere ich gleich mal ab.
Local $Array_Systeme = _Get_Records("SELECT * FROM " & $tblname001 & " Order By Sortierung ASC " & ";")
Und für die Labels hatte ich das bereits mit dem $SS_Center=0x01 so umgesetzt, das passt jetzt auch.
Gruß gmmg
Ich habe in die Access DB jetzt noch ein Spalte für die Label ID bzw. Icon ID aufgenommen und schreibe dann die Werte beim erstellen in diese Spalte.
$aLabels[$i][4]
$aIcons[$i][4]
Das anklicken der Icon und Label funktioniert jetzt auch. Hier war der Fehler, dass in der DB nicht alle Felder mit Icon Werten gefüllt waren, somit 0 Werte drin standen.
#AutoIt3Wrapper_UseX64=y
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <D:\Scripte\MS_AccessCom\Access UDF\Access_UDF.au3>
#include <D:\Scripte\ArrayMultiColSort\ArrayMultiColSort.au3>
;--------- MSAccess DB ------------
$dbname = @ScriptDir & "\bin\db\Helpdesk.accdb"
$tblname001 = "Systeme"
Local $Connection = _Start_Connection($dbname & ";")
Local $Array_Systeme = _Get_Records("SELECT * FROM " & $tblname001 & ";")
_Close_Connection()
;----------------------------------
;----- Sort Array nach Col3 -------
;sortiere nach Col3
Global $aSortData[][] = [ _
[3, 0]]
; Sort and display array
_ArrayMultiColSort($Array_Systeme, $aSortData)
;_ArrayDisplay($Array_Systeme)
;----------------------------------
Local $aIcons = $Array_Systeme
Local $aLabels = $Array_Systeme
$hGUI = GUICreate("GUI Test", 800, 720)
; Create the buttons and add their ControlIDs to the array
For $i = 0 To UBound($Array_Systeme) - 1
$aIcons[$i][4] = GUICtrlCreateIcon(@ScriptDir & "\bin\icons\" & $Array_Systeme[$i][2],"", 11 + (60 * $i), 70, 40, 40)
GUICtrlSetTip($aIcons[$i][4], $Array_Systeme[$i][1])
;$aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 20 + (59 * $i), 115, 60, 30)
$aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 10 + (60 * $i), 115, 60, 30,0x01) ;center Txt
GUICtrlSetTip($aLabels[$i][4], $Array_Systeme[$i][1])
Next
;_ArrayDisplay($aIcons)
;_ArrayDisplay($aLabels)
GUISetState()
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
Exit
; Was the ControlID a button?
Case Else
For $x = 0 To UBound($Array_Systeme) - 1
If $iMsg = $aLabels[$x][4] or $iMsg = $aIcons[$x][4] Then
; If so then display the data
MsgBox(0, "Label clicked", $aLabels[$x][1])
; No point in looking further
ExitLoop
EndIf
Next
EndSwitch
WEnd
Alles anzeigen
Hier mal mit Fixer Ausrichtung der Labels
#AutoIt3Wrapper_UseX64=y
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <D:\Scripte\MS_AccessCom\Access UDF\Access_UDF.au3>
#include <D:\Scripte\ArrayMultiColSort\ArrayMultiColSort.au3>
;--------- MSAccess DB ------------
$dbname = @ScriptDir & "\bin\db\Helpdesk.accdb"
$tblname001 = "Systeme"
Local $Connection = _Start_Connection($dbname & ";")
Local $Array_Systeme = _Get_Records("SELECT * FROM " & $tblname001 & ";")
_Close_Connection()
;----------------------------------
;----- Sort Array nach Col3 -------
;sortiere nach Col3
Global $aSortData[][] = [ _
[3, 0]]
; Sort and display array
_ArrayMultiColSort($Array_Systeme, $aSortData)
;_ArrayDisplay($Array_Systeme)
;----------------------------------
Local $aIcons = $Array_Systeme
Local $aLabels = $Array_Systeme
$hGUI = GUICreate("GUI Test", 800, 720)
; Create the buttons and add their ControlIDs to the array
For $i = 0 To UBound($Array_Systeme) - 1
$aIcons[$i][4] = GUICtrlCreateIcon(@ScriptDir & "\bin\icons\" & $Array_Systeme[$i][2],"", 20 + (60 * $i), 70, 40, 40)
GUICtrlSetTip($aIcons[$i][4], $Array_Systeme[$i][1])
;$aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 25 + (60 * $i -4), 115, 60, 30)
IF $i = 0 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 30 + (60 * $i), 115, 60, 30)
IF $i = 1 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 30 + (60 * $i), 115, 60, 30)
IF $i = 2 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 25 + (60 * $i), 115, 60, 30)
IF $i = 3 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 26 + (60 * $i), 115, 60, 30)
IF $i = 4 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 20 + (60 * $i), 115, 60, 30)
IF $i = 5 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 20 + (60 * $i), 115, 60, 30)
IF $i = 6 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 22 + (60 * $i), 115, 60, 30)
IF $i = 7 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 24 + (60 * $i), 115, 60, 30)
IF $i = 8 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 20 + (60 * $i), 115, 60, 30)
IF $i = 9 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 22 + (60 * $i), 115, 60, 30)
IF $i = 10 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 30 + (60 * $i), 115, 60, 30)
IF $i = 11 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 25 + (60 * $i), 115, 60, 30)
IF $i = 12 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 17 + (60 * $i), 115, 60, 30)
GUICtrlSetTip($aLabels[$i][4], $Array_Systeme[$i][1])
Next
_ArrayDisplay($aIcons)
_ArrayDisplay($aLabels)
GUISetState()
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
Exit
; Was the ControlID a button?
Case Else
For $x = 0 To UBound($Array_Systeme) - 1
If $iMsg = $aLabels[$x][4] or $iMsg = $aIcons[$x][4] Then
; If so then display the data
MsgBox(0, "Label clicked", $aLabels[$x][1])
; No point in looking further
ExitLoop
EndIf
Next
EndSwitch
WEnd
Alles anzeigen
Gruß gmmg
Hallo Velted,
genau, ich möchte die X Anzahl an Icons Nebeneinander anzeigen + die Labels entsprechend unter dem jeweiligen Icon.
Label Texte, der Icon Name und der ToolTip kommen aus der DB, wobei der Tooltip im ersten Step gleich dem Label Text sein kann.
Was in meinem Beispiel nicht funktioniert, beim Scriptstart wird gleich die MsgBox(0, "Label clicked") angezeigt, obwohl ich selbst ja noch auf kein Label oder Icon geklickt habe.
In der Access DB habe ich für die Sortierung einfach eine Spalte mit Zahlenwerten 01-13 die ja dann mit dem ArraySort Absteigend sortiert werden.
so sieht die Access DB aus
System ist dann = Label Text und Tooltipp
Gruß gmmg
Hallo Sven,
bei dem Create Icon kommt die Nummer daher, dass ich die Icons in einer DLL gespeichert hatte.
Die udf 'S gibt es hier im engl. Forum
Gruß gmmg
Habe schon eine erste Version gebaut, funktioniert aber noch nicht so wie gewünscht.
Hat noch einer eine Idee dazu?
#AutoIt3Wrapper_UseX64=y
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <D:\Scripte\MS_AccessCom\Access UDF\Access_UDF.au3>
#include <D:\Scripte\ArrayMultiColSort\ArrayMultiColSort.au3>
;--------- MSAccess DB ------------
$dbname = @ScriptDir & "\bin\db\Helpdesk.accdb"
$tblname001 = "Systeme"
Local $Connection = _Start_Connection($dbname & ";")
Local $GetData = _Get_Records("SELECT * FROM " & $tblname001 & ";")
_Close_Connection()
;----------------------------------
;----- Sort Array nach Col3 -------
;sortiere nach Col3
Global $aSortData[][] = [ _
[3, 0]]
; Sort and display array
_ArrayMultiColSort($GetData, $aSortData)
;_ArrayDisplay($GetData)
;----------------------------------
$aIcons = $GetData
$aLabels = $GetData
For $a = 0 To UBound ($GetData) -1
;MsgBox(0,"", $GetData[$i][1])
$aIcons[$a][0] = $GetData[$a][1]
$aLabels[$a][0] = $GetData[$a][1]
Next
$hGUI = GUICreate("GUI Test", 800, 720)
; Create the buttons and add their ControlIDs to the array
For $b = 0 To UBound($aIcons) - 1
$aIcons[$b][1] = GUICtrlCreateIcon(@ScriptDir & "\bin\icons\" & $aIcons[$b][2],25, 10 + (60 * $b), 70, 40, 40)
GUICtrlSetTip($aIcons[$b][1], $aIcons[$b][0])
Next
For $c = 0 To UBound($aLabels) - 1
$aLabels[$c][1] = GUICtrlCreateLabel($aLabels[$c][1], 25 + (60 * $c), 115, 60, 30)
GUICtrlSetTip($aLabels[$c][1], $aLabels[$c][0])
Next
GUISetState()
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
Exit
; Was the ControlID a button?
;~ Case Else
;~ For $x = 0 To UBound($aIcons) - 1
;~ If $iMsg = $aIcons[$x][1] Then
;~ ; If so then display the data
;~ MsgBox(0, "Label clicked", $aIcons[$x][0])
;~ ; No point in looking further
;~ ExitLoop
;~ EndIf
;~ Next
EndSwitch
WEnd
Alles anzeigen
Gruß gmmg
Im engl. Forum habe ich ein Beispiel für die Button Erstellung gefunden.
Mal sehen, ob ich damit weiter komme.
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
; Create an array to hold the button data and the control Ids
Global $aButtons[5][2]
; Add the data
For $i = 0 To 4
$aButtons[$i][0] = "Button " & $i & " pressed"
Next
$hGUI = GUICreate("Test", 500, 500)
; Create the buttons and add their ControlIDs to the array
For $i = 0 To UBound($aButtons) - 1
$aButtons[$i][1] = GUICtrlCreateButton("Button " & $i, 10, 10 + (40 * $i), 80, 30)
Next
GUISetState()
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
Exit
; Was the ControlID a button?
Case Else
For $i = 0 To UBound($aButtons) - 1
If $iMsg = $aButtons[$i][1] Then
; If so then display the data
MsgBox($MB_SYSTEMMODAL, "Button Pressed", $aButtons[$i][0])
; No point in looking further
ExitLoop
EndIf
Next
EndSwitch
WEnd
Alles anzeigen
Hallo Zusammen,
ich bin aktuell am umstellen unseres IT-Helpdesk Tools. Ziel der Umstellung ist es die Icons dynamisch aus einem Array bzw. Datenstring zu erstellen. Die Daten dafür kommen aus einer Access DB.
Aktuell wird für jedes Icon mit der Zeile "GUICTRLCreateIcon" einzeln erstellt.
$ico01 = GUICtrlCreateIcon(@ScriptDir & "\bin\icons\Prog1.ico",25, $ico_left, 70, 40, 40)
$label01 = GUICtrlCreateLabel("Prog1",$label_left, 115,$label_length,25)
GUICtrlSetTip($ico01, "Prog1")
GUICtrlSetTip($label01, "Prog1")
Maximal sollen es 12 oder 13 Icons werden.
Hier mal ein Bild der GUI
Ich bin der Meinung es gab da mal ein Beispiel für eine dynamische Erstellung, ich finde aber grad nichts dazu.
Hat das jemand schonmal umgesetzt?
Gruß gmmg