Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Add color invert to this script


  • Please log in to reply
5 replies to this topic
Wingfat
  • Members
  • 937 posts
  • Last active: Oct 14 2015 04:20 PM
  • Joined: 23 Aug 2004
would it be possible to add in the color invert to this Magnify scritp?


; Autohotkey script "Screen Magnifier"
;=================================================================================
#SingleInstance ignore
Process, Priority, , High
OnExit handle_exit
hotkey, Space,  toggle_follow
hotkey, Escape, GuiClose
hotkey, F18,    GuiClose
; Init variables
  follow    := 1
  ZOOMFX    := 1.189207115
  zoom      := 2
  antialias := 1
  delay     := 10

  whMax     := 400
  wh        := 200
  whMin     := 100

  wwMax     := 800
  ww        := 480
  wwMin     := 200


  mx        := 0
  my        := 0
  mxp       := mx
  myp       := my
  wwD       := 0
  whD       := 0


; Init zoom window

  MouseGetPos, mx, my

  Gui, +AlwaysOnTop  +Owner -Resize -ToolWindow +E0x00000020
  Gui, Show, NoActivate W%ww% H%wh% X-1000 Y-1000, MagWindow ; start offscreen

  WinSet, Transparent  , 254, MagWindow
  Gui, -Caption
  Gui, +Border

  WinGet, PrintSourceID, id
  hdd_frame := DllCall("GetDC", UInt, PrintSourceID)

  WinGet, PrintScreenID,  id, MagWindow
  hdc_frame := DllCall("GetDC", UInt, PrintScreenID)
  if(antialias != 0)
      DllCall("gdi32.dll\SetStretchBltMode", "uint", hdc_frame, "int", 4*antialias)


Gosub, Repaint
return
;=================================================================================
; Input events

WheelUp::       ; zoom in
  if zoom < 8
      zoom *= %ZOOMFX%
return

WheelDown::     ; zoom out
  if zoom > %ZOOMFX%
      zoom /= %ZOOMFX%
return


+WheelDown::    ; larger
  wwD =  32
  whD =  32
  Gosub, Repaint
return

+WheelUp::      ; smaller
  wwD = -32
  whD = -32
  Gosub, Repaint
return

;=================================================================================
; toggle_follow
toggle_follow:
    follow := 1 - follow
return

; Repaint
Repaint:
    CoordMode,   Mouse, Screen
    MouseGetPos, mx, my
    WinGetPos,   wx, wy, ww, wh, MagWindow

    if(wwD != 0)
    {
       ww  += wwD
       wh  += whD
       wwD = 0
       whD = 0
    }

    if(mx != mxp) OR (my !- myp)
    {
        DllCall( "gdi32.dll\StretchBlt"
                , UInt, hdc_frame
                , Int , 2                       ; nXOriginDest
                , Int , 2                       ; nYOriginDest
                , Int , ww-6                    ; nWidthDest
                , Int , wh-6                    ; nHeightDest
                , UInt, hdd_frame               ; hdcSrc
                , Int , mx - (ww / 2 / zoom)    ; nXOriginSrc
                , Int , my - (wh / 2 / zoom)    ; nYOriginSrc
                , Int , ww / zoom               ; nWidthSrc
                , Int , wh / zoom               ; nHeightSrc
                , UInt, 0xCC0020)               ; dwRop (raster operation)

       if(follow == 1)
           WinMove, MagWindow, ,mx-ww/2, my-wh/2, %ww%, %wh%

        mxp = mx
        myp = my
    }

    SetTimer, Repaint , %delay%
return

; GuiClose handle_exit
GuiClose:
handle_exit:
   DllCall("gdi32.dll\DeleteDC"    , UInt,hdc_frame )
   DllCall("gdi32.dll\DeleteDC"    , UInt,hdd_frame )
Process, Priority, , Normal
ExitApp

;=================================================================================

I know that there is this ColorZoomer in the Scripts Forum that has the option to invert the colors.. just havnet figured out how to add that function to the above script with some sort of hot key like Ctrl Atl C..
Magnifier(bInvert = False)
{
   nZ := 4                               ; Zoom Factor
   nW := A_ScreenWidth // 2 //2//nZ      ; Width  of (small) Target Rectangle
   nH := A_ScreenHeight// 6 //2//nZ      ; Height of (small) Target Rectangle

   ToolTip, %A_Space%
   WinGet, hWnd, ID, ahk_class tooltips_class32
   WinClose, ahk_class SysShadow      ; Comment it out to have the DropShadow

   hDC_SC := DllCall("GetDC", "Uint",    0)
   hDC_LW := DllCall("GetDC", "Uint", hWnd)
   hDC_TT := DllCall("GetDC", "Uint", hWnd)

   DllCall("SetStretchBltMode", "Uint", hDC_TT, "int", 4)

   Loop
   {
      MouseGetPos, xCursor, yCursor
      DllCall("BitBlt", "Uint", hDC_LW, "int", 0, "int", 0, "int", 2*nW, "int", 2*nH, "Uint", hDC_SC, "int", xCursor-nW, "int", yCursor-nH, "Uint", 0x40CC0020)
      If bInvert
      DllCall("BitBlt", "Uint", hDC_LW, "int", 0, "int", 0, "int", 2*nW, "int", 2*nH, "Uint", 0, "int", 0, "int", 0, "Uint", 0x00550009)
      Cursor(hDC_LW, nW, nH)      ; Capture magnified mouse cursor.
      DllCall("StretchBlt", "Uint", hDC_TT, "int", 0, "int", 0, "int", 2*nW*nZ, "int", 2*nH*nZ, "Uint", hDC_LW, "int", 0, "int", 0, "int", 2*nW, "int", 2*nH, "Uint", 0x00CC0020)
;      Cursor(hDC_TT, nW*nZ, nH*nZ)   ; Capture un-magnified mouse cursor.
      WinMove, ahk_id %hWnd%,, xCursor-(nW*nZ+1), yCursor+nH, 2*(nW*nZ+1), 2*(nH*nZ+1)

      If GetKeyState("Esc")
         Break
   }

   DllCall("ReleaseDC", "Uint",    0, "Uint", hDC_SC)
   DllCall("ReleaseDC", "Uint", hWnd, "Uint", hDC_LW)
   DllCall("ReleaseDC", "Uint", hWnd, "Uint", hDC_TT)

   WinClose, ahk_id %hWnd%
}

----------------------------
Wingfool you fat! I mean, Wingfat you fool!
Line from Woody Allen's movie "What's Up Tiger Lilly?"
-----------------------------

Wingfat
  • Members
  • 937 posts
  • Last active: Oct 14 2015 04:20 PM
  • Joined: 23 Aug 2004
any one? someone have any idea on how to invert white and black colors for this app or where to point me in the rigth direction?
----------------------------
Wingfool you fat! I mean, Wingfat you fool!
Line from Woody Allen's movie "What's Up Tiger Lilly?"
-----------------------------

  • Guests
  • Last active:
  • Joined: --
All you need to do is set the ROP to 6 (R2_NOT) using "SetROP2", then call "FillRect" on the entire magnifier DC. This should be done after the StreachBlt, of course.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
Change 0xCC0020 in your script to 0x330008.

Wingfat
  • Members
  • 937 posts
  • Last active: Oct 14 2015 04:20 PM
  • Joined: 23 Aug 2004
okay.. so here is my new script.. i does the regular magnify, and the color invert. but when i run the color invert it flashes back and forth between normal and inverted.. any ideas on how to clean up my script to make it run smoother?

; Autohotkey script "Screen Magnifier"
;=================================================================================
#SingleInstance ignore
Process, Priority, , High
OnExit handle_exit
hotkey, Space,  toggle_follow
hotkey, Escape, GuiClose
hotkey, F18,    GuiClose

; Init variables
  follow    := 1
  ZOOMFX    := 1.189207115
  zoom      := 2
  antialias := 1
  delay     := 10

  whMax     := 400
  wh        := 200
  whMin     := 100

  wwMax     := 800
  ww        := 480
  wwMin     := 200


  mx        := 0
  my        := 0
  mxp       := mx
  myp       := my
  wwD       := 0
  whD       := 0


; Init zoom window

  MouseGetPos, mx, my

  Gui, +AlwaysOnTop  +Owner -Resize -ToolWindow +E0x00000020
  Gui, Show, NoActivate W%ww% H%wh% X-1000 Y-1000, MagWindow ; start offscreen

  WinSet, Transparent  , 254, MagWindow
  Gui, -Caption
  Gui, +Border

  WinGet, PrintSourceID, id
  hdd_frame := DllCall("GetDC", UInt, PrintSourceID)

  WinGet, PrintScreenID,  id, MagWindow
  hdc_frame := DllCall("GetDC", UInt, PrintScreenID)
  if(antialias != 0)
      DllCall("gdi32.dll\SetStretchBltMode", "uint", hdc_frame, "int", 4*antialias)


Gosub, Repaint
return
;=================================================================================
; Input events


^WheelUp::       ; zoom in
  if zoom < 8
      zoom *= %ZOOMFX%
return

^WheelDown::     ; zoom out
  if zoom > %ZOOMFX%
      zoom /= %ZOOMFX%
return


+WheelDown::    ; larger
  wwD =  32
  whD =  32
  Gosub, Repaint
return

+WheelUp::      ; smaller
  wwD = -32
  whD = -32
  Gosub, Repaint
return

;=================================================================================
; toggle_follow
toggle_follow:
    follow := 1 - follow
return

; Repaint
Repaint:
    CoordMode,   Mouse, Screen
    MouseGetPos, mx, my
    WinGetPos,   wx, wy, ww, wh, MagWindow

    if(wwD != 0)
    {
       ww  += wwD
       wh  += whD
       wwD = 0
       whD = 0
    }

    if(mx != mxp) OR (my !- myp)
    {
        DllCall( "gdi32.dll\StretchBlt"
                , UInt, hdc_frame
                , Int , 2                       ; nXOriginDest
                , Int , 2                       ; nYOriginDest
                , Int , ww-6                    ; nWidthDest
                , Int , wh-6                    ; nHeightDest
                , UInt, hdd_frame               ; hdcSrc
                , Int , mx - (ww / 2 / zoom)    ; nXOriginSrc
                , Int , my - (wh / 2 / zoom)    ; nYOriginSrc
                , Int , ww / zoom               ; nWidthSrc
                , Int , wh / zoom               ; nHeightSrc
                , UInt, 0xCC0020)               ; dwRop (raster operation)

       if(follow == 1)
           WinMove, MagWindow, ,mx-ww/2, my-wh/2, %ww%, %wh%

        mxp = mx
        myp = my
    }

    SetTimer, Repaint , %delay%
return

; Repaint(2)
^+c::GoSub, Repaint2
Repaint2:
    CoordMode,   Mouse, Screen
    MouseGetPos, mx, my
    WinGetPos,   wx, wy, ww, wh, MagWindow

    if(wwD != 0)
    {
       ww  += wwD
       wh  += whD
       wwD = 0
       whD = 0
    }

    if(mx != mxp) OR (my !- myp)
    {
        DllCall( "gdi32.dll\StretchBlt"
                , UInt, hdc_frame
                , Int , 2                       ; nXOriginDest
                , Int , 2                       ; nYOriginDest
                , Int , ww-6                    ; nWidthDest
                , Int , wh-6                    ; nHeightDest
                , UInt, hdd_frame               ; hdcSrc
                , Int , mx - (ww / 2 / zoom)    ; nXOriginSrc
                , Int , my - (wh / 2 / zoom)    ; nYOriginSrc
                , Int , ww / zoom               ; nWidthSrc
                , Int , wh / zoom               ; nHeightSrc
                , UInt, 0x330008)               ; dwRop (raster operation)

       if(follow == 1)
           WinMove, MagWindow, ,mx-ww/2, my-wh/2, %ww%, %wh%

        mxp = mx
        myp = my
    }

    SetTimer, Repaint2 , %delay%
return


; GuiClose handle_exit
GuiClose:
handle_exit:
   DllCall("gdi32.dll\DeleteDC"    , UInt,hdc_frame )
   DllCall("gdi32.dll\DeleteDC"    , UInt,hdd_frame )
Process, Priority, , Normal
ExitApp

;=================================================================================
Use Ctrl Shift C to change to the inverted colors
----------------------------
Wingfool you fat! I mean, Wingfat you fool!
Line from Woody Allen's movie "What's Up Tiger Lilly?"
-----------------------------

Wingfat
  • Members
  • 937 posts
  • Last active: Oct 14 2015 04:20 PM
  • Joined: 23 Aug 2004
almost there.. still flickers though :( not sure how to end that and to get it to change back to normal after using the invert key combo
----------------------------
Wingfool you fat! I mean, Wingfat you fool!
Line from Woody Allen's movie "What's Up Tiger Lilly?"
-----------------------------