Hallo, Leute
möchte euch mein neues Projekt hier mal vorstellen.
Ich nenne es "GDI+ MyToolbar".
schaut es euch mal an, ist aber noch nicht ganz fertig.
Ich habe momentan keine Idee wie ich weiter machen soll...
Vielleicht hat der eine oder andere mal einen guten Vorschlag wie man es besser machen kann.
Es wäre toll wenn man meine Buttons doppelt belegen könnte.
Die Idee entstand von dem AMIGA-Programm DosControl 6.0a (nur der untere Bereich!)
Spoiler anzeigen
Hier ist mein aktuelles Script dazu
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
AutoIt Version : 3.3.6.1
Author : tv_freeze
Scriptname : GDI+ MyToolbar (beta) and nor ready yet!!!
Script Function : Start Tools on clicked privat Buttons
: by clicked the button, search the tool on HD & start them
OS : Windows XP (Vista or Win7 not tested (own risc)
Thanx to : SEuBo for GUICtrLCreatePng-Routine & 'name22' for some Help's
: BugFix for _RecursiveFileSearch-Routine
: Oscar 'WM_MOV' a little bit from CDROM-Drive-Control
: Alexanderschill for Fade/in/out-Routine
best Forum : http://www.autoit.de
#ce ------------------------------------------------------------------------------
#NoTrayIcon
#include <IE.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
Opt("GUICloseOnESC", 1) ; i remove it later
[/autoit] [autoit][/autoit] [autoit]; my Buttons
Global $clickbutton = @ScriptDir & '\Button.png', $closebutton = @ScriptDir & '\close.bmp', $minbutton = @ScriptDir & '\minimize.bmp'
; settings
Global $sAppPath = @ScriptDir & '\settings\', $sIniFile = $sAppPath & 'Toolbar.ini', $settings
Global $iLeft = IniRead($sIniFile, 'Config', 'Left', -1)
Global $iTop = IniRead($sIniFile, 'Config', 'Top', -1)
; font
Global $Font = 'Arial', $FontSize = 4, $FontColor = 0xFFFFFFFF, $ButtColor, $change
;titlebar
Global $BgColorTitle = 0xFFFFFF, $BgColor = 0x777799, $TitleHeight = 20
; gui
Global $title = "GDI+ MyToolbar", $width = 220, $height = 118
; buttons
Global $x_pos_button = 8, $y_pos_button = 50, $buttoncount = 0, $wcounter = 0, $DefaultButtonHeight = 16
; reading settings (tool-name's)
$data = IniReadSection($sIniFile, "Config") ; read my tools
$nr = $data[0][0]
Global $buttons[$nr + 1], $tool[$nr + 1]
For $a = 2 To $nr - 1
$tool[$a - 1] = 0
Next
; make gui-window
$hGUI = GUICreate($title, $width, $height, $iLeft, $iTop, $WS_POPUP)
GUISetBkColor($BgColor)
GUISetIcon(@ScriptDir & '\Autoit.ico')
; titlebar-white
GUISetFont($FontSize + 6, 400, 0, 'Arial Black')
$TitleBar = GUICtrlCreateLabel($title, 3, 4, $width - 42, 17, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetColor(-1, $FontColor)
barchange() ; new $width for titlebar
[/autoit] [autoit][/autoit] [autoit]; close & minimize buttons
$minimize_b = GUICtrlCreatePic($minbutton, $width - 31, 7, 9, 9)
$close_b = GUICtrlCreatePic($closebutton, $width - 16, 7, 9, 9)
; my Tools-Buttons here (see ini-file)
For $i = 2 To $nr - 1
$buttons[$i] = GUICtrlCreatePng($hGUI, $clickbutton, $x_pos_button, $y_pos_button, $data[$i + 1][1], $Font, $FontSize, $FontColor)
$y_pos_button = $y_pos_button + $DefaultButtonHeight
$buttoncount = $buttoncount + 1
If $buttoncount = 4 Then
$buttoncount = 0
BiggerGui()
$x_pos_button = $x_pos_button + 104
$y_pos_button = 50
EndIf
If $wcounter = 1 Then
$width = $width + 2
new_pos() ; new position for minimize & close buttons
$wcounter = 0
EndIf
Next
If $nr / 2 <> Int($nr / 2) Then
$width = $width + 50
BiggerGui()
$x_pos_button = $x_pos_button + 104
$y_pos_button = 50
new_pos() ; new position for minimize & close buttons
EndIf
; About-button
$Credits = GUICtrlCreatePng($hGUI, $clickbutton, 8, 28, "Credits", $Font, $FontSize, 0xFFF0FF0F)
; Greetings-button
$Greetings = GUICtrlCreatePng($hGUI, $clickbutton, 112, 28, "Greetings", $Font, $FontSize, 0xFFF0FF0F)
; settings-button
$settings = GUICtrlCreatePng($hGUI, $clickbutton, 216, 28, "Settings", $Font, $FontSize, 0xFFF0FF0F)
GuiRoundCorners($hGUI, 0, 0, 2, 2)
GUISetState()
GUIRegisterMsg($WM_MOVE, 'WM_MOVE')
; main-loop
While 1
$nMsg = GUIGetMsg()
For $a = 2 To $nr - 1
If $nMsg = $buttons[$a] Then ; click buttons ?
If $tool[$a - 1] = "1" Then
_ErrorInfo() ; file not found!
EndIf
If $tool[$a - 1] = "0" Then
$found = ""
_toolsearch($data[$a + 1][0], @HomeDrive)
If $found <> "" Then
$tool[$a - 1] = $found
; MsgBox(0,"Button" & $a-1, $data[$a+1][0] & " gestartet",1)
Run($tool[$a - 1])
EndIf
If $found = "4" Then
$tool[$a - 1] = "1"
_ErrorInfo() ; program not found!
EndIf
Else
Run($tool[$a - 1])
EndIf
EndIf
Next
Switch $nMsg
Case $settings ; click settings ?
GUISetState(@SW_DISABLE, $hGUI)
settings()
GUISetState(@SW_ENABLE, $hGUI)
Case $minimize_b
new_pos() ; new position for minimize & close buttons
GUISetState(@SW_MINIMIZE, $hGUI)
Case $close_b
ExitLoop
Case $Greetings
new_pos() ; new position for minimize & close buttons
_FADE($title, "", 10, 2) ; fade the main-GUI out
GUISetState(@SW_MINIMIZE, $hGUI)
GUISetState(@SW_DISABLE, $hGUI)
Greetings()
GUISetState(@SW_ENABLE, $hGUI)
GUISetState(@SW_RESTORE, $hGUI)
WinSetTrans($title, "", 255)
_FADE($title, "", 6, 1) ; fade the main-GUI in
WinSetTrans($title, "", 255)
Case $GUI_EVENT_CLOSE ; i remove it later
ExitLoop
EndSwitch
WEnd
GUICtrlDelete($hGUI)
Exit
Func _toolsearch($datei, $Ordner)
If StringRight($datei, 4) <> '.exe' Then $datei &= '.exe'
If StringRight($Ordner, 1) <> '\' Then $Ordner &= '\'
$found = _RecursiveFileSearch($datei, $Ordner)
EndFunc ;==>_toolsearch
Func BiggerGui()
$winsize = WinGetPos("[active]")
$width = $width + 50
WinMove($hGUI, '', $winsize[0] - ($width - $winsize[2]) / 2, Default, $width, 118) ; center my gui-windows, please!
GUICtrlSetPos($minimize_b, $width - 33, 7)
GUICtrlSetPos($close_b, $width - 20, 7)
barchange()
$wcounter = 1
EndFunc ;==>BiggerGui
Func new_pos()
GUICtrlDelete($minimize_b)
$minimize_b = GUICtrlCreatePic($minbutton, $width - 35, 7, 9, 9)
GUICtrlDelete($close_b)
$close_b = GUICtrlCreatePic($closebutton, $width - 20, 7, 9, 9)
EndFunc ;==>new_pos
Func barchange()
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateGraphic(0, 0, $width, $TitleHeight)
GUICtrlSetBkColor(-1, $BgColorTitle)
GUICtrlSetState(-1, $GUI_DISABLE)
EndFunc ;==>barchange
Func GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
$pos = WinGetPos($h_win)
$ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)
If $ret[0] Then
$ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
If $ret2[0] Then
Return 1
Else
Return 0
EndIf
Else
Return 0
EndIf
EndFunc ;==>GuiRoundCorners
Func GUICtrlCreatePng($hWnd, $sPath, $iX, $iY, $sString = "", $sFont = "Arial", $iFontSize = 4, $FontColor = 0xFFFFFFFF) ; SEuBo
_GDIPlus_Startup()
Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend, $hGUI
Local $hImage = _GDIPlus_ImageLoadFromFile($sPath), $iWidth = _GDIPlus_ImageGetWidth($hImage), $iHeight = _GDIPlus_ImageGetHeight($hImage)
Local $hImageContext = _GDIPlus_ImageGetGraphicsContext($hImage)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate($sFont)
$hFont = _GDIPlus_FontCreate($hFamily, $iFontSize)
$hBrush = _GDIPlus_BrushCreateSolid($FontColor)
If $change = 1 Then
$hBrush1 = _GDIPlus_BrushCreateSolid($ButtColor) ; Button Color over Brush-Button - change by tv_freeze
EndIf
$aMeasure = _GDIPlus_GraphicsMeasureString($hImageContext, $sString, $hFont, _GDIPlus_RectFCreate(), $hFormat)
If StringLen($sString) > 10 Then
DllStructSetData($aMeasure[0], "X", 2 + $iWidth / 2 - DllStructGetData($aMeasure[0], "Width") / 2)
Else
DllStructSetData($aMeasure[0], "X", $iWidth / 2 - DllStructGetData($aMeasure[0], "Width") / 2)
EndIf
DllStructSetData($aMeasure[0], "Y", $iHeight / 2 - DllStructGetData($aMeasure[0], "Height") / 2)
If $change = 1 Then
_GDIPlus_GraphicsFillRect($hImageContext, 2, 1, $iWidth-4, $iHeight-2, $hBrush1) ; change by tv_freeze
EndIf
_GDIPlus_GraphicsDrawStringEx($hImageContext, $sString, $hFont, $aMeasure[0], $hFormat, $hBrush)
$hGUI = GUICreate("", $iWidth, $iHeight, $iX, $iY, 0x80000000, BitOR(0x40, 0x80000), $hWnd)
$cLabel = GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight)
GUICtrlSetBkColor(-1, -2)
GUISetState(@SW_SHOWNOACTIVATE, $hGUI)
$hScrDC = _WinAPI_GetDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
$tSize = DllStructCreate("int X;int Y")
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $iWidth)
DllStructSetData($tSize, "Y", $iHeight)
$tSource = DllStructCreate("int X;int Y")
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate("byte Op;byte Flags;byte Alpha;byte Format")
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", 255)
DllStructSetData($tBlend, "Format", 1)
_WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
_WinAPI_ReleaseDC(0, $hScrDC)
_WinAPI_SelectObject($hMemDC, $hOld)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC($hMemDC)
GUISwitch($hWnd)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_GraphicsDispose($hImageContext)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_FontDispose($hFont)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_Shutdown()
Return SetError(0, $hGUI, $cLabel)
EndFunc ;==>GUICtrlCreatePng
; Save last Window-Positions (Left & Top)
Func WM_MOVE($hWnd, $iMsg, $iwParam, $ilParam) ; Oscar (from CDROM-Drive-Control)
If $hWnd = $hGui Then
Local $aPos = WinGetPos($hGUI)
IniWrite($sIniFile, 'Config', 'Left', $aPos[0])
IniWrite($sIniFile, 'Config', 'Top', $aPos[1])
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_MOVE
Func ShowSubFolders($Folder, $FILE)
For $Subfolder In $Folder.SubFolders
If FileExists($Subfolder.Path & "\" & $FILE) Then
$PathFound = $Subfolder.Path & "\" & $FILE
ExitLoop
EndIf
ShowSubFolders($Subfolder, $FILE)
Next
EndFunc ;==>ShowSubFolders
Func _ErrorInfo()
Local $info
$info = "The program " & Chr(34) & $data[$a + 1][1] & Chr(34) & " was not found..." & @CRLF
$info = $info & "Click the Button 'Settings' to change it!"
MsgBox(48, "Button" & $a - 1, StringFormat($info), 0, $hGUI)
EndFunc ;==>_ErrorInfo
Func Greetings()
Local $newGUI, $oIE, $GUIActiveX, $space, $new_msg, $ok, $htm, $TRANSPARENCY
For $j = 1 To 19
$space &= Chr(32) ; space
Next
$space &= 'Greetings!'
$newGUI = GUICreate($space, 180, 248, (@DesktopWidth - 180) / 2, (@DesktopHeight - 248) / 2, Default, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$htm = GUICreate("", 180, 218, 0, 0, $WS_CHILD, $newGUI)
_IEErrorHandlerRegister() ; Kein COM-Fehlerhandler
$oIE = _IECreateEmbedded() ; Webbrowserobjekt
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 198, 222)
_IENavigate($oIE, @ScriptDir & '\credits.htm')
$winsize = WinGetPos($space)
$ok = GUICtrlCreateButton("I have read this", 48, $winsize[1] - 84, 90, 22)
GUICtrlSetState(-1, $GUI_FOCUS)
WinSetTrans($space, "", 0)
GUISetState(@SW_SHOW, $newGUI)
$TRANSPARENCY = WinGetTrans($space)
_FADE($space, "", 6, 1) ; fade the GUI in
While 1
$new_msg = GUIGetMsg()
Select
Case $new_msg = $GUI_EVENT_CLOSE
ExitLoop
Case $new_msg = $ok
ExitLoop
EndSelect
WEnd
_FADE($space, "", 10, 2) ; fade the GUI out
GUIDelete($htm) ; close IE-Window
GUIDelete($newGUI) ; close Credits-Window
EndFunc ;==>Greetings
Func Settings()
Local $set, $setpos_x, $setpos_y
$setpos_x = IniRead($sIniFile, 'Config', 'Left', '')
$setpos_y = IniRead($sIniFile, 'Config', 'Top', '')
If @DesktopHeight - $setpos_y < $setpos_y Then
$set = GUICreate($title & ' -> Settings', 200, 100, -1, $setpos_y - 120, Default, $WS_EX_TOOLWINDOW)
Else
$set = GUICreate($title & ' -> Settings', 200, 100, -1, $setpos_y + 140, Default, $WS_EX_TOOLWINDOW)
EndIf
GUISetBkColor($BgColor)
$ButtColor = 0xF0000FF0
$change = 1 ; new ButtonColor on
$butset1 = GUICtrlCreatePng($set, $clickbutton, 4, 28, "Button Function", $Font, $FontSize, 0xFFFFFFFF)
$ButtColor = 0xF0000000
$butset2 = GUICtrlCreatePng($set, $clickbutton, 4, 45, "Button Color", $Font, $FontSize, 0xFFFFFFFF)
$ButtColor = 0xFFFFFFFF
$butset3 = GUICtrlCreatePng($set, $clickbutton, 4, 62, "New Button", $Font, $FontSize, 0xF0000000)
$change = 0 ; new ButtonColor off
GUISetState(@SW_SHOW, $set)
While 1
$nMsg = GUIGetMsg()
If $nMsg = $butset1 Then ; click buttons ?
MsgBox(0,"Button Function", "Click the Button for change Function!")
changebutton()
EndIf
Switch $nMsg
Case $GUI_EVENT_CLOSE ; i remove it later
ExitLoop
EndSwitch
WEnd
GUIDelete($set) ; close Settings-Window
EndFunc ;==>Settings
Func changebutton()
Local $function, $aWinPos = WinGetPos("[active]")
While 1
$nMsg = GUIGetMsg()
For $a = 2 To $nr - 1
If $nMsg = $buttons[$a] Then ; click buttons ?
$function = InputBox('New Function', 'Change your Button function:', $data[$a + 1][0], '', 270, 130, $aWinPos[0] + $aWinPos[2] / 2 - 135, $aWinPos[1] + 150, 0)
; MsgBox(0,"Button Function", $data[$a + 1][0])
EndIf
Next
Switch $nMsg
Case $GUI_EVENT_CLOSE ; i remove it later
ExitLoop
EndSwitch
WEnd
EndFunc
; Funktion by alexanderschill
; $Wintitle = Fenstertitel
; $Text = Fenstertest
; $SPEED = Schnelligkeit des Fadens (1-255)
; $FADE = 1 - Fade In | 2 - Fade Out
Func _FADE($WINTITLE, $text, $SPEED, $FADE)
While $FADE = 1
WinSetTrans($WINTITLE, "", 0)
GUISetState(@SW_SHOW)
$TRANSPARENCY = 0
For $TRANSPARENCY = 0 To 255 Step +$SPEED
WinSetTrans($WINTITLE, $text, $TRANSPARENCY)
Sleep(10)
Next
ExitLoop
WEnd
While $FADE = 2
$TRANSPARENCY = 255
For $TRANSPARENCY = 255 To 0 Step -$SPEED
WinSetTrans($WINTITLE, $text, $TRANSPARENCY)
Sleep(10)
Next
ExitLoop
WEnd
EndFunc ;==>_FADE
Func WinGetTrans($WINTITLE, $text = "")
Local $hWnd = WinGetHandle($WINTITLE, $text)
If Not $hWnd Then Return -1
Local $val = DllStructCreate("int")
Local $aRet = DllCall("user32.dll", "int", "GetLayeredWindowAttributes", "hwnd", $hWnd, "ulong_ptr", 0, "int_ptr", DllStructGetPtr($val), "ulong_ptr", 0)
If @error Or Not $aRet[0] Then Return -1
Return DllStructGetData($val, 1)
EndFunc ;==>WinGetTrans
;--------------------------------------------------------------------------------------------------
; Funktion _RecursiveFileSearch($FILE, $SEARCHFOLDER)
;
; Beschreibung Sucht nach vorgegebener Datei in einem Ordner rekursiv
;
; Parameter $FILE: zu suchende Datei
; $SEARCHFOLDER: Ordner für Suchstart
;
; Rückgabe Erfolg: Pfad der gesuchten Datei
; @error = 0
; Fehler: 1-kein Dateiname / 2-kein Ordnername übergeben (3-beides); 4-Datei nicht vorhanden
; @error = 1
;
; Autor BugFix ([email='bugfix@autoit.de'][/email])
;--------------------------------------------------------------------------------------------------
Func _RecursiveFileSearch($FILE, $SEARCHFOLDER)
Global $PathFound = ""
Dim $Fehler = 0
If $FILE = "" Then
SetError(1)
$Fehler += 1
EndIf
If $SEARCHFOLDER = "" Then
SetError(1)
$Fehler += 2
EndIf
If @error Then Return $Fehler
If FileExists($SEARCHFOLDER & $FILE) Then
Return $SEARCHFOLDER & $FILE
EndIf
SetError(0)
$FSO = ObjCreate("Scripting.FileSystemObject")
ShowSubFolders($FSO.GetFolder($SEARCHFOLDER), $FILE)
If $PathFound = "" Then
SetError(1)
$Fehler = 4
Return $Fehler
Else
SetError(0)
EndIf
Return $PathFound
EndFunc ;==>_RecursiveFileSearch
Mein Script+Grafik hier: autoit.de/wcf/attachment/12344/
So, das war auch schon alles.
mfg
tv_freeze