Füge mal folgende zwei Zeilen hinzu:
[autoit]
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
Opt("MustDeclareVars", 1)
und lass' dein Skript nochmals laufen.
Gruß,
UEZ
Füge mal folgende zwei Zeilen hinzu:
[autoit]
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
Opt("MustDeclareVars", 1)
und lass' dein Skript nochmals laufen.
Gruß,
UEZ
Habe das URL Grabben einbaut und jetzt fehlt noch das Zoom Feature für die Vorschau.
Um das Problem mit OS kleiner Vista zu lösen, habe ich mich entschlossen, diese einfach wegzulassen, da auch der Screenshot
für Webseiten auf WinXP nicht läuft.
Ich finde, und das ist meine Meinung, dass WinXP mittlerweile ein obsoletes OS ist und man es langsam in Rente schicken sollte.
Die nächste Version wird kein WinXP unterstützen!
Gruß,
UEZ
Hab etwas herumprobiert und noch keine Lösung für XP gefunden.
Es schein, daß Fensterteile, die außerhalb des Bildschrims liegen nicht erfasst werden. weder mit BitBlt, noch via WM_PRINTCLIENT hatte ich Erfolg.
Bei Gelegenheit werd ich weiterforschen
E
Ich werde mich langsam, aber sicher, von WinXP verabschieden und nicht darauf achten, ob es auch unter WinXP läuft. Wenn es unter WinXP läuft, dann gut, ansonsten Pech, egal ob MS noch für WinXP Patche herausbringt oder nicht!
Ich hatte vor längerer Zeit ein nettes Programm, dass bei Fenstern allgemein einen Screenshot erstellt hat, automagisch etwas herunter gescrollt hat und den nächsten gemacht hat und die Bilder dann zusammengesetzt hat. Vielleicht ist das einfacher?
Gruß,
Matthias
Das Skript funzt doch unter Vista+, somit ist das Basteln nicht nötig. ![]()
Gruß,
UEZ
eukalyptus: geht es damit: WinMove($hGUI, "", $aWin[0] - $BodyWidth + 10, $aWin[1] - $BodyHeight+ 10) ?
andygo: vielen Dank
Geht demm jetzt ![]()
Ich habe das Skript nicht unter WinXP, sondern "nur" unter Win7 x64 getestet - XP teste ich in meiner VM gleich...
Gruß,
UEZ
Edit: das Skript scheint mit WinXP nicht richtig zu laufen, denn normalerweise wird der IE nicht direkt aufgerufen, sondern kurz in einem eigenen Fenster, von dem ein Screenshot erstellt wird!
Da haben wir es einmal wieder - WinXP und die Komptabilität :pinch:
Stimmt, mit https://autoit.de/www.autoit.de sieht man den Balken rechts nicht.
Versuche es mal mit https://autoit.de/www.autoitscript.com/forum als URL.
Ich wollte nur Bordmittel benutzen, da ich sonst IrfanView voraussetzen muss ![]()
Gruß,
UEZ
Ich will AutoIt Windows Screenshooter mit einer Web Screenshot Funktion erweitern,
bin eigentlich mit der IE Objektprogrammierung fast überhaupt nicht vertraut.
Es gibt zwar ein klasse Proggy (Web Screenshot), aber ich kenne mich überhaupt nicht
mit AutoItObject aus.
Also habe ich versucht, was eigenes auf die Beine zu stellen:
#include <Clipboard.au3>
#include <IE.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
;Coded by UEZ 2011 - beta version
If @OSBuild < 6000 Then Exit MsgBox(16, "Error!", "Script is running properly only on Vista+ os!", 10)
[/autoit] [autoit][/autoit] [autoit]Global Const $hDwmApiDll = DllOpen("dwmapi.dll")
Global $sChkAero = DllStructCreate("int;")
DllCall($hDwmApiDll, "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($sChkAero))
Global $aero = DllStructGetData($sChkAero, 1)
If Not $aero Then Exit MsgBox(16, "Error", "Aero must be enabled to grab web sites properly!", 20)
$sChkAero = 0
Global $URL, $btn, $msg, $hWnd, $input, $i
$hWnd = GUICreate("Save Web Page as an image", 320, 120)
$input = GUICtrlCreateInput("http://www.stern.de", 10, 5, 300, 20)
$btn = GUICtrlCreateButton("Ok", 40, 35, 240, 70)
ControlFocus($hWnd, "", $btn)
GUISetState()
While $msg <> -3
$msg = GUIGetMsg()
Select
Case $msg = $btn
Start()
Case $msg = -3
GUIDelete($hWnd)
Exit
EndSelect
WEnd
Func Start()
$URL = GUICtrlRead($input)
SplashTextOn("Screenshooting Web Site", "Please wait while taking screenshot", 300, 40, -1, -1, 1 + 2 + 4 + 32, "")
AdlibRegister("Wait", 300)
Web_Screenshot($URL)
AdlibUnRegister("Wait")
SplashOff()
MsgBox(0, "Information", "Web Site Image copied to clipboard!", 10)
EndFunc
Func Web_Screenshot($url, $IEwidth = 1045)
Local $oIE, $GUIActiveX, $oDocument, $oBody, $BodyWidth, $BodyHeight, $oHtml
Local $hGUI_WebGrab, $hWin, $aWin, $aMP
Local Const $BrowserNavConstant = 2 + 256 + 2048 ;BrowserNavConstant -> http://msdn.microsoft.com/en-us/library/…8(v=vs.85).aspx
$oIE = ObjCreate("Shell.Explorer.2") ;http://msdn.microsoft.com/en-us/library/…4(v=vs.85).aspx
$hWin = WinGetHandle("Program Manager")
$aWin = WinGetPos($hWin)
#region render web site to get height
$hGUI_WebGrab = GUICreate("", 0, 0, $aWin[0] - $BodyWidth + 1, $aWin[1] - $BodyHeight + 1, BitOR($WS_CLIPSIBLINGS, $WS_CLIPCHILDREN, $WS_POPUP),Default, WinGetHandle(AutoItWinGetTitle()))
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, $IEwidth, 256)
GUISetState(@SW_MINIMIZE, $hGUI_WebGrab)
Local $timeout = 30 * 1000
Local $timer = TimerInit()
With $oIE
.Silent = True
.FullScreen = True
.Resizable = False
.Visible = False
.StatusBar = False
.AddressBar = False
.Navigate($URL, $BrowserNavConstant, "_top")
Do
If TimerDiff($timer) > $timeout Then ExitLoop
Sleep(100)
Until $oIE.ReadyState = 4
.Stop
Sleep(2000)
EndWith
$oDocument = $oIE.document
$oBody = $oDocument.body
$oBody.scroll = "no"
$oBody.style.borderStyle = "none"
$BodyWidth = $oBody.scrollWidth
$BodyHeight = $oBody.scrollHeight
GUIDelete($hGUI_WebGrab)
$GUIActiveX = 0
#endregion
$hGUI_WebGrab = GUICreate("", $BodyWidth, $BodyHeight, $aWin[0] - $BodyWidth + 1, $aWin[1] - $BodyHeight + 1, BitOR($WS_CLIPSIBLINGS, $WS_CLIPCHILDREN, $WS_POPUP), Default, WinGetHandle(AutoItWinGetTitle()))
;~ $hGUI_WebGrab = GUICreate("", $BodyWidth, $BodyHeight, -1, -1, BitOR($WS_CLIPSIBLINGS, $WS_CLIPCHILDREN, $WS_POPUP), Default, WinGetHandle(AutoItWinGetTitle()))
$GUIActiveX = GUICtrlCreateObj ($oIE, 0, 0, $BodyWidth, Min($BodyHeight, 8192))
;~ GUISetState(@SW_SHOWNA, $hGUI_WebGrab) ;Show GUI for some milli seconds to make a screenshot
$timer = TimerInit()
With $oIE
.Silent = True
.FullScreen = True
.Resizable = False
.Visible = False
.StatusBar = False
.AddressBar = False
.Navigate($URL, $BrowserNavConstant, "_top")
Do
If TimerDiff($timer) > $timeout Then ExitLoop
Sleep(100)
Until $oIE.ReadyState = 4
.Stop
Sleep(1000)
EndWith
$oDocument = $oIE.document
$oBody =$oDocument.body
$oHtml = $oDocument.documentElement
$oBody.scroll = "no"
$oBody.style.borderStyle = "none"
$oBody.style.border = "0px"
$oHtml.style.overflow = 'hidden'
GUISetState(@SW_SHOWNA, $hGUI_WebGrab) ;Show GUI
[/autoit] [autoit][/autoit] [autoit]Local $hDC = _WinAPI_GetWindowDC($hGUI_WebGrab)
Local $hDC_Dummy = _WinAPI_GetWindowDC(0)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC_Dummy)
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Dummy, $BodyWidth, $BodyHeight)
_WinAPI_SelectObject($hMemDC, $hBitmap)
_WinAPI_BitBlt($hMemDC, 0, 0, $BodyWidth, $BodyHeight, $hDC, 0, 0, $SRCCOPY)
_WinAPI_DeleteDC($hMemDC)
_WinAPI_ReleaseDC($hGUI_WebGrab, $hDC)
_WinAPI_ReleaseDC(0, $hDC_Dummy)
_WinAPI_ReleaseDC(0, $hDC)
_ClipBoard_Open(0)
_ClipBoard_Empty()
_ClipBoard_SetDataEx($hBitmap, $CF_BITMAP)
_ClipBoard_Close()
_WinAPI_DeleteObject ($hBitmap)
$GUIActiveX = 0
$oIE = 0
GUIDelete($hGUI_WebGrab)
_ReduceMemory()
EndFunc
Func Min($a, $b)
If $a < $b Then Return $a
Return $b
EndFunc
Func Wait()
Switch Mod($i, 4)
Case 0
ControlSetText("Screenshooting Web Site", "", "Static1", "Please wait while taking screenshot")
Case 1
ControlSetText("Screenshooting Web Site", "", "Static1", "Please wait while taking screenshot .")
Case 2
ControlSetText("Screenshooting Web Site", "", "Static1", "Please wait while taking screenshot ..")
Case 3
ControlSetText("Screenshooting Web Site", "", "Static1", "Please wait while taking screenshot ...")
EndSwitch
$i += 1
EndFunc
Func _ReduceMemory($ProcID = 0)
If $ProcID = 0 or ProcessExists($ProcID) = 0 Then ; No process id specified or process doesn't exist - use current process instead.
Local $ai_GetCurrentProcess = DllCall('kernel32.dll', 'ptr', 'GetCurrentProcess')
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'ptr', $ai_GetCurrentProcess[0])
Return $ai_Return[0]
EndIf
Local $ai_Handle = DllCall("kernel32.dll", 'ptr', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ProcID)
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'ptr', $ai_Handle[0])
DllCall('kernel32.dll', 'int', 'CloseHandle', 'ptr', $ai_Handle[0])
Return $ai_Return[0]
EndFunc
Ich habe zwei Probleme hier:Wie kann ich eine IE Seite rendern und diese abspeichern, ohne eine GUI anzuzeigen?Wie bekomme ich den vertikalen Balken auf der rechten Seite weg (einfach den Screenshot vom Clipboard in irgendein Tool einfügen)?
Ideen?
Der Code ist noch im Alpha Status und kann oder hat sehr wahrscheinlich schwachsinnigen Code! Jetzt im ßeta Stadium.
Gruß,
UEZ
Edit: scheint mit WinXP nicht zu laufen, da es kein Aero gibt, welches nötig ist, von Fenstern einen Screenshot zu erstellen, das sich außerhalb des sichtbaren Desktops befindet.!
Ja, im FileCommander habe ich diesen Workaround eingebaut. Wobei ich damit auch nicht wirklich zufrieden bin.
Ich glaube, mir gefällt die Lösung mit dem Dummy-Control (Post#2) besser.
Die ist echt clever, nur für mein Code nicht von Nutzen. Siehst du, wenn du mal in den Code reinschaust!
Edit: obwohl, könnte man auch so implementieren! ![]()
Gruß,
UEZ
Hi KaFu,
nett, dass du dein Wissen auch hier teilst! ![]()
Weiter so ![]()
Gruß,
UEZ ![]()
Mein letztes Update für dieses Tool!
Gruß,
UEZ
Hab' ein Workaround gefunden, indem ich ein bissl bei Oscar in seinem FileCommander abgeschaut habe (vielen Dank OSCAR!)! ![]()
Hier der Auszug:
[autoit]
Case $LVN_KEYDOWN
$tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam)
Switch DllStructGetData($tInfo, 'VKey')
Case 38
$index = _GUICtrlListView_GetSelectionMark($List) - 1
If $index > -1 Then Make_Screenshot(_GUICtrlListView_GetItemText($List, $index, 1), $aWnd[$index][2], $aWnd[$index][3])
Case 40
$index = _GUICtrlListView_GetSelectionMark($List) + 1
If $index < _GUICtrlListView_GetItemCount($hListView) Then Make_Screenshot(_GUICtrlListView_GetItemText($List, $index, 1), $aWnd[$index][2], $aWnd[$index][3])
EndSwitch
EndSwitch
Und zwar ist der Code für meinen AutoIt Windows Screenshooter!
Vielen Dank für eurer Feedback!
Gruß,
UEZ
Wie kann ich akkurater die Spalte eines ListViews auslesen, als $LVN_ITEMCHANGED zu benutzen, da $LVN_ITEMCHANGED mehrmals aufgerufen wird?
Hier das Beispiel aus der Hilfe:
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
[/autoit] [autoit][/autoit] [autoit]$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work
[/autoit] [autoit][/autoit] [autoit]Global $hListView
[/autoit] [autoit][/autoit] [autoit]_Main()
[/autoit] [autoit][/autoit] [autoit]Func _Main()
[/autoit] [autoit][/autoit] [autoit]Local $GUI, $hImage
$GUI = GUICreate("(UDF Created) ListView Create", 200, 300)
$hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 268)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
[/autoit] [autoit][/autoit] [autoit]; Load images
$hImage = _GUIImageList_Create()
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
_GUICtrlListView_SetImageList($hListView, $hImage, 1)
; Add columns
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
; Add items
_GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
_GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
_GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $hListView
If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_KEYDOWN ; A key has been pressed
ConsoleWrite("$LVN_KEYDOWN" & @CRLF)
; No return value
Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
ConsoleWrite("$NM_CLICK" & @CRLF)
Case $LVN_ITEMCHANGED ; An item has changed
ConsoleWrite("$LVN_ITEMCHANGED" & @CRLF)
; No return value
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Wenn eine Zelle markiere und mit den Cursor Tasten die Auswahl bewege, dann wird $LVN_ITEMCHANGED leider mehrmals aufgerufen!
Ich will prüfen, welche Zelle gerade aufgerufen wurde. Mit $LVN_KEYDOWN geht es auch, aber ich bekomme nicht die Zelle und deren Inhalt raus!
Gruß,
UEZ
Such' doch mal im Forum nach "Spiel Game"! ![]()
Br,
UEZ
alles ok, kein Flackern mehr, dachte eigentlich es sei ein grundsätzliches Problem von XP im Zusammenhang mit GDI+ und Transparenz,
mfg autoBert
Das hängt schon mit WinXP zusammen, aber warum das so ist, weiß ich nicht.
Jedenfalls gibts es ein Workaround dazu -> [ gelöst ] Schlechte GDI+ Performance auf WinXP
Respekt
Ich finde die Animation klasse (Habe selbst vor einigen Tagen schon überlegt, ob ich den Win7 Seifenblasenbildschirmschohner nachbauen soll...)
Auch das Downloaden geht sauber von der Hand
Du holst ungeahnte Geschwindigkeiten aus meinem schlechten inet^^
25kb/s. Das hab ich mit dem normalen Firefoxdownloader so gut wie nie...(system ist WinXP 32Bit)
lg
Das mit dem Screensaver geht mir eigentlich schon lange durch den Kopf, da ich schon lange die Bubbles vom Screensaver extrahiert habe...
Hey.
Nette sache
Cool würde es mitsicherheit kommen, wenn man durch Bewegung des Fensters die Blasen anschupsen könnte
mfg Datzer
Mal sehen, ob ich das hinbekomme...
@all: vielen Dank für euer Feedback! ![]()
Gruß,
UEZ
autoBert: sollte jetzt gefixt sein. Bitte mal testen!
Gruß,
UEZ
Hmmm, habe es jetzt in meiner VM nachvollziehen können! Merkwürdig! ![]()
Workaround: die Animation abstellen -> rmt -> disable.
Warum es zum Flackern auf WinXP kommt, kann ich leider nicht sagen! Werde mal einige Sachen unter WInXP ausprobieren! Unter Win7 X64 läuft's ohne Probleme!
Danke für dein Feedback!
Gruß,
UEZ
Hast du dir die möglichen Parameter zu InetGet angeschaut? Dann müsstest du die Antwort kennen, mit dieser Methode gar nicht. Afaik hat aber @progandy in einem Hilfe-Thread shon einmal eine Möglichkeit aufgezeigt, wie es unter bestimmten Voraussetzungen mit WinHTTp? funktioniert.
UEZ, die Animation ist gelungen, jedoch habe ich in meinem MP3-Player und auch im YT-Downloader während dein Skript gestartet ist ein merkwürdiges Flackern in Teilbereichen der GUI. In beiden benutze ich WinSetTrans und ich bin mir sicher dass es damit zu tun hat. Wenn der Download beendet ist ist auch das Flackern solange verschwunden bis ich die MsgBox bestätige.
Edit: auch Tooltips des Explorer reagieren mit einem Flackern während das Skript läuft. Ich benutze WinXP Prof. SP3
Frohes gutes neues Jahr autoBert
Ich habe mal deine 2 Tools auf einem Notebook mit WinXP SP2 laufen lassen, konnte aber kein flackern erkennen!
Vielleicht können mal die XP User testen und hier posten, ob sie ein Flackern sehen!
Wirklich gut gelungen, selbst in dieser "stinknormalen" Gui ist wieder eine GDI+ Extra eingebaut
![]()
Die nächste Frage wäre, wie man den Download dann auch an der Stelle wieder fortführen kann, an der man stehengeblieben ist...
Mal sehen, ob ich das noch implementieren kann.
Gruß,
UEZ
Sprenger120: Vielen Dank für dein Feedback! ![]()
Kleines Update -> die Bläschen haben jetzt eine Pseudokollision! Vielleicht gefällst ja euch...
Gruß,
UEZ
Mein Favorit: schnell, schick und stabil -> Win7
Gruß,
UEZ
Hier und da gibt es die Anfrage, wie man Downloads abbrechen kann. Hier ein möglicher Weg:
;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-24 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-24 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)
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(22, 182, 570, 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")
;~ Global $Group = GuiCtrlCreateGroup("", 3, 5, $width - 6, 220, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT))
;~ GUICtrlCreateGroup("", -99, -99, 1, 1)
;Pseudo group
Global $Lx = 10
Global $Ly = 8
Global $Lw = $width - 2 * $Lx
Global $Lh = $height - 34
Global $Line1 = GUICtrlCreateLabel("", $lx, $ly, $Lw, 1, $SS_SUNKEN)
Global $Line2 = GUICtrlCreateLabel("", $lx, $Lh - 2, $Lw, 1, $SS_SUNKEN)
Global $Line3 = GUICtrlCreateLabel("", $Lx, $ly, 1, $Lh - 9, $SS_SUNKEN)
Global $Line4 = GUICtrlCreateLabel("", $Lw + $Lx - 1, $ly, 1, $Lh - 9, $SS_SUNKEN)
Global $GText = GUICtrlCreateLabel("UEZ'11 ", $Lw - 2 * $Lx + 2, $Lh - 12, 25, 10, $SS_CENTER, $WS_EX_TOPMOST)
GUICtrlSetFont(-1, 6, 100, 0)
GUICtrlSetBkColor($GText, "0x" & $bg_color)
GUICtrlSetColor(-1, 0x000040)
GUISetState(@SW_SHOW)
ControlFocus($hGUI, "", $Start_DL)
#endregion
#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)
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)")
Sleep(500)
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+
Sollte ab Windows2000 bis Win7 x64 funzen! Momentan ohne Proxy und Resume Unterstützung.
Gruß,
UEZ
Wenn du wirklich Spiele erstellen willst, würde ich eher auf z.B. SDL zurückgrefen: http://www.autoitscript.com/forum/topic/94834-sdl-udf/
Für BitBlt mit Transparenz: Das heißt AlhpaBlend (funktioniert mit Bitmaps mit premultiplied alpha)
Die Challenge ist doch mit GDI+ die Games zu coden! Ob man jetzt SDL, Irrlicht, AU3Impact, o.ä. nimmt, ist ja reine Geschmacksache. Mit den genannten Addons kann man ganz tolle Effekte erzielen, wofür man mit GDI+ riesen Klimmzüge machen muss, wenn sie sich überhaupt implementieren lassen, z.B. Spiegeleffekt auf Kugeln, etc.
Einen super Schritt hat z.B. eukalyptus mit diesem Code aus diesem Post hingelegt, was mit GDI+ Bordmitteln anscheinend nicht geht! ![]()
Gruß,
UEZ