Jump to content

Search the Community

Showing results for tags 'inverse'.

  • 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 1 result

  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
×
×
  • Create New...