Jump to content

Search the Community

Showing results for tags 'magnify'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 3 results

  1. Magnifier Functions UDF That magnify tool in Windows since Vista? Yeah, pretty nice feature eh? Well, turns out there's an API that is going unused around here! We've got to change that! MSDN Links: Magnification API Magnifier Functions Magnifier API Overview (includes examples) This UDF exposes most of the useful Magnifier API functions available since Windows Vista. The built-in Magnifier offers very easy screen magnification in the form of Magnifier controls or Full-screen magnification (since Windows 7). It also allows altering the colors of the magnifier or in face the whole screen. With the Magnify API, you can do all sorts of neat things: Create a hardware-accelerated Magnifier control in any GUI (of any size) Resize any part of the screen by any factor (as a floating point value) Alter the colors (invert, grayscale, etc) Ignore certain windows (they become like invisible windows to the magnifier) Full-screen Color Effects (Win 7+ but official as of Win 8) Full-screen Magnify (Win 7+ but official as of Win 8) Windows 7 has 2 Full-screen Magnification API functions that are considered undocumented, but are nearly identical to their Windows 8 documented API counterparts. Therefore, the UDF script takes care of calling the correct API function based on the O/S. The UDF functions are _MagnifierFullScreenSetScale() and _MagnifierFullScreenSetColorEffect(). The only difference in these functions is SetMagnificationDesktopMagnification uses a double for its 1st parameter whereas MagSetFullscreenTransform uses a float. Here's the Win7 undocumented to Win8 documented API mapping: SetMagnificationDesktopColorEffect - MagSetFullscreenColorEffect SetMagnificationDesktopMagnification - MagSetFullscreenTransform There are two examples included in the ZIP archive. The 1st, MagnifierExperiments, shows all the wacky things that can be done using the Magnifier. The 2nd is an example of Inverting screen colors via a Tray interface (both are below). Updates:: Magnifier Experiments: Various Full-screen and Window magnifier effects tests: ; =========================================================================================================== ; <MagnifierExperiments.au3> ; ; Experiments with the Built-In Windows Magnification API (since Windows Vista) ; Uses <WinMagnifier.au3> ; ; NOTE: TRY to run this at the same bit-mode your O/S is running in, as the GUI can be funky at times ; when run in an incompatible bit mode. So for 64-bit O/S's, run this as x64 only! ; ; Check out the Examples from 'Magnification API Overview', where much of the experiments thus far come from ; @ MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ms692402%28v=vs.85%29.aspx ; ; Author: Ascend4nt ; =========================================================================================================== ;~ #AutoIt3Wrapper_UseX64=Y ; Use when necessary #include "WinMagnifier.au3" #include <WinAPIGdi.au3> ; _WinAPI_DwmIsCompositionEnabled() #Region MAGNIFIER_EXPERIMENTS ; ============================================================================= ; Func _MagnificationExperiments($nWidth, $nHeight, $iX1, $iY1, ; $fMagFactor = Default, $bInvertColors = 1, ; $bShowCursor = False) ; ; ; Author: Ascend4nt ; ============================================================================= Func _MagnificationExperiments($nWidth, $nHeight, $iX1, $iY1, $fMagFactor = Default, $bInvertColors = False, $bShowCursor = False) Local $aTmp, $aColorFX, $hMagnifyGUI, $hMagnifyCtrl ;~ If Not _MagnifierInit() Then Return SetError(@error, 0, 0) $aTmp = _MagnifierGUICreate($nWidth, $nHeight, $iX1, $iY1, $bInvertColors, $bShowCursor) If @error Then Return SetError(@error, 0, 0) $hMagnifyGUI = $aTmp[0] $hMagnifyCtrl = $aTmp[1] ; Optionally make the window Topmost ;~ WinSetOnTop($hMagnifyGUI, "", 0) ; ------------------------- ; -- MAGNIFICATION SCALE -- If $fMagFactor <> Default Then _MagnifierSetScale($hMagnifyCtrl, $fMagFactor) EndIf ; ------------------------- ; ------------------ ; -- SET SOURCE (on screen) -- ;~ _MagnifierSetSource($hMagnifyCtrl, 0, 0, 200, 100) ; ------------------ ; ------------------ ; Exclude Windows! _MagnifierSetWindowFilter($hMagnifyCtrl, WinGetHandle("[CLASS:SciTEWindow]")) ; ------------------ ConsoleWrite("InvertColors flag (MS_INVERTCOLORS) set? = " & _MagnifierIsInvertColorsStyle($hMagnifyCtrl) & @LF) ; ------------------ ; SHOW IT! GUISetState(@SW_SHOW, $hMagnifyGUI) MsgBox(0, "Normal Magnify", "Normal 2x scale") ; Inverted Colors Dim $aColorFX[5][5] = [ _ [-1.0, 0, 0, 0, 0], _ [ 0, -1.0, 0, 0, 0], _ [ 0, 0, -1.0, 0, 0], _ [ 0, 0, 0, 1.0, 0], _ [1.0, 1.0, 1.0, 0, 1.0] ] _MagnifierSetColorEffect($hMagnifyCtrl, $aColorFX) MsgBox(0, "Inverted Colors via ColorFX", "Inverted Colors via ColorEffects") ;~ _MagnifierSetInvertColorsStyle($hMagnifyCtrl, True) ;~ MsgBox(0, "Inverse Color Style", "Inverse Effect Color Style (control style)") ; ------------------ ;~ $aColorFX = _MagnifierGetColorEffect($hMagnifyCtrl) ;~ _ArrayDisplay($aColorFX, "Color Effects Matrix") ; ------------------ ; -- CLEAR COLOR EFFECTS -- _MagnifierClearColorEffects($hMagnifyCtrl) ; ------------------ ; Still set after Setting Color Effects to Identity Matrix (restored original colors) ;~ ConsoleWrite("InvertColors flag (MS_INVERTCOLORS) set? = " & _MagnifierIsInvertColorsStyle($hMagnifyCtrl) & @LF) ; ------------------------- ; -- SET SOURCE AGAIN -- _MagnifierSetSource($hMagnifyCtrl, $iX1 + 100, $iY1 + 100, $iX1 + $nWidth, $iY1 + $nHeight) MsgBox(0, "Source Change", "Moved Source & Cleared Effects") ; ------------------ ; -- COLOR EFFECTS -- If 1 Then _MagnifierSetColorEffect($hMagnifyCtrl, $COLOR_EFFECTS_GRAYSCALE_MATRIX) MsgBox(0, "Grayscale", "Grayscale Color Effects") EndIf ; ------------------ GUIDelete($hMagnifyGUI) Return 1 EndFunc #Region MAIN_CODE _WinMain() ; ------------------= MAIN CODE =----------------------- Func _WinMain() ; Force restart with AutoIt x64 if running on a 64-bit O/S If @OSArch = "X64" And Not @AutoItX64 And Not _IsScriptCompiledToExe() Then Exit ShellExecute(StringReplace(@AutoItExe, ".exe", "_x64.exe", -1),'/AutoIt3ExecuteScript "' & @ScriptFullPath & '"', @WorkingDir) EndIf ; Setting DWM off has these effects: ; - Full-screen Magnifier Color Effects AND Magnification do NOT work ; - Magnifier Control will not 'ignore' windows with _MagnifierSetWindowFilter() ; - Magnified images tend to look blurry - possibly software-mode magnification? ; Force DWM off so Full-screen Effect tests don't run ;_WinAPI_DwmEnableComposition(False) If Not _MagnifierInit() Then Exit @error ; Magnifier Full-screen Effects Require DWM Composition to be enabled If _WinAPI_DwmIsCompositionEnabled() Then If _MagnifierFullScreenSetColorEffect($COLOR_EFFECTS_GRAYSCALE_MATRIX) Then MsgBox(0, "Full-screen Magnify FX", "Gray-scale Color Effects!") ;~ $aColorFX = _MagnifierFullScreenGetColorEffect() ;~ _ArrayDisplay($aColorFX, "Full-screen matrix after Grayscale Transform") _MagnifierFullScreenClearColorEffects() MsgBox(0, "Full-screen Magnify FX", "Colors back to normal! Yay?") EndIf ; Full-screen Magnifier issues: ; - Windows Vista: Not supported ($g_nWinMagnifyAPILevel = 1) ; - Windows 7: Uses negative numbers, not entirely sure of how these values are mapped just yet ; - Windows 8: Works pretty much as expected (and documented) - use positive #'s indicating top-left of scaled screen If $g_nWinMagnifyAPILevel >= 7 Then Local $bRet ; Difference in calculations for Win7 and Win8 - need a consistent mapping method! If $g_nWinMagnifyAPILevel = 7 Then _MagnifierFullScreenSetScale(2.0, -1 * @DesktopWidth / 2, -1 * @DesktopHeight / 2) Else ; $g_nWinMagnifyAPILevel >= 8 _MagnifierFullScreenSetScale(2.0, @DesktopWidth / 4, @DesktopHeight / 4) EndIf MsgBox(0, "Full-screen Scale FX", "Scaled 2x") _MagnifierFullScreenSetScale(1.0) MsgBox(0, "Full-screen Scale FX", "Back to 1x scale") EndIf ; Brightness Lowering isolated (Contrast & Saturation look bad) Dim $aColorFX[5][5] = [ _ [ 1.0, 0, 0, 0, 0], _ [ 0, 1.0, 0, 0, 0], _ [ 0, 0, 1.0, 0, 0], _ [ 0, 0, 0, 1.0, 0], _ [-0.5, -0.5, -0.5, 0, 1.0] ] ; Brightness - Lowering - Color Components Dim $aColorFX[5][5] = [ _ [0.6, 0, 0, 0, 0], _ [ 0, 0.6, 0, 0, 0], _ [ 0, 0, 0.6, 0, 0], _ [ 0, 0, 0, 1.0, 0], _ [ 0, 0, 0, 0, 1.0] ] _MagnifierFullScreenSetColorEffect($aColorFX) MsgBox(0, "Brightness Lowered Fullscreen", "Fullscreen ColorEffects - Brightness Reduced") ; Verify effects (false here): ;ConsoleWrite("Inversion Matrix Comparison Result:" & _MagnifierColorEffectIsEqual(_MagnifierFullScreenGetColorEffect(), $COLOR_EFFECTS_INVERSION_MATRIX) & @LF) _MagnifierFullScreenSetColorEffect($COLOR_EFFECTS_INVERSION_MATRIX) MsgBox(0, "Inverted Fullscreen", "Fullscreen ColorEffects - Inversion." & @CRLF & _ "Inversion Matrix Comparison Result:" & _MagnifierColorEffectIsEqual(_MagnifierFullScreenGetColorEffect(), $COLOR_EFFECTS_INVERSION_MATRIX)) #cs ; Inverted Colors - Lowered Brightness (adding to color components, reducing brightness components) Dim $aColorFX[5][5] = [ _ [-0.7, 0, 0, 0, 0], _ [ 0, -0.7, 0, 0, 0], _ [ 0, 0, -0.7, 0, 0], _ [ 0, 0, 0, 1.0, 0], _ [0.7, 0.7, 0.7, 0, 1.0] ] _MagnifierFullScreenSetColorEffect($aColorFX) MsgBox(0, "Inverted LB Fullscreen", "Fullscreen ColorEffects - Inversion Lowered Brightness") #ce #cs ; Inverted Colors - Increased Brightness Dim $aColorFX[5][5] = [ _ [-1.3, 0, 0, 0, 0], _ [ 0, -1.3, 0, 0, 0], _ [ 0, 0, -1.3, 0, 0], _ [ 0, 0, 0, 1.0, 0], _ [1.3, 1.3, 1.3, 0, 1.0] ] _MagnifierFullScreenSetColorEffect($aColorFX) MsgBox(0, "Inverted IB Fullscreen", "Fullscreen ColorEffects - Inversion Increased Brightness") #ce ;~ _MagnifierFullScreenSetColorEffect($COLOR_EFFECTS_BW_MATRIX) ;~ MsgBox(0, "Black & White Fullscreen", "Black & White Fullscreen ColorEffects") _MagnifierFullScreenSetColorEffect($COLOR_EFFECTS_SEPIA_TONE_MATRIX) MsgBox(0, "Sepia FullScreen", "Sepia Fullscreen ColorEffects") _MagnifierFullScreenClearColorEffects() MsgBox(0, "Color Restored", "Restored Normal Colors") EndIf ; IMPORTANT - Magnification GUI will fail to work properly sometimes if run in x86 mode on a 64bit O/S ; For this reason, ALWAYS run the Magnification code in the SAME bit-mode as the O/S (x86 in 32-bit O/S's, x64 in 64-bit O/S's) ;~ ConsoleWrite("Title = " & WinGetTitle("[CLASS:SciTEWindow]") & @CRLF) _MagnificationExperiments(@DesktopWidth, @DesktopHeight / 2, 0, @DesktopHeight / 2, 2.0) EndFunc #EndRegion MAIN_CODE #EndRegion MAGNIFIER_EXPERIMENTS #Region MISC_FUNCTIONS ; ============================================================================= ; Func _IsScriptCompiledToExe() ; ; Returns True if the Script has been compiled to an Executable. ; Returns False for .AU3 and .A3X-compiled scripts, as well as scripts run from a different executable ; (CompiledScript.exe /AutoIt3ExecuteScript AnotherScript.exe) ; ; The common method for checking @Compiled is error-prone especially when a script is compiled to .A3X ; To deal with this annoying oversight by the devs (who could easily make @Compiled return -1 for A3X), ; this function checks the path to executable against the script path to make sure they are 1 and the same ; ; While this doesn't detect scripts run from another executable, the situation is basically the same ; - the script still does not have access to the original executable file's resources ; ; Author: Ascend4nt ; ============================================================================= Func _IsScriptCompiledToExe() Return (@Compiled And @AutoItExe = @ScriptFullPath) EndFunc #EndRegion MISC_FUNCTIONS _ Screen Inverter: Toggle full-screen Color Inversion on and off via the Tray: ; =========================================================================================================== ; <MagnifierScreenInverter.au3> ; ; Simple Full-Screen Color Inversion example. Toggle Color Inversion on/off via Tray. ; Important: Requires Win 7+ ; ; Note: May work cleaner if run in same bitness (32/64) as O/S.. it seems some transitions in DWM ; cause the Magnifier tool (magnifier.exe) to crash if used in conjunction with this script. ; ; Uses <WinMagnifier.au3> ; ; Author: Ascend4nt ; =========================================================================================================== ;~ #AutoIt3Wrapper_UseX64=Y ; Optional, may work better if in same bitness as O/S #include "WinMagnifier.au3" #include <WinAPIGdi.au3> ; _WinAPI_DwmIsCompositionEnabled() Global $g_bDwmActive = False Global $g_bInvertOn = False, $g_cTrayInvertToggle = 0 #Region MAIN_CODE Exit _WinMain() Func _WinMain() ; Singleton code: If WinExists("0bc53fe0-59c2-11e2-bcfd-0800200c_9a66") Then Return 1111 AutoItWinSetTitle("0bc53fe0-59c2-11e2-bcfd-0800200c_9a66") ; Vista Minimum for Magnifier, but Full-Screen FX requires Win7+ If Not _MagnifierInit() Or $g_nWinMagnifyAPILevel <= 1 Then Return @error Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1+2) Opt("GUIOnEventMode", 1) If Not _WinAPI_DwmIsCompositionEnabled() Then If MsgBox(32 + 3, "Warning: DWM is OFF", _ "Desktop Composition is OFF, which makes Color Inversion Impossible" & @CRLF & _ "unless Re-Enabled!" & @CRLF & _ "Would you like to run this program anyway? ") <> 6 Then Return 2222 EndIf TraySetClick(8) $g_cTrayInvertToggle = TrayCreateItem("Invert Colors Toggle") TrayItemSetOnEvent(-1, "_ToggleInvertColors") TrayCreateItem("") TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "_Exit") ; Automatically Invert on Left-Click Icon TraySetOnEvent(-7, "_ToggleInvertColors") ; $TRAY_EVENT_PRIMARYDOWN -7 TraySetToolTip("Screen Color Inverter (Left-Click Toggles, Right-Click For Menu)") #cs ; OPTIONAL: ; Create a Dummy GUI so we can receive and react to WM_DWMCOMPOSITIONCHANGED Messages Local $hDummyGUI = GUICreate("") GUIRegisterMsg(0x031E, "_DwmCompositionChange") ; WM_DWMCOMPOSITIONCHANGED 0x031E #ce ; Not necessary, but can free some memory by flushing data to disk DllCall("psapi.dll", "bool", "EmptyWorkingSet", "handle", -1) While 1 Sleep(50) WEnd EndFunc #EndRegion MAIN_CODE #Region TRAY_ONEVENT_FUNCS Func _ToggleInvertColors() If $g_bInvertOn Then TrayItemSetState($g_cTrayInvertToggle, 4) _MagnifierFullScreenClearColorEffects() ;~ ConsoleWrite("Inversion: OFF"&@LF) $g_bInvertOn = False Else ; Magnifier Full-screen Effects Require DWM Composition to be enabled If _WinAPI_DwmIsCompositionEnabled() Then TrayItemSetState($g_cTrayInvertToggle, 1) _MagnifierFullScreenSetColorEffect($COLOR_EFFECTS_INVERSION_MATRIX) ;~ ConsoleWrite("Inversion: ON"&@LF) $g_bInvertOn = True EndIf EndIf EndFunc #cs ; OPTIONAL: Func _DwmCompositionChange($hWnd, $nMsg, $wParam, $lParam) ConsoleWrite("DwmCompositionChanged!"&@LF) If _WinAPI_DwmIsCompositionEnabled() Then $g_bDwmActive = True If $g_bInvertOn Then ; Doesn't appear to be necessary (state is recovered): ;_MagnifierFullScreenSetColorEffect($COLOR_EFFECTS_INVERSION_MATRIX) EndIf Else $g_bDwmActive = False EndIf Return 0 EndFunc #ce Func _Exit() _MagnifierUnInit() Exit EndFunc #EndRegion TRAY_ONEVENT_FUNCS WinMagnifier.zip ~prev downloads: 48
  2. 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
  3. So I've been playing with some code I've got, most of which was ripped from UEZ and created some miscellaneous useless scripts and suddenly I felt compelled to find a way to add en effect to an image that would make it look like if there is a black hole in your desktop. I've searched and searched to no avail and now I'm here. Anyone know how to add an effect to an image as picture related? #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/so #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%%scriptfile%_Obfuscated.au3" #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Include <WindowsConstants.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> #include <GDIPlus.au3> HotKeySet("{ESC}","close") Global $Img = @ScriptDir&"test.png" Global $aM_Mask, $GUI, $hwnd Global $IMAGE_BITMAP = 0 Global $STM_SETIMAGE = 0x0172 Init() Func Init() _GDIPlus_Startup() Local $hwnd = GUICreate("Test", 300, 300, -1, -1,$WS_POPUP,-1,GUICreate("ghost"));$WS_EX_TOPMOST GUICtrlCreatePic("",0,0,400,400,-1,0x00100000); only for enable dragging of the gui GUISetBkColor(0x000000,$hwnd) _ScreenCapture_CaptureWnd($Img,$hwnd);leaving the courser... GUISetState() 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) setTrans($hwnd) Do $Pos = WinGetPos($hwnd) If ($Pos[0] <> $TmpPos[0]) Or ($Pos[1] <> $TmpPos[1]) Then GUISetState(@SW_HIDE) _GDIPlus_BitmapDispose($image) Sleep(100) _ScreenCapture_CaptureWnd($Img,$hwnd);leaving the courser.. $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 ;_GDIPlus_MatrixRotate($matrix, 0.01) _GDIPlus_GraphicsSetTransform($backbuffer, $matrix) _GDIPlus_GraphicsDrawImageRect($backbuffer, $image, -150, -150, 300, 300);-150,-150) _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 300, 300) Sleep(20) Until 0 Return EndFunc Func close() 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 Edit: forgot to explain the script, the script basically takes a snapshot of the background area of where the gui is going to appear and then loads the image to the gui, which is a big circle really, I want to find a way of making the picture look a little warped before adding it to the gui so it will have a black hole effect or something.
×
×
  • Create New...