Search the Community
Showing results for tags 'SD'.
-
So I was getting into GDI and found a lot of examples that I really liked, one of them caught my eye which was a smiley face that would go in circles that I got from martin I wanted to make a sort of "black hole" on my desktop where I can drag and drop files and have them securely deleted and came up with this with a lot of help from UEZ, Werty and other people from who I took code from and liked it so much I thought I'd share it since I haven't seen something like this on here yet. You are going to need to install the ImageMagick COM object if you do not already have it, the script will tell you where you can get it and how to install it if you don't already have it. A lot of copy pasta lead to this script. Now for the script. #NoTrayIcon #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=blackhole.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Res_Comment=Graphical Trash Bin #AutoIt3Wrapper_Res_Description=Secure Delete Toy #AutoIt3Wrapper_Res_Fileversion=1.0.0.58 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3" #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/so #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <GDIp.au3> #include <SD.au3>; wraithdu Secure Delete UDF http://www.autoitscript.com/forum/topic/82954-securely-overwrite-files/ HotKeySet("{ESC}", "close") OnAutoItExitRegister("close") Global $aM_Mask, $hwnd Global Const $IMAGE_BITMAP = 0 Global Const $STM_SETIMAGE = 0x0172 Global $gaDropFiles[1] Global $Img = @TempDir & "\test.png"; The image used for the effects processing Global $ImgMgc = ObjCreate("ImageMagickObject.MagickImage.1"); Create the Image Majic Com object if installed If Not IsObj($ImgMgc) Then Global $Over = False, $SEC = @SEC, $Pos, $Msg, $Label, _ $Adv = GUICreate("Error!", 297, 93, 371, 313, BitOR($WS_CAPTION, $WS_POPUPWINDOW, $DS_SETFOREGROUND), -1), _ $h = ControlGetHandle($Adv, '', $Label), _ $Ok = GUICtrlCreateButton("OK", 107, 58, 77, 23) GUICtrlCreateIcon(@SystemDir & "\user32.dll", -2, 10, 10, 32, 32) GUICtrlCreateLabel("You need to install the ", 60, 20, 110, 17) $Label = GUICtrlCreateLabel("ImageMagick COM object!", 169, 20, 124, 17) GUICtrlSetFont($Label, 8.5) GUICtrlSetCursor($Label, 0) GUISetState() While 1 $Pos = _WinAPI_GetMousePos() $Msg = GUIGetMsg() Switch $Msg Case -3 close() Case $Ok close() Case $Label ShellExecute("http://www.imagemagick.org/script/binary-releases.php#windows") Sleep(8000) MsgBox(48,"Info",'The download we'&"'"&'re looking for is the "ImageMagick-6.x.x-3-Q16-windows-dll.exe" release binary...' & @CR & @CR & _ 'After downloading and running, in the "Select Additional Tasks" section, deselect everything' & @CR & _ 'and select only "Install ImageMagickObject OLE Control for VBscript, Visual Basic, and WSH".') EndSwitch Switch _WinAPI_WindowFromPoint($Pos) Case $h If Not $Over Then GUICtrlSetFont($Label, -1, -1, 4) GUICtrlSetColor($Label, 0x0000ff) $Over = 1 EndIf Case Else If $Over And (@SEC <> $SEC) Then GUICtrlSetFont($Label, 8.5) GUICtrlSetColor($Label, 0x000000) $Over = 0 $SEC = @SEC ElseIf Not $Over And ($SEC <> @SEC) Then GUICtrlSetFont($Label, -1, -1, 4) GUICtrlSetColor($Label, 0x0000ff) $Over = 1 $SEC = @SEC EndIf EndSwitch WEnd close() EndIf Init(); Start all the fun stuff :) Func Init() _GDIPlus_Startup() Local $hwnd = GUICreate("Black Hole", 300, 300, -1, -1, $WS_POPUP, $WS_EX_ACCEPTFILES, GUICreate("ghost"));$WS_EX_TOPMOST Local $Pic = GUICtrlCreatePic("", 0, 0, 400, 400, -1, $GUI_WS_EX_PARENTDRAG); only for enable dragging of the gui GUICtrlSetState($Pic, $GUI_DROPACCEPTED) GUISetBkColor(0x000000, $hwnd) $Img = CreateImg($hwnd, $Img, 0.50); Create the magic image If IsObj($ImgMgc) Then $ImgMgc.Convert($Img, "-implode", "-15", $Img); Give the image a lense effect EndIf GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC") Local $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) Local $bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics) Local $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) Local $Pos = WinGetPos($hwnd) Local $TmpPos = $Pos Local $image = _GDIPlus_ImageLoadFromFile($Img) Local $matrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($matrix, 150, 150);True) _GDIPlus_GraphicsSetTransform($backbuffer, $matrix) _GDIPlus_GraphicsDrawImageRect($backbuffer, $image, -150, -150, 300, 300);-150,-150) _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 300, 300) setTrans($hwnd); make the GUI circular GUISetState() Local $Msg, $Files, $SEC = @SEC While 1 Sleep(20) $Msg = GUIGetMsg($hwnd) Switch $Msg Case $GUI_EVENT_DROPPED $Files = '' For $i = 0 To UBound($gaDropFiles) - 1 $Files &= $gaDropFiles[$i] & @CR Next Switch MsgBox(4 + 48 + 256 + 262144, "Advisory!", "Are you sure you wish to permanantly delete these files?" & @CRLF & $Files) Case 6 For $i = 0 To UBound($gaDropFiles) - 1 _SecureFileDelete($gaDropFiles[$i], False, True, False) Next EndSwitch Case $Pic $Pos = WinGetPos($hwnd) If ($Pos[0] <> $TmpPos[0]) Or ($Pos[1] <> $TmpPos[1]) Then; check if GUI was relocated GUISetState(@SW_HIDE) _GDIPlus_BitmapDispose($image) Sleep(100);for some reason the GUI is still caught in the image if we don't wait :/ CreateImg($hwnd, $Img, 0.50) If IsObj($ImgMgc) Then Switch Random(1,2,1) Case 1 $ImgMgc.Convert($Img, "-implode", "-1", "-swirl", "1000", $Img) Case 2 $ImgMgc.Convert($Img, "-implode", "-15", $Img) EndSwitch EndIf $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) $bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics) $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) $image = _GDIPlus_ImageLoadFromFile($Img) $matrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($matrix, 150, 150);True) GUISetState(@SW_SHOW) $Pos = WinGetPos($hwnd) $TmpPos = $Pos EndIf EndSwitch If @SEC <> $SEC Then ;_GDIPlus_MatrixRotate($matrix, -0.01); uncomment to slowley rotate the image at an intervail _GDIPlus_GraphicsSetTransform($backbuffer, $matrix) _GDIPlus_GraphicsDrawImageRect($backbuffer, $image, -150, -150, 300, 300);-150,-150) _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 300, 300) $SEC = @SEC EndIf WEnd close() EndFunc ;==>Init Func CreateImg($hGui, $ImgPath, $fArea); Thanks UEZ! If Not IsHWnd($hGui) Then Exit MsgBox(0, "", "error") EndIf Local $iWidth = 300 Local $iHeight = 300 Local $iSize = 300 Local $hBmp = _ScreenCapture_CaptureWnd("", $hGui, 0, 0, $iWidth, $iHeight, False) Local $hBGBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) Local $hBrush = _CreateBrush($iSize, $fArea) Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBGBitmap) _GDIPlus_GraphicsFillRect($hContext, 0, 0, $iSize, $iSize, $hBrush) _GDIPlus_ImageSaveToFile($hBGBitmap, $ImgPath) _WinAPI_DeleteObject($hBmp) _GDIPlus_BitmapDispose($hBGBitmap) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_BitmapDispose($hBGBitmap) Return $ImgPath EndFunc ;==>CreateImg Func _CreateBrush($iSize, $fArea) Local $fTmp = $iSize * $fArea * 1.20 Local $hPath = _GDIPlus_PathCreate() ;_GDIPlus_PathAddEllipse($hPath, $fTmp, $fTmp, $iSize - $fTmp * 2, $iSize - $fTmp * 2) _GDIPlus_PathAddEllipse($hPath, $fTmp - 25, $fTmp - 25, -10, -10) Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath) _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFF000000) Local $aColor[2] = [1, 0x00000000] _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColor) _GDIPlus_PathBrushSetFocusScales($hBrush, 0.5, 0.5) _GDIPlus_PathBrushSetGammaCorrection($hBrush, True) _GDIPlus_PathDispose($hPath) Return $hBrush EndFunc ;==>_CreateBrush Func WM_DROPFILES_FUNC($hwnd, $msgID, $wParam, $lParam) Local $nSize, $pFileName Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255) For $i = 0 To $nAmt[0] - 1 $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0) $nSize = $nSize[0] + 1 $pFileName = DllStructCreate("char[" & $nSize & "]") DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize) ReDim $gaDropFiles[$i + 1] $gaDropFiles[$i] = DllStructGetData($pFileName, 1) $pFileName = 0 Next Binary($hwnd + $msgID + $lParam);just to prevent unused var errors -_- EndFunc ;==>WM_DROPFILES_FUNC Func close() _GDIPlus_Shutdown() Exit EndFunc ;==>close Func setTrans($hW) Local $x, $Startx, $Endx $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 460, "long", 460) For $y = 0 To 300 $x = Abs((150 * 150 - (150 - $y) * (150 - $y)) ^ 0.5) $Startx = 150 + $x $Endx = 300 addRegion($Startx, $y, $Endx, $y) $Startx = 0 $Endx = 150 - $x addRegion($Startx, $y, $Endx, $y) Next DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hW, "long", $aM_Mask[0], "int", 1) EndFunc ;==>setTrans Func addRegion($a, $b, $c, $d) Local $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $a, "long", $b, "long", $c + 1, "long", $d + 1) DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 3) EndFunc ;==>addRegion Download Black Hole Desktop Toy.htm Download Since I'm not exactly a pro at this GDI stuff, the script is a little buggy, in example, I have the GUI redrawn every second since when another window is hovered above it it will be painted black and will look ugly. Updated: I removed my fail attempt at creating a portable version of the ImageMagick COM interface, if you don't have it, it'll advise you as to where you can get it. Here is a version that does not need the ImageMagick COM object thanks to UEZ. Although, when dropping files into it, it takes about 20-30 seconds to respond which is a fault on my side due to my scripting abilities... You will need the UDF & the UDF. #include <GDIP.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <SD.au3>; Secure Delete UDF HotKeySet("{ESC}", "_Exit") _GDIPlus_Startup() Global $aM_Mask Global $iWidth = 300 Global $iHeight = 300 Global $iSize = 301 Global $fArea = 0.25 Global $gaDropFiles[1] Global $hGui = GUICreate("Black Hole", $iWidth, $iHeight, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW,$WS_EX_ACCEPTFILES)) GUISetBkColor(0xABCDEF) Local $Pic = GUICtrlCreatePic("", 0, 0, 400, 400, -1, $GUI_WS_EX_PARENTDRAG); only for enable dragging of the gui GUICtrlSetState($Pic, $GUI_DROPACCEPTED) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC") setTrans($hGui) _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, 255, 0x1) Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer) _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2) _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF) Global $hBrush = _CreateBrush(300, $fArea) GUIRegisterMsg($WM_PAINT, "WM_PAINT") GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND") ;_WinAPI_ShowCursor(False) GUISetState() Global $Msg, $Files While 1 _Draw() Sleep(100) $Msg = GUIGetMsg($hGui) Switch $Msg Case $GUI_EVENT_DROPPED $Files = '' For $i = 0 To UBound($gaDropFiles) - 1 $Files &= $gaDropFiles[$i] & @CR Next Switch MsgBox(4 + 48 + 256 + 262144, "Advisory!", "Are you sure you wish to permanantly delete these files?" & @CRLF & $Files) Case 6 For $i = 0 To UBound($gaDropFiles) - 1 _SecureFileDelete($gaDropFiles[$i], False, True, False) Next EndSwitch EndSwitch WEnd Func _Draw() _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF) ; Local $hBmp = _ScreenCapture_Capture("", $aPos[0], $aPos[1], $aPos[0] + $iSize, $aPos[1] + $iSize, False) Local $hBmp = _ScreenCapture_CaptureWnd("",$hGui,0,0) Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) _WinAPI_DeleteObject($hBmp) Local $hTexture = _GDIPlus_TextureCreate($hBitmap) _GDIPlus_BitmapDispose($hBitmap) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iSize, $iSize, $hGraphics) Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $fScale = 1 Local $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_GraphicsFillEllipse($hContext, 0, 0, $iSize, $iSize, $hTexture) _GDIPlus_GraphicsSetSmoothingMode($hContext, 2) Local $fTmp = 0 For $i = 2 To Floor($iSize / 2) $fTmp = $i * ($iSize * $fArea) / ($iSize / 2) * 2.6 $fScale = (($iSize - $fTmp) / ($iSize - $i * 2)) _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0) _GDIPlus_MatrixTranslate($hMatrix, $iSize / 2, $iSize / 2) _GDIPlus_MatrixScale($hMatrix, $fScale, $fScale) _GDIPlus_MatrixRotate($hMatrix, $fScale) _GDIPlus_MatrixTranslate($hMatrix, -$iSize / 2, -$iSize / 2) _GDIPlus_GraphicsSetTransform($hContext, $hMatrix) _GDIPlus_GraphicsFillEllipse($hContext, $i, $i, $iSize - $i * 2, $iSize - $i * 2, $hTexture) Next _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0) _GDIPlus_GraphicsSetTransform($hContext, $hMatrix) _GDIPlus_GraphicsFillRect($hContext, 0, 0, $iSize, $iSize, $hBrush) _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_BrushDispose($hTexture) _GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBitmap, -1, -1) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0) EndFunc ;==>_Draw Func WM_DROPFILES_FUNC($hwnd, $msgID, $wParam, $lParam) Local $nSize, $pFileName Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255) For $i = 0 To $nAmt[0] - 1 $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0) $nSize = $nSize[0] + 1 $pFileName = DllStructCreate("char[" & $nSize & "]") DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize) ReDim $gaDropFiles[$i + 1] $gaDropFiles[$i] = DllStructGetData($pFileName, 1) $pFileName = 0 Next Binary($hwnd + $msgID + $lParam);just to prevent unused var errors -_- EndFunc ;==>WM_DROPFILES_FUNC Func _CreateBrush($iSize, $fArea) Local $fTmp = $iSize * $fArea * 1.20 Local $hPath = _GDIPlus_PathCreate() _GDIPlus_PathAddEllipse($hPath, $fTmp, $fTmp, $iSize - $fTmp * 2, $iSize - $fTmp * 2) Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath) _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFF000000) Local $aColor[2] = [1, 0x00000000] _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColor) _GDIPlus_PathBrushSetFocusScales($hBrush, 0.5, 0.5) _GDIPlus_PathBrushSetGammaCorrection($hBrush, True) _GDIPlus_PathDispose($hPath) Return $hBrush EndFunc ;==>_CreateBrush Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam) _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_PAINT Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam) _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0) Return True EndFunc ;==>WM_ERASEBKGND Func setTrans($hW) Local $x, $Startx, $Endx $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 460, "long", 460) For $y = 0 To 300 $x = Abs((150 * 150 - (150 - $y) * (150 - $y)) ^ 0.5) $Startx = 150 + $x $Endx = 300 addRegion($Startx, $y, $Endx, $y) $Startx = 0 $Endx = 150 - $x addRegion($Startx, $y, $Endx, $y) Next DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hW, "long", $aM_Mask[0], "int", 1) EndFunc ;==>setTrans Func addRegion($a, $b, $c, $d) Local $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $a, "long", $b, "long", $c + 1, "long", $d + 1) DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 3) EndFunc ;==>addRegion Func _Exit() ;_WinAPI_ShowCursor(True) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfxBuffer) _GDIPlus_BitmapDispose($hBmpBuffer) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit
- 5 replies
-
- Gravitational
- lensing
-
(and 6 more)
Tagged with: