Ich habe den Code von Post#17 aktualisiert.
Gruß,
UEZ
Ich habe den Code von Post#17 aktualisiert.
Gruß,
UEZ
Probiere es mal damit:
#include <GDIPlus.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]Global $vGUIWidth = 400, $vGUIHeight = 400
Global $hGraphic, $hBitmap, $hBackbuffer, $hImage, $hTexture
Global $hGUI = GUICreate("", $vGUIWidth, $vGUIHeight, -1, -1)
Global $hGUI2 = GUICreate("", $vGUIWidth, $vGUIHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_MDICHILD, $hGUI)
GUISetBkColor(0xABCDEF, $hGUI2)
Global $lv = GUICtrlCreateListView("col1|col2", 10, 10, 200, 200, $LVS_NOCOLUMNHEADER)
GUICtrlSetBkColor(-1, 0xABCDEF)
GUICtrlSetColor(-1, 0x004000)
Global $b = GUICtrlCreateButton("Exit", 10, $vGUIHeight - 50)
_SetXPStyle(0)
Global $g = GUICtrlCreateGroup("Gruppe1", 220, 10, 160, 150)
GUICtrlSetColor(-1, 0x000040)
GUICtrlSetBkColor(-1, -2);...
_SetXPStyle(1)
GUISetState(@SW_SHOW, $hGUI2)
GUISetState(@SW_SHOW, $hGUI)
_WinAPI_SetLayeredWindowAttributes($hGUI2, 0xABCDEF)
[/autoit] [autoit][/autoit] [autoit]$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($vGUIWidth, $vGUIHeight, $hGraphic)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\test.jpg")
$hTexture = _GDIPlus_TextureCreate($hImage)
_GDIPlus_GraphicsFillRect($hBackbuffer, 0, 0,$vGUIWidth, $vGUIHeight, $hTexture)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $vGUIWidth, $vGUIHeight)
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")
[/autoit] [autoit][/autoit] [autoit]For $i = 0 To 50
_GUICtrlListView_AddItem($lv, Random(0x111111, 0xFFFFFF, 1))
Next
Do
Until GUIGetMsg() = -3
_GDIPlus_ImageDispose($hImage)
_GDIPlus_BrushDispose($hTexture)
_GDIPlus_GraphicsDispose($hBackbuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
GUIDelete($hGUI2)
GUIDelete($hGUI)
Exit
Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $vGUIWidth, $vGUIHeight)
Return 1
EndFunc ;==>WM_PAINT
Func _SetXPStyle($b_Set = 1); 0 = deactivate, 1 = activate
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $b_Set * 7)
EndFunc
Func _GDIPlus_TextureCreate($hImage, $iWrapMode = 0)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "hwnd", $hImage, "int", $iWrapMode, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[3]
EndFunc ;==>_GDIPlus_TextureCreate
Gruß,
UEZ
Ich dachte da eher an eine Funktion wie _GDIPlus_GraphicsSetInterpolationMode() bei GDI+, wo du 8 Stufen für die Qualität hat. Da ihr hier mit GDI+ nichts macht, weiß ich nicht, ob man das zusätzlich noch einbauen kann.
Gruß,
UEZ
Viele Leute benutzen die hier vorgestellten Programme regelmäßig?
Mir persönlich geht es nicht darum, irgendwelche Applikation für die Masse zu schreiben, sondern eher eine Art Code Demonstration. Es ist natürlich von Vorteil, wenn es Kommentare gibt, um den Code zu optimieren oder Fehler zu beseitigen. Wenn jemand noch das Programm nutzt, dann waren die Bemühungen nicht ganz umsonst.
Da die meisten hier ihre Programme vorstellen, ist natürlich ein Feedback wünschenswert, unabhängig davon, ob man es einsetzt oder nicht.
Und wenn's kein Feedback gibt, c'est la vie - auch kein Problem.
Ich persönlich teste auch nicht alles, was hier vorgestellt wird und deshalb bin ich auch nicht sauer darüber...
Gruß,
UEZ
Da kann ich mich nur anschließen, aber wie sagt der Franzose: "C'est la vie"! ![]()
Gruß,
UEZ
Du könntest alternativ die ConsoleWrite() Funktion nehmen und #AutoIt3Wrapper_Change2CUI=y als Wrapper nehmen.
Gruß,
UEZ
ZitatUEZ, vom Clientfenster kann ich mit deinem Screenshooter kein Bild machen. Bis auf die Titelzeile ist der Screenshoot leer.
MIt dem Snipet Tool funzt es aber, siehe Bild oben.
Das hat leider mit der Funktion: DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "handle", $hMemDC, "int", 0) zu tun. Ich kenne leider keine andere Funktion, die von verdeckten Fenstern ein Screenshot machen kann. Ferner funzt das Ganze auch nicht mit GDI+ Fenstern richtig!
Wenn du auch die "Grab Screen" Funktion nimmst, kannst du das Fenster manuell "grabben" oder F11/F12 als Fullscreen Screenshot.
Wenn du als Pixelfehler die "Streifen" auf hellem Hintergrund meinst, dann sehe ich sie auch, aber das ist nicht so schlimm.
Gruß,
UEZ
Letztes Update.
Gruß,
UEZ
Klasse Arbeit! ![]()
Gefällt mir sehr gut! ![]()
Wenn man noch die Bildqualität erhöhen könnte, wäre das echt super!
Gruß,
UEZ
Ich habe den Code aktualisiert.
Gruß,
UEZ
Hier der Code aus Windows Screenshooter:
HotKeySet("{ESC}","_exit")
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#Include <GDIPlus.au3>
_GDIPlus_Startup()
$x = 0
$y = 0
$width = @DesktopWidth
$height = @DesktopHeight
$hBitmap = Grab_Region($x, $y, $width, $height)
$hGui = GUICreate("_WinAPI_BitBlt", $width, $height, $x, $y, $WS_POPUP,$WS_EX_TOPMOST)
GUISetState(@SW_SHOW)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $width, $height)
While GUIGetMsg() <> -3
Sleep(100)
WEnd
Func _exit()
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
Exit
EndFunc
Func Grab_Region($x, $y, $w, $h)
Local $hDC = _WinAPI_GetDC(0)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $memBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $w, $h)
Local $hObj = _WinAPI_SelectObject($hMemDC, $memBitmap)
_WinAPI_BitBlt($hMemDC, 0, 0, $w, $h, $hDC, $x, $y, $SRCCOPY)
Local $aCursor = _WinAPI_GetCursorInfo()
If $aCursor[1] Then
Local $hIcon = _WinAPI_CopyIcon($aCursor[2])
Local $aIcon = _WinAPI_GetIconInfo($hIcon)
_WinAPI_DeleteObject($aIcon[4])
_WinAPI_DrawIcon($hMemDC, $aCursor[3] - $aIcon[2], $aCursor[4] - $aIcon[3], $hIcon)
_WinAPI_DestroyIcon($hIcon)
EndIf
Local $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($memBitmap)
_WinAPI_DeleteDC($hMemDC)
_WinAPI_DeleteObject($memBitmap)
_WinAPI_ReleaseDC(0, $hDC)
_WinAPI_DeleteDC($hDC)
Return SetError(0, 0, $hBmp)
EndFunc
Gruß,
UEZ
Poste mal dein GUI Code, denn ich habe eine Idee, wie du ein GDI+ Bild im Hintergrund haben kannst, ohne das die GUI Controls langsam aufgebaut werden.
Gruß,
UEZ
Wie sieht's denn bei dir aus? Wie sind deine Monitore angeordnet?
Bei mir geht's. Ich habe 2 Monitore nebeneinander und das Bild ist über beide gestreckt.
Gruß,
UEZ
Wenn du mit GDI+ arbeitest, dann solltest du dir die Windows Message Codes näher anschauen.
Ich benutze dafür i.d.R. WM_ERASEBKGND.
Such nach WM_ERASEBKGND und du wirst eine Menge Beiträge dazu finden!
Gruß,
UEZ
Probiere es mal damit:
#include <GDIPlus.au3>
$hFullScreen = WinGetHandle("Program Manager")
$aFullScreen = WinGetPos($hFullScreen)
$x0 = $aFullScreen[0]
$y0 = $aFullScreen[1]
$width = $aFullScreen[2]
$height = $aFullScreen[3]
$Gui = GUICreate ("Test",$width,$height,$x0,$y0,0x80000000)
GUISetState ()
_GDIPlus_Startup ()
$Graphics = _GDIPlus_GraphicsCreateFromHWND ($Gui)
_GDIPlus_GraphicsSetSmoothingMode ($Graphics,2)
$Pen = _GDIPlus_PenCreate(0xFF000000,20)
_GDIPlus_GraphicsDrawRect ($Graphics,5,$height -110,100,100,$Pen)
Dim $aPoints[4][2]
$aPoints[0][0] = 3
$aPoints[1][0] = $x0
$aPoints[1][1] = $height - 100
$aPoints[2][0] = $width /2
$aPoints[2][1] = $height - 130
$aPoints[3][0] = $width
$aPoints[3][1] = $height -100
_GDIPlus_GraphicsDrawCurve ($Graphics,$aPoints,$Pen)
While 1
Switch GUIGetMsg ()
Case -3
Exit
EndSwitch
WEnd
Habe zur Zeit kein Multimonitor Betrieb; erst wieder morgen!
Gruß,
UEZ
Das ist leider nicht so einfach, wie du dir das denkst! -> JPEG
Gruß,
UEZ
Das funzt auch bei mir unter Win7 x64 (Beispiel aus dem engl. Forum):
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=..\..\..\..\PROGRAMDATA\MY Docs\Auto It\Test\rebar_test.exe
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GuiReBar.au3>
#include <GuiToolBar.au3>
#include <GuiComboBox.au3>
#include <GuiDateTimePicker.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiConstantsEx.au3>
Opt("MustDeclareVars", 1)
$Debug_RB = False
Global $hReBar, $hgui, $btnExit, $hToolbar, $hCombo, $hDTP, $hInput
Global Const $WMSZ_LEFT = 1
Global Const $WMSZ_RIGHT = 2
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUIRegisterMsg($WM_SIZING, "WM_SIZING")
_main()
Func _main()
Local Enum $idNew = 1000, $idOpen, $idSave, $idHelp
$hgui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))
; create the rebar control
$hReBar = _GUICtrlRebar_Create($hgui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))
; create a toolbar to put in the rebar
$hToolbar = _GUICtrlToolbar_Create($hgui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))
; Add standard system bitmaps
Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
Case 0
_GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
Case 2
_GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
EndSwitch
; Add buttons
_GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW)
_GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN)
_GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE)
_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)
; create a combobox to put in the rebar
$hCombo = _GUICtrlComboBox_Create($hgui, "", 0, 0, 120)
_GUICtrlComboBox_BeginUpdate($hCombo)
_GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
_GUICtrlComboBox_EndUpdate($hCombo)
; create a date time picker to put in the rebar
$hDTP = _GUICtrlDTP_Create($hgui, 0, 0, 190)
; add band with control
_GUICtrlRebar_AddBand($hReBar, $hCombo, 120, 200, "Dir *.exe")
; add band with date time picker
_GUICtrlRebar_AddBand($hReBar, $hDTP, 120)
; add band with toolbar to begining of rebar
_GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)
;add another control
_GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($hInput), 120, 200, "Name:")
$btnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $btnExit
Exit
EndSwitch
WEnd
EndFunc ;==>_main
Func WM_SIZE($hWnd)
Local $wpos
$wpos = WinGetPos($hWnd)
ControlMove($hWnd, "", $hReBar, 0, 0, $wpos[2])
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SIZE
Func WM_SIZING($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $wParam, $lParam
Switch $wParam ;drag side or corner
Case $WMSZ_LEFT, $WMSZ_RIGHT
_WinAPI_RedrawWindow($hgui, 0, 0, $RDW_UPDATENOW + $RDW_INVALIDATE + $RDW_ALLCHILDREN)
Case Else
_WinAPI_RedrawWindow($hgui, 0, 0, $RDW_UPDATENOW + $RDW_INVALIDATE + $RDW_ALLCHILDREN)
EndSwitch
Return "GUI_RUNDEFMSG"
EndFunc ;==>WM_SIZING
Func _DebugPrint($s_text, $line = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @LF & _
"+======================================================" & @LF & _
"-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
"+======================================================" & @LF)
EndFunc ;==>_DebugPrint
Gruß,
UEZ
Zitat
2. betrifft mein Unvermögen, da ich noch ganz am Anfang der Programmierungsversuche stehe.Wenn ich zum Testen den Downloader hier nehme, und es um eine banale Groupbox ergänzen will, werden mir große Teile des Inhaltes und der Animation verschluckt. Gut dachte ich, vermutlich muss ich der Groupbox noch ein Attribut mitgeben, das der Hintergrund durchsichtig ist ( Function GUICtrlSetBkColor mit $GUI_BKCOLOR_TRANSPARENT )
Das klappt aber nicht.
Nehm ich die Animation raus, geht es. ich habe lediglich den befehl GuiCtrlCreateGroup hinzugefügt.
GuiCtrlCreateGroup() erstellt anscheinend ein Label mit einem Rahmen. Wenn ich ein Label mit den gleichen Dimensionen erstelle, habe ich den gleichen Effekt, da die kompletten Controls überdeckt werden.
Hier 2 Alternativen, die mir auf die Schnelle eingefallen sind:
1:
;Coded by UEZ 2010/2011 - thanks to Ximorro for the idea with the bubbles ![]()
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_UseX64=n
;~ #AutoIt3Wrapper_Icon=
#AutoIt3Wrapper_Res_Description=Simple downloader made with AutoIt
#AutoIt3Wrapper_Res_Fileversion=0.9.6.0
#AutoIt3Wrapper_Res_LegalCopyright=UEZ 2010/2011
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_Field=Coded by|UEZ
#AutoIt3Wrapper_Res_Field=Build|2011-01-20 Beta
#AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time%
#AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer%
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_UPX_Parameters=--ultra-brute
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3"
#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
Opt("GUICloseOnESC", 0)
#region GUI
Global Const $width = 615, $height = 266
Global $hGUI = GUICreate("Tiny URL Downloader v0.96 Build 2011-01-20 by UEZ " & ChrW(9996), $width, $height)
WinSetTrans($hGUI,"", 0xFF);
Global $bg_color = "E0E0F0"
GUISetBkColor("0x" & $bg_color, $hGUI)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Global $Input_URL = GUICtrlCreateInput("http://translation.autoit.de/autoitinfo/hilfedateien/AutoIt-Hilfe-Deutsch-3.3.6.1-Stand-07_09_10.zip", 64, 24, 497, 21)
;~ Global $Group = GuiCtrlCreateGroup("", 3, 5, $width - 6, 220, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT))
;~ GUICtrlCreateGroup("", -99, -99, 1, 1)
;Pseudo group
Global $Lx = 3
Global $Ly = 10
Global $Lw= $width - 5
Global $Lh = $height - 40
Global $Line1 = GUICtrlCreateLabel("", $lx, $ly, $Lw, 1, $SS_SUNKEN)
Global $Line2 = GUICtrlCreateLabel("", $lx, $Lh, $Lw, 1, $SS_SUNKEN)
Global $Line3 = GUICtrlCreateLabel("", $Lx, $ly, 1, $Lh - 9, $SS_SUNKEN)
Global $Line4 = GUICtrlCreateLabel("", $Lw, $ly, 1, $Lh - 9, $SS_SUNKEN)
GUICtrlSetTip(-1, "Type in any valid URL address (http://, https://, ftp://)!")
Global $Label1 = GUICtrlCreateLabel("URL:", 32, 27, 28, 14)
GUICtrlSetBkColor(-1, -2)
GUICtrlSetFont(-1, 9, 400, 1, "Arial")
Global $Start_DL = GUICtrlCreateButton("&Download", 64, 128, 75, 25)
GUICtrlSetOnEvent(-1, "Start_DL")
GUICtrlSetTip(-1, "Press Download button to start download")
Global $Stop_DL = GUICtrlCreateButton("&Cancel", 488, 128, 75, 25)
GUICtrlSetOnEvent(-1, "Stop_DL")
GUICtrlSetTip(-1, "Press Cancel button to stop download")
GUICtrlSetState(-1, $GUI_DISABLE)
Global $Exit = GUICtrlCreateButton("&Exit", 276, 128, 75, 25)
GUICtrlSetOnEvent(-1, "_Exit")
GUICtrlSetTip(-1, "Close program")
Global $Progress = GUICtrlCreateProgress(8, 182, 598, 32)
Global $StatusBar = _GUICtrlStatusBar_Create($hGUI)
_GUICtrlStatusBar_SetText($StatusBar, "Ready")
Global $aStatusBar = ControlGetPos("", "", $StatusBar)
Global $dh = $aStatusBar[3] ;get the heigth of the statusbar
Global $Input_Save_To = GUICtrlCreateInput(@ScriptDir, 64, 80, 410, 21)
Global $Label2 = GUICtrlCreateLabel("Save to:", 17, 82, 44, 17)
GUICtrlSetFont(-1, 9, 400, 1, "Arial")
GUICtrlSetBkColor($Label2, -2)
Global $Save_To = GUICtrlCreateButton("&Select Folder", 486, 78)
GUICtrlSetOnEvent(-1, "Select_Folder")
GUICtrlSetTip(-1, "Select a folder where you want to save the downloaded file (UNC path not supported yet!)")
Global $ContextMenu = GUICtrlCreateContextMenu()
Global $Submenu_Anim = GUICtrlCreateMenu("Animation", $ContextMenu)
Global $Anim_Start = GUICtrlCreateMenuItem("Start", $Submenu_Anim)
Global $Anim_Stop = GUICtrlCreateMenuItem("Stop", $Submenu_Anim)
Global $Anim_Seperator = GUICtrlCreateMenuItem("", $Submenu_Anim)
Global $Anim_Disable = GUICtrlCreateMenuItem("Disable", $Submenu_Anim)
GUICtrlSetState($Anim_Start, $GUI_CHECKED)
GUICtrlSetState($Anim_Stop, $GUI_UNCHECKED)
Global $Display_Anim = True
Global $Disable_Anim = False
GUICtrlSetOnEvent($Anim_Start, "Start_Anim")
GUICtrlSetOnEvent($Anim_Stop, "Stop_Anim")
GUICtrlSetOnEvent($Anim_Disable, "Disable_Anim")
GUISetState(@SW_SHOW)
ControlFocus($hGUI, "", $Start_DL)
#endregion
#region GDI+ init
_GDIPlus_Startup()
Global $i
Global Const $bubbles = 16, $max_speed = 5, $min_size = 30, $max_size = 70
Global $aData[$bubbles][6] ;x,y,vx,vy,size,bmp
For $i = 0 To $bubbles - 1
$aData[$i][0] = Random(0, $width - $max_size, 1)
$aData[$i][1] = Random(0, $height - $max_size, 1)
$aData[$i][2] = _Random(-$max_speed, $max_speed, -1.5, 1.5) ;vx
$aData[$i][3] = _Random(-$max_speed, $max_speed, -1.5, 1.5) ;vy
$aData[$i][4] = Random($min_size, $max_size, 1) ;size
;~ $aData[$i][5] = _CreateBubbleBitmap($aData[$i][4], "0xA0" & Hex(Random(0xA0A0A0, 0xF0F0F0, 1), 6), "0xA0" & Hex(Random(0x808080, 0xF0F0F0, 1), 6)) ;handle to bitmap
$aData[$i][5] = _CreateBubbleBitmap($aData[$i][4]) ;handle to bitmap
Next
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic)
Global $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Global $hBrush = _GDIPlus_BrushCreateSolid("0xFF" & $bg_color)
_GDIPlus_GraphicsClear($hBackbuffer, "0xFF" & $bg_color)
Global Const $GW_CHILD = 5, $GW_HWNDNEXT = 2
Global $hRegion = _GDIPlus_RegionCreateFromRect(_GDIPlus_RectFCreate(0, 0, $width, $height))
Global $hChild = _WinAPI_GetWindow($hGUI, $GW_CHILD)
Global $aRect
Do
$aRect = ControlGetPos($hChild, "", 0)
_GDIPlus_RegionCombineRect($hRegion, _GDIPlus_RectFCreate($aRect[0], $aRect[1], $aRect[2], $aRect[3]), 3)
$hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT)
Until Not $hChild
_GDIPlus_GraphicsSetClipRegion($hGraphic, $hRegion)
_GDIPlus_RegionDispose($hRegion)
;~ AdlibRegister("Start_Animation", 50)
GUIRegisterMsg(0x0113, "Start_Animation") ;$WM_TIMER = 0x0113
DllCall("User32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", 50, "int", 0) ;set GUIRegisterMsg($WM_TIMER, "Draw") timer
#endregion GDI+ init
Global $hDownload, $nBytes, $nRead, $nSize, $calc, $file, $url, $current
Global $speed = 0
Global $prog = 0
Global $stop = 0
While Sleep(0x7FFFFF)
WEnd
Func Disable_Anim()
$Display_Anim = False
$Disable_Anim = True
GUICtrlSetState($Anim_Start, $GUI_UNCHECKED)
GUICtrlSetState($Anim_Stop, $GUI_UNCHECKED)
GUICtrlSetState($Anim_Disable, $GUI_CHECKED)
EndFunc ;==>Disable_Anim
Func Start_Anim()
$Display_Anim = True
$Disable_Anim = False
GUICtrlSetState($Anim_Start, $GUI_CHECKED)
GUICtrlSetState($Anim_Stop, $GUI_UNCHECKED)
GUICtrlSetState($Anim_Disable, $GUI_UNCHECKED)
EndFunc ;==>Start_Anim
Func Stop_Anim()
$Display_Anim = False
$Disable_Anim = False
GUICtrlSetState($Anim_Start, $GUI_UNCHECKED)
GUICtrlSetState($Anim_Stop, $GUI_CHECKED)
GUICtrlSetState($Anim_Disable, $GUI_UNCHECKED)
EndFunc ;==>Stop_Anim
Func _Random($min, $max, $emin, $emax, $int = 0)
Local $r1 = Random($min, $emin, $int)
Local $r2 = Random($emax, $max, $int)
If Random(0, 1, 1) Then Return $r1
Return $r2
EndFunc ;==>_Random
Func Select_Folder()
Local $folder = FileSelectFolder("Select a folder", "", 5)
If @error Or StringMid($folder, 2, 2) <> ":\" Then Return
GUICtrlSetData($Input_Save_To, $folder)
EndFunc ;==>Select_Folder
Func Start_DL()
Local $mc = MouseGetCursor()
$url = GUICtrlRead($Input_URL)
$file = GUICtrlRead($Input_Save_To)
If $url <> "" And $file <> "" Then
GUISetOnEvent($GUI_EVENT_CLOSE, "")
Disable_Buttons()
GUISetCursor(15, 0, $hGUI)
Sleep(100)
$nSize = InetGetSize($url)
If $nSize < 1 Then
GUISetCursor($mc, 0, $hGUI)
Enable_Buttons()
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
MsgBox(16, "Error", "Unable to get file size from server!" & @CRLF & @CRLF & "Check URL or maybe server down!", 15)
Return
EndIf
GUISetCursor($mc, 0, $hGUI)
$file &= "\" & StringRight($url, StringLen($url) - StringInStr($url, "/", 0, -1)) & ".tmp"
$hDownload = InetGet($url, $file, 1, 1)
AdlibRegister("DL_Check", 50)
$current = 0
AdlibRegister("DL_Speed", 1000)
EndIf
EndFunc ;==>Start_DL
Func DL_Check()
Local $msg
If InetGetInfo($hDownload, 2) Or $stop Then
InetClose($hDownload)
Enable_Buttons()
AdlibUnRegister("DL_Check")
AdlibUnRegister("DL_Speed")
If $stop Then
$msg = MsgBox(4 + 48, "Warning", "Download was cancelled!" & @LF & @LF & _
" Delete incomplete file?", 20)
Switch $msg
Case -1, 6
FileDelete($file)
If @error Then $msg = MsgBox(16, "Error", "Unable to delete file, maybe locked by another process!" & @CRLF & _
"Check manually!", 20)
EndSwitch
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Else
GUICtrlSetData($Progress, 100)
_GUICtrlStatusBar_SetText($StatusBar, $nSize & " / " & $nSize & " bytes (100 % @ " & $speed & " kb/s)")
FileMove($file, StringLeft($file, StringLen($file) - 4), 9)
MsgBox(0, "Information", "Download completed!", 20)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
EndIf
$stop = 0
GUICtrlSetData($Progress, 0)
_GUICtrlStatusBar_SetText($StatusBar, "Ready")
Else
$nRead = InetGetInfo($hDownload, 0)
$calc = Int(100 * $nRead / $nSize)
GUICtrlSetData($Progress, $calc)
_GUICtrlStatusBar_SetText($StatusBar, $nRead & " / " & $nSize & " bytes (" & $calc & " % @ " & $speed & " kb/s)")
EndIf
EndFunc ;==>DL_Check
Func Enable_Buttons()
GUICtrlSetState($Start_DL, $GUI_ENABLE)
GUICtrlSetState($Stop_DL, $GUI_DISABLE)
GUICtrlSetState($Exit, $GUI_ENABLE)
GUICtrlSetState($Input_Save_To, $GUI_ENABLE)
GUICtrlSetState($Input_URL, $GUI_ENABLE)
GUICtrlSetState($Save_To, $GUI_ENABLE)
EndFunc ;==>Enable_Buttons
Func Disable_Buttons()
GUICtrlSetState($Start_DL, $GUI_DISABLE)
GUICtrlSetState($Exit, $GUI_DISABLE)
GUICtrlSetState($Input_Save_To, $GUI_DISABLE)
GUICtrlSetState($Input_URL, $GUI_DISABLE)
GUICtrlSetState($Save_To, $GUI_DISABLE)
GUICtrlSetState($Stop_DL, $GUI_ENABLE)
EndFunc ;==>Disable_Buttons
Func DL_Speed()
$speed = Round(($nRead - $current) / 1024, 2)
$current = $nRead
EndFunc ;==>DL_Speed
Func Stop_DL()
$stop = 1
EndFunc ;==>Stop_DL
Func _Exit()
InetClose($hDownload)
Close_GDIplus()
GUIDelete($hGUI)
Exit
EndFunc ;==>_Exit
#region GDI+
Func Start_Animation()
Local $j
;draw bubbles
If $Disable_Anim Then _GDIPlus_GraphicsClear($hGraphic, "0xFF" & $bg_color)
If $Display_Anim Then
;~ _GDIPlus_GraphicsClear($hBackbuffer, "0xFF" & $bg_color)
_GDIPlus_GraphicsFillRect($hBackbuffer, 0, 0, $width, $height, $hBrush)
For $j = 0 To $bubbles - 1
_GDIPlus_GraphicsDrawImage($hBackbuffer, $aData[$j][5], $aData[$j][0], $aData[$j][1])
Next
;calculate new position incl. border collision check
For $j = 0 To $bubbles - 1
$aData[$j][0] += $aData[$j][2] ;increase x coordinate with appropriate slope
$aData[$j][1] += $aData[$j][3] ;increase y coordinate with appropriate slope
If $aData[$j][0] <= 0 Then ;border collision x left
$aData[$j][0] = 1
$aData[$j][2] *= -1
ElseIf $aData[$j][0] >= $width - $aData[$j][4] Then ;border collision x right
$aData[$j][0] = $width - ($aData[$j][4] + 1)
$aData[$j][2] *= -1
EndIf
If $aData[$j][1] <= 0 Then ;border collision y top
$aData[$j][1] = 1
$aData[$j][3] *= -1
ElseIf $aData[$j][1] >= $height - $aData[$j][4] - $dh Then ;border collision y bottom
$aData[$j][1] = $height - ($aData[$j][4] + 1) - $dh
$aData[$j][3] *= -1
EndIf
Next
Collision_Check()
EndIf
If Not $Disable_Anim Then _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $width, $height)
EndFunc ;==>Start_Animation
Func Collision_Check() ;0:x, 1:y, 2:vx, 3:vy, 4:size, 5:bmp
Local $Delta_X, $Delta_Y, $Distance, $Matrix11, $Matrix12, $Matrix21, $Matrix22, $Vp1, $Vp2, $Vs1, $Vs2
For $i = 0 To $bubbles - 1
For $j = $i + 1 To $bubbles - 1
If Pixel_Distance($aData[$i][0], $aData[$i][1], $aData[$j][0], $aData[$j][1]) < ($aData[$i][4] + $aData[$j][4]) / 2 Then
$Delta_X = $aData[$i][0] - $aData[$j][0]
$Delta_Y = $aData[$i][1] - $aData[$j][1]
$Distance = Sqrt($Delta_X * $Delta_X + $Delta_Y * $Delta_Y)
$Matrix11 = $Delta_X / $Distance
$Matrix12 = -$Delta_Y / $Distance
$Matrix21 = $Delta_Y / $Distance
$Matrix22 = $Delta_X / $Distance
$Vp1 = $aData[$i][2] * $Matrix11 + $aData[$i][3] * - $Matrix12
$Vs1 = $aData[$i][2] * - $Matrix21 + $aData[$i][3] * $Matrix22
$Vp2 = $aData[$j][2] * $Matrix11 + $aData[$j][3] * - $Matrix12
$Vs2 = $aData[$j][2] * - $Matrix21 + $aData[$j][3] * $Matrix22
If $Vp1 - $Vp2 < 0 Then
$aData[$i][2] = $Matrix11 + $Vs1 * $Matrix12
$aData[$i][3] = $Matrix21 + $Vs1 * $Matrix22
$aData[$j][2] = $Matrix11 + $Vs2 * $Matrix12
$aData[$j][3] = $Matrix21 + $Vs2 * $Matrix22
EndIf
EndIf
Next
Next
EndFunc ;==>Collision_Check
Func Pixel_Distance($x1, $y1, $x2, $y2) ;Pythagoras theorem
Local $a, $b
If $x2 = $x1 And $y2 = $y1 Then Return 0
$a = $y2 - $y1
$b = $x2 - $x1
Return Sqrt($a * $a + $b * $b)
EndFunc ;==>Pixel_Distance
Func Close_GDIplus()
;~ AdlibUnRegister("Start_Animation")
GUIRegisterMsg(0x0113, "")
_GDIPlus_BrushDispose($hBrush)
For $i = 0 To $bubbles - 1
_GDIPlus_BitmapDispose($aData[$i][5])
Next
_GDIPlus_GraphicsDispose($hBackbuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
EndFunc ;==>Close_GDIplus
Func _CreateBubbleBitmap($size = 75, $gradient_start = 0xA0F0C0C0, $gradient_end = 0xA0C0F0C0, $angle1 = 90, $angle2 = 45, $pen1 = 0x55AAAAAF, $pen2 = 0x50FFFFFF)
Local $ps1 = 2, $ps2 = Int($size / 12)
Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($size, $size)
Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hContext, 2)
Local $Pen_Border = _GDIPlus_PenCreate($pen1, $ps1)
Local $Pen_Reflection = _GDIPlus_PenCreate($pen2, $ps2)
Local $Brush_Gradient = _GDIPlus_CreateLineBrush(0, 0, $size, $size, $gradient_start, $gradient_end)
_GDIPlus_GraphicsFillEllipse($hContext, 0, 0, $size, $size, $Brush_Gradient)
_GDIPlus_GraphicsDrawArc($hContext, $size / 3, $size / 5, $size / 2, $size / 2, 10, -$angle1, $Pen_Reflection)
_GDIPlus_GraphicsDrawArc($hContext, $size / 6, $size / 3.5, $size / 2, $size / 2, -210, -$angle2, $Pen_Reflection)
_GDIPlus_GraphicsDrawEllipse($hContext, 0, 0, $size - $ps1, $size - $ps1, $Pen_Border)
_GDIPlus_PenDispose($Pen_Border)
_GDIPlus_PenDispose($Pen_Reflection)
_GDIPlus_BrushDispose($Brush_Gradient)
_GDIPlus_GraphicsDispose($hContext)
Return $hBitmap
EndFunc ;==>_CreateBubbleBitmap
Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[6]
EndFunc ;==>_GDIPlus_BitmapCreateFromScan0
Func _GDIPlus_CreateLineBrush($iPoint1X, $iPoint1Y, $iPoint2X, $iPoint2Y, $iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $WrapMode = 0)
Local $tPoint1, $pPoint1, $tPoint2, $pPoint2, $aRet
If $iArgb1 = "" Then $iArgb1 = 0xFF0000FF
If $iArgb2 = "" Then $iArgb2 = 0xFFFF0000
If $WrapMode = -1 Then $WrapMode = 0
$tPoint1 = DllStructCreate("float X;float Y")
$pPoint1 = DllStructGetPtr($tPoint1)
DllStructSetData($tPoint1, "X", $iPoint1X)
DllStructSetData($tPoint1, "Y", $iPoint1Y)
$tPoint2 = DllStructCreate("float X;float Y")
$pPoint2 = DllStructGetPtr($tPoint2)
DllStructSetData($tPoint2, "X", $iPoint2X)
DllStructSetData($tPoint2, "Y", $iPoint2Y)
$aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrush", "ptr", $pPoint1, "ptr", $pPoint2, "int", $iArgb1, "int", $iArgb2, "int", $WrapMode, "int*", 0)
Return $aRet[6]
EndFunc ;==>_GDIPlus_CreateLineBrush
Func _GDIPlus_GraphicsSetClipRegion($hGraphics, $hRegion, $iCombineMode = 0)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetClipRegion", "hwnd", $hGraphics, "hwnd", $hRegion, "int", $iCombineMode)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_GraphicsSetClipRegion
Func _GDIPlus_RegionCreateFromRect($tRectF)
Local $pRectF, $aResult
$pRectF = DllStructGetPtr($tRectF)
$aResult = DllCall($ghGDIPDll, "uint", "GdipCreateRegionRect", "ptr", $pRectF, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[2]
EndFunc ;==>_GDIPlus_RegionCreateFromRect
Func _GDIPlus_RegionCombineRect($hRegion, $tRectF, $iCombineMode = 2)
Local $pRectF, $aResult
$pRectF = DllStructGetPtr($tRectF)
$aResult = DllCall($ghGDIPDll, "uint", "GdipCombineRegionRect", "hwnd", $hRegion, "ptr", $pRectF, "int", $iCombineMode)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_RegionCombineRect
Func _GDIPlus_RegionDispose($hRegion)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDeleteRegion", "hwnd", $hRegion)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_RegionDispose
#endregion GDI+
2:
;Coded by UEZ 2010/2011 - thanks to Ximorro for the idea with the bubbles ![]()
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_UseX64=n
;~ #AutoIt3Wrapper_Icon=
#AutoIt3Wrapper_Res_Description=Simple downloader made with AutoIt
#AutoIt3Wrapper_Res_Fileversion=0.9.6.0
#AutoIt3Wrapper_Res_LegalCopyright=UEZ 2010/2011
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_Field=Coded by|UEZ
#AutoIt3Wrapper_Res_Field=Build|2011-01-20 Beta
#AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time%
#AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer%
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_UPX_Parameters=--ultra-brute
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3"
#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
Opt("GUICloseOnESC", 0)
#region GUI
Global Const $width = 615, $height = 266
Global $hGUI = GUICreate("Tiny URL Downloader v0.96 Build 2011-01-20 by UEZ " & ChrW(9996), $width, $height)
WinSetTrans($hGUI,"", 0xFF);
Global $bg_color = "E0E0F0"
GUISetBkColor("0x" & $bg_color, $hGUI)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Global $hGUI_Child = GUICreate("", $width, $height, 0, 0, $WS_POPUP + $WS_CLIPSIBLINGS, $WS_EX_MDICHILD + $WS_EX_LAYERED, $hGUI)
GUISetBkColor(0x123456)
_WinAPI_SetLayeredWindowAttributes($hGUI_Child, 0x123456, 0xFF)
Global $Lx = 3
Global $Ly = 10
Global $Lw= $width - 2 * $Lx
Global $Lh = $height - 48
Global $Group = GuiCtrlCreateGroup("UEZ'11 ", $Lx, $Ly, $Lw, $Lh, BitOR($GUI_SS_DEFAULT_GROUP, $BS_RIGHT, $BS_FLAT))
;~ Global $Group = GuiCtrlCreateGroup("", $Lx, $Ly, $Lw, $Lh, $SS_SUNKEN)
GUICtrlSetFont(-1, 6, 100, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetBkColor($Group, "0x" & $bg_color)
GUICtrlSetColor(-1, 0x0)
Global $Input_URL = GUICtrlCreateInput("http://translation.autoit.de/autoitinfo/hilfedateien/AutoIt-Hilfe-Deutsch-3.3.6.1-Stand-07_09_10.zip", 64, 24, 497, 21)
GUICtrlSetTip(-1, "Type in any valid URL address (http://, https://, ftp://)!")
Global $Label1 = GUICtrlCreateLabel("URL:", 32, 27, 28, 14)
GUICtrlSetBkColor(-1, "0x" & $bg_color)
GUICtrlSetFont(-1, 9, 200, 1, "Arial")
GUICtrlSetColor(-1, 0x0)
Global $Label2 = GUICtrlCreateLabel("Save to:", 17, 82, 44, 17)
GUICtrlSetFont(-1, 9, 200, 1, "Arial")
GUICtrlSetBkColor($Label2, "0x" & $bg_color)
GUICtrlSetColor(-1, 0x0)
Global $Start_DL = GUICtrlCreateButton("&Download", 64, 128, 75, 25)
GUICtrlSetOnEvent(-1, "Start_DL")
GUICtrlSetTip(-1, "Press Download button to start download")
Global $Stop_DL = GUICtrlCreateButton("&Cancel", 488, 128, 75, 25)
GUICtrlSetOnEvent(-1, "Stop_DL")
GUICtrlSetTip(-1, "Press Cancel button to stop download")
GUICtrlSetState(-1, $GUI_DISABLE)
Global $Exit = GUICtrlCreateButton("&Exit", 276, 128, 75, 25)
GUICtrlSetOnEvent(-1, "_Exit")
GUICtrlSetTip(-1, "Close program")
Global $Progress = GUICtrlCreateProgress(8, 182, 598, 32)
Global $StatusBar = _GUICtrlStatusBar_Create($hGUI_Child)
_GUICtrlStatusBar_SetText($StatusBar, "Ready")
Global $aStatusBar = ControlGetPos("", "", $StatusBar)
Global $dh = $aStatusBar[3] ;get the heigth of the statusbar
Global $Input_Save_To = GUICtrlCreateInput(@ScriptDir, 64, 80, 410, 21)
Global $Save_To = GUICtrlCreateButton("&Select Folder", 486, 78)
GUICtrlSetOnEvent(-1, "Select_Folder")
GUICtrlSetTip(-1, "Select a folder where you want to save the downloaded file (UNC path not supported yet!)")
Global $ContextMenu = GUICtrlCreateContextMenu()
Global $Submenu_Anim = GUICtrlCreateMenu("Animation", $ContextMenu)
Global $Anim_Start = GUICtrlCreateMenuItem("Start", $Submenu_Anim)
Global $Anim_Stop = GUICtrlCreateMenuItem("Stop", $Submenu_Anim)
Global $Anim_Seperator = GUICtrlCreateMenuItem("", $Submenu_Anim)
Global $Anim_Disable = GUICtrlCreateMenuItem("Disable", $Submenu_Anim)
GUICtrlSetState($Anim_Start, $GUI_CHECKED)
GUICtrlSetState($Anim_Stop, $GUI_UNCHECKED)
Global $Display_Anim = True
Global $Disable_Anim = False
GUICtrlSetOnEvent($Anim_Start, "Start_Anim")
GUICtrlSetOnEvent($Anim_Stop, "Stop_Anim")
GUICtrlSetOnEvent($Anim_Disable, "Disable_Anim")
GUISetState(@SW_SHOW, $hGUI)
GUISetState(@SW_SHOW, $hGUI_Child)
ControlFocus($hGUI_Child, "", $Start_DL)
#endregion
[/autoit] [autoit][/autoit] [autoit]#region GDI+ init
_GDIPlus_Startup()
Global $i
Global Const $bubbles = 10, $max_speed = 5, $min_size = 30, $max_size = 70
Global $aData[$bubbles][6] ;x,y,vx,vy,size,bmp
For $i = 0 To $bubbles - 1
$aData[$i][0] = Random(0, $width - $max_size, 1)
$aData[$i][1] = Random(0, $height - $max_size, 1)
$aData[$i][2] = _Random(-$max_speed, $max_speed, -1.5, 1.5) ;vx
$aData[$i][3] = _Random(-$max_speed, $max_speed, -1.5, 1.5) ;vy
$aData[$i][4] = Random($min_size, $max_size, 1) ;size
;~ $aData[$i][5] = _CreateBubbleBitmap($aData[$i][4], "0xA0" & Hex(Random(0xA0A0A0, 0xF0F0F0, 1), 6), "0xA0" & Hex(Random(0x808080, 0xF0F0F0, 1), 6)) ;handle to bitmap
$aData[$i][5] = _CreateBubbleBitmap($aData[$i][4]) ;handle to bitmap
Next
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic)
Global $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Global $hBrush = _GDIPlus_BrushCreateSolid("0xFF" & $bg_color)
_GDIPlus_GraphicsClear($hBackbuffer, "0xFF" & $bg_color)
GUIRegisterMsg(0x0113, "Start_Animation") ;$WM_TIMER = 0x0113
DllCall("User32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", 50, "int", 0) ;set GUIRegisterMsg($WM_TIMER, "Draw") timer
#endregion GDI+ init
Global $hDownload, $nBytes, $nRead, $nSize, $calc, $file, $url, $current
Global $speed = 0
Global $prog = 0
Global $stop = 0
While Sleep(0x7FFFFF)
WEnd
Func Disable_Anim()
$Display_Anim = False
$Disable_Anim = True
GUICtrlSetState($Anim_Start, $GUI_UNCHECKED)
GUICtrlSetState($Anim_Stop, $GUI_UNCHECKED)
GUICtrlSetState($Anim_Disable, $GUI_CHECKED)
EndFunc ;==>Disable_Anim
Func Start_Anim()
$Display_Anim = True
$Disable_Anim = False
GUICtrlSetState($Anim_Start, $GUI_CHECKED)
GUICtrlSetState($Anim_Stop, $GUI_UNCHECKED)
GUICtrlSetState($Anim_Disable, $GUI_UNCHECKED)
EndFunc ;==>Start_Anim
Func Stop_Anim()
$Display_Anim = False
$Disable_Anim = False
GUICtrlSetState($Anim_Start, $GUI_UNCHECKED)
GUICtrlSetState($Anim_Stop, $GUI_CHECKED)
GUICtrlSetState($Anim_Disable, $GUI_UNCHECKED)
EndFunc ;==>Stop_Anim
Func _Random($min, $max, $emin, $emax, $int = 0)
Local $r1 = Random($min, $emin, $int)
Local $r2 = Random($emax, $max, $int)
If Random(0, 1, 1) Then Return $r1
Return $r2
EndFunc ;==>_Random
Func Select_Folder()
Local $folder = FileSelectFolder("Select a folder", "", 5)
If @error Or StringMid($folder, 2, 2) <> ":\" Then Return
GUICtrlSetData($Input_Save_To, $folder)
EndFunc ;==>Select_Folder
Func Start_DL()
Local $mc = MouseGetCursor()
$url = GUICtrlRead($Input_URL)
$file = GUICtrlRead($Input_Save_To)
If $url <> "" And $file <> "" Then
GUISetOnEvent($GUI_EVENT_CLOSE, "")
Disable_Buttons()
GUISetCursor(15, 0, $hGUI)
Sleep(100)
$nSize = InetGetSize($url)
If $nSize < 1 Then
GUISetCursor($mc, 0, $hGUI)
Enable_Buttons()
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
MsgBox(16, "Error", "Unable to get file size from server!" & @CRLF & @CRLF & "Check URL or maybe server down!", 15)
Return
EndIf
GUISetCursor($mc, 0, $hGUI)
$file &= "\" & StringRight($url, StringLen($url) - StringInStr($url, "/", 0, -1)) & ".tmp"
$hDownload = InetGet($url, $file, 1, 1)
AdlibRegister("DL_Check", 50)
$current = 0
AdlibRegister("DL_Speed", 1000)
EndIf
EndFunc ;==>Start_DL
Func DL_Check()
Local $msg
If InetGetInfo($hDownload, 2) Or $stop Then
InetClose($hDownload)
Enable_Buttons()
AdlibUnRegister("DL_Check")
AdlibUnRegister("DL_Speed")
If $stop Then
$msg = MsgBox(4 + 48, "Warning", "Download was cancelled!" & @LF & @LF & _
" Delete incomplete file?", 20)
Switch $msg
Case -1, 6
FileDelete($file)
If @error Then $msg = MsgBox(16, "Error", "Unable to delete file, maybe locked by another process!" & @CRLF & _
"Check manually!", 20)
EndSwitch
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Else
GUICtrlSetData($Progress, 100)
_GUICtrlStatusBar_SetText($StatusBar, $nSize & " / " & $nSize & " bytes (100 % @ " & $speed & " kb/s)")
FileMove($file, StringLeft($file, StringLen($file) - 4), 9)
MsgBox(0, "Information", "Download completed!", 20)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
EndIf
$stop = 0
GUICtrlSetData($Progress, 0)
_GUICtrlStatusBar_SetText($StatusBar, "Ready")
Else
$nRead = InetGetInfo($hDownload, 0)
$calc = Int(100 * $nRead / $nSize)
GUICtrlSetData($Progress, $calc)
_GUICtrlStatusBar_SetText($StatusBar, $nRead & " / " & $nSize & " bytes (" & $calc & " % @ " & $speed & " kb/s)")
EndIf
EndFunc ;==>DL_Check
Func Enable_Buttons()
GUICtrlSetState($Start_DL, $GUI_ENABLE)
GUICtrlSetState($Stop_DL, $GUI_DISABLE)
GUICtrlSetState($Exit, $GUI_ENABLE)
GUICtrlSetState($Input_Save_To, $GUI_ENABLE)
GUICtrlSetState($Input_URL, $GUI_ENABLE)
GUICtrlSetState($Save_To, $GUI_ENABLE)
EndFunc ;==>Enable_Buttons
Func Disable_Buttons()
GUICtrlSetState($Start_DL, $GUI_DISABLE)
GUICtrlSetState($Exit, $GUI_DISABLE)
GUICtrlSetState($Input_Save_To, $GUI_DISABLE)
GUICtrlSetState($Input_URL, $GUI_DISABLE)
GUICtrlSetState($Save_To, $GUI_DISABLE)
GUICtrlSetState($Stop_DL, $GUI_ENABLE)
EndFunc ;==>Disable_Buttons
Func DL_Speed()
$speed = Round(($nRead - $current) / 1024, 2)
$current = $nRead
EndFunc ;==>DL_Speed
Func Stop_DL()
$stop = 1
EndFunc ;==>Stop_DL
Func _Exit()
InetClose($hDownload)
Close_GDIplus()
GUIDelete($hGUI)
Exit
EndFunc ;==>_Exit
#region GDI+
Func Start_Animation()
Local $j
;draw bubbles
If $Disable_Anim Then _GDIPlus_GraphicsClear($hGraphic, "0xFF" & $bg_color)
If $Display_Anim Then
;~ _GDIPlus_GraphicsClear($hBackbuffer, "0xFF" & $bg_color)
_GDIPlus_GraphicsFillRect($hBackbuffer, 0, 0, $width, $height, $hBrush)
For $j = 0 To $bubbles - 1
_GDIPlus_GraphicsDrawImage($hBackbuffer, $aData[$j][5], $aData[$j][0], $aData[$j][1])
Next
;calculate new position incl. border collision check
For $j = 0 To $bubbles - 1
$aData[$j][0] += $aData[$j][2] ;increase x coordinate with appropriate slope
$aData[$j][1] += $aData[$j][3] ;increase y coordinate with appropriate slope
If $aData[$j][0] <= 0 Then ;border collision x left
$aData[$j][0] = 1
$aData[$j][2] *= -1
ElseIf $aData[$j][0] >= $width - $aData[$j][4] Then ;border collision x right
$aData[$j][0] = $width - ($aData[$j][4] + 1)
$aData[$j][2] *= -1
EndIf
If $aData[$j][1] <= 0 Then ;border collision y top
$aData[$j][1] = 1
$aData[$j][3] *= -1
ElseIf $aData[$j][1] >= $height - $aData[$j][4] - $dh Then ;border collision y bottom
$aData[$j][1] = $height - ($aData[$j][4] + 1) - $dh
$aData[$j][3] *= -1
EndIf
Next
Collision_Check()
EndIf
If Not $Disable_Anim Then _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $width, $height)
EndFunc ;==>Start_Animation
Func Collision_Check() ;0:x, 1:y, 2:vx, 3:vy, 4:size, 5:bmp
Local $Delta_X, $Delta_Y, $Distance, $Matrix11, $Matrix12, $Matrix21, $Matrix22, $Vp1, $Vp2, $Vs1, $Vs2
For $i = 0 To $bubbles - 1
For $j = $i + 1 To $bubbles - 1
If Pixel_Distance($aData[$i][0], $aData[$i][1], $aData[$j][0], $aData[$j][1]) < ($aData[$i][4] + $aData[$j][4]) / 2 Then
$Delta_X = $aData[$i][0] - $aData[$j][0]
$Delta_Y = $aData[$i][1] - $aData[$j][1]
$Distance = Sqrt($Delta_X * $Delta_X + $Delta_Y * $Delta_Y)
$Matrix11 = $Delta_X / $Distance
$Matrix12 = -$Delta_Y / $Distance
$Matrix21 = $Delta_Y / $Distance
$Matrix22 = $Delta_X / $Distance
$Vp1 = $aData[$i][2] * $Matrix11 + $aData[$i][3] * - $Matrix12
$Vs1 = $aData[$i][2] * - $Matrix21 + $aData[$i][3] * $Matrix22
$Vp2 = $aData[$j][2] * $Matrix11 + $aData[$j][3] * - $Matrix12
$Vs2 = $aData[$j][2] * - $Matrix21 + $aData[$j][3] * $Matrix22
If $Vp1 - $Vp2 < 0 Then
$aData[$i][2] = $Matrix11 + $Vs1 * $Matrix12
$aData[$i][3] = $Matrix21 + $Vs1 * $Matrix22
$aData[$j][2] = $Matrix11 + $Vs2 * $Matrix12
$aData[$j][3] = $Matrix21 + $Vs2 * $Matrix22
EndIf
EndIf
Next
Next
EndFunc ;==>Collision_Check
Func Pixel_Distance($x1, $y1, $x2, $y2) ;Pythagoras theorem
Local $a, $b
If $x2 = $x1 And $y2 = $y1 Then Return 0
$a = $y2 - $y1
$b = $x2 - $x1
Return Sqrt($a * $a + $b * $b)
EndFunc ;==>Pixel_Distance
Func Close_GDIplus()
GUIRegisterMsg(0x0113, "")
_GDIPlus_BrushDispose($hBrush)
For $i = 0 To $bubbles - 1
_GDIPlus_BitmapDispose($aData[$i][5])
Next
_GDIPlus_GraphicsDispose($hBackbuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
EndFunc ;==>Close_GDIplus
Func _CreateBubbleBitmap($size = 75, $gradient_start = 0xA0F0C0C0, $gradient_end = 0xA0C0F0C0, $angle1 = 90, $angle2 = 45, $pen1 = 0x55AAAAAF, $pen2 = 0x50FFFFFF)
Local $ps1 = 2, $ps2 = Int($size / 12)
Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($size, $size)
Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hContext, 2)
Local $Pen_Border = _GDIPlus_PenCreate($pen1, $ps1)
Local $Pen_Reflection = _GDIPlus_PenCreate($pen2, $ps2)
Local $Brush_Gradient = _GDIPlus_CreateLineBrush(0, 0, $size, $size, $gradient_start, $gradient_end)
_GDIPlus_GraphicsFillEllipse($hContext, 0, 0, $size, $size, $Brush_Gradient)
_GDIPlus_GraphicsDrawArc($hContext, $size / 3, $size / 5, $size / 2, $size / 2, 10, -$angle1, $Pen_Reflection)
_GDIPlus_GraphicsDrawArc($hContext, $size / 6, $size / 3.5, $size / 2, $size / 2, -210, -$angle2, $Pen_Reflection)
_GDIPlus_GraphicsDrawEllipse($hContext, 0, 0, $size - $ps1, $size - $ps1, $Pen_Border)
_GDIPlus_PenDispose($Pen_Border)
_GDIPlus_PenDispose($Pen_Reflection)
_GDIPlus_BrushDispose($Brush_Gradient)
_GDIPlus_GraphicsDispose($hContext)
Return $hBitmap
EndFunc ;==>_CreateBubbleBitmap
Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[6]
EndFunc ;==>_GDIPlus_BitmapCreateFromScan0
Func _GDIPlus_CreateLineBrush($iPoint1X, $iPoint1Y, $iPoint2X, $iPoint2Y, $iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $WrapMode = 0)
Local $tPoint1, $pPoint1, $tPoint2, $pPoint2, $aRet
If $iArgb1 = "" Then $iArgb1 = 0xFF0000FF
If $iArgb2 = "" Then $iArgb2 = 0xFFFF0000
If $WrapMode = -1 Then $WrapMode = 0
$tPoint1 = DllStructCreate("float X;float Y")
$pPoint1 = DllStructGetPtr($tPoint1)
DllStructSetData($tPoint1, "X", $iPoint1X)
DllStructSetData($tPoint1, "Y", $iPoint1Y)
$tPoint2 = DllStructCreate("float X;float Y")
$pPoint2 = DllStructGetPtr($tPoint2)
DllStructSetData($tPoint2, "X", $iPoint2X)
DllStructSetData($tPoint2, "Y", $iPoint2Y)
$aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrush", "ptr", $pPoint1, "ptr", $pPoint2, "int", $iArgb1, "int", $iArgb2, "int", $WrapMode, "int*", 0)
Return $aRet[6]
EndFunc ;==>_GDIPlus_CreateLineBrush
Func _GDIPlus_GraphicsSetClipRegion($hGraphics, $hRegion, $iCombineMode = 0)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetClipRegion", "hwnd", $hGraphics, "hwnd", $hRegion, "int", $iCombineMode)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_GraphicsSetClipRegion
Func _GDIPlus_RegionCreateFromRect($tRectF)
Local $pRectF, $aResult
$pRectF = DllStructGetPtr($tRectF)
$aResult = DllCall($ghGDIPDll, "uint", "GdipCreateRegionRect", "ptr", $pRectF, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[2]
EndFunc ;==>_GDIPlus_RegionCreateFromRect
Func _GDIPlus_RegionCombineRect($hRegion, $tRectF, $iCombineMode = 2)
Local $pRectF, $aResult
$pRectF = DllStructGetPtr($tRectF)
$aResult = DllCall($ghGDIPDll, "uint", "GdipCombineRegionRect", "hwnd", $hRegion, "ptr", $pRectF, "int", $iCombineMode)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_RegionCombineRect
Func _GDIPlus_RegionDispose($hRegion)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDeleteRegion", "hwnd", $hRegion)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_RegionDispose
#endregion GDI+
Zitat
1. , würde ich das Tool öfters als Downloader nutzen, würde ich es vermutlich ein wenig aufbohren, was den abgebrochenen Download angeht ( auch wenn mir klar ist, dass das Beispiel in erster Linie aufzeigen sollte, wie ein Abbruch eingebaut werden kann ) . Ich würde analog anderen Programmen vielleicht hingehen und der Datei während des Downloads einen temporären Dateinamen im Zielverzeichnis geben a la filename.exe.part und erst, wenn die Datei komplett durchlaufen ist in den Originalnamen umbenennen.
Das mit der temp. Datei ist erst jetzt implementiert. Die Resume Funktion muss ich erstmal nachforschen, wenn ich Zeit habe.
Gruß,
UEZ
Hi Prickel,
danke für dein Feedback! Ich werde mal sehen, was ich machen kann, um deine Punkte zu integrieren!
Gruß,
UEZ
Sollte jetzt gelöst sein!
Danke an Raupi für den Tipp!
Gruß,
UEZ