Jump to content

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

Invert screen colors


  • Please log in to reply
25 replies to this topic
Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
Not perfect, high CPU usage, but saves your eyes health. I wanted simplicity (no magnifiers, etc.), just invert colors.
Based on Sean's and Wingfat's scripts. Thank you guys!
Obsolete for Win7 users --> there is a built in Color inversion function in magnifier.

Default Hotkeys:
F9 toggles Invert screen colors
Escape ExitApp

/*===Description=========================================================================

Invert screen colors

Put together by Learning one
Based on Sean's and Wingfat's scripts
Sean: http://www.autohotkey.com/forum/topic18167.html
Wingfat: http://www.autohotkey.com/forum/topic49265.html
Thanks: Sean, Wingfat

Not perfect, high CPU usage, but saves your eyes health.
Obsolete for Win7 users --> there is a built in Color inversion function in magnifier
*/


;===Settings============================================================================
Hotkey = F9				; toggles Invert screen colors
RepaintPeriod = 80		; repaint screen period (don't set it too low! --> heavy CPU load)

 
;===Auto-execute continuation===========================================================
#SingleInstance ignore
OnExit ExitSub
Gui, +AlwaysOnTop +ToolWindow +E0x00000020 
Gui, color, black
Gui, Show, na X0 Y0 W%A_ScreenWidth% H%A_ScreenHeight%, InvertScreenColors
WinSet, Transparent, 255, InvertScreenColors
Gui, -Caption

WinGet, PrintSourceID, id
hdd_frame := DllCall("GetDC", UInt, PrintSourceID)
WinGet, PrintScreenID,  id, InvertScreenColors
hdc_frame := DllCall("GetDC", UInt, PrintScreenID)
DllCall("gdi32.dll\SetStretchBltMode", "uint", hdc_frame, "int", 4)
SetTimer, Repaint, %RepaintPeriod%
Hotkey, %Hotkey%, ISC
Return      ;===Auto-execute ends here===


;===Subroutines=========================================================================
Repaint:
DllCall("gdi32.dll\StretchBlt", UInt, hdc_frame, Int, 0, Int, 0, Int, A_ScreenWidth, Int, A_ScreenHeight, UInt, hdd_frame, Int, 0, Int, 0, Int, A_ScreenWidth, Int, A_ScreenHeight, UInt, 0x330008) 
Return

ISC:
ISC ++
if ISC = 1
{
	SetTimer, Repaint, off
	Gui, hide
}
Else
{
	SetTimer, Repaint, %RepaintPeriod%
	Gui, show, na
	ISC = 0
}
Return

ExitSub:
DllCall("gdi32.dll\DeleteDC", UInt, hdc_frame)
DllCall("gdi32.dll\DeleteDC", UInt, hdd_frame)
ExitApp

;===Exit Hotkey==========================================================================
Escape::ExitApp


HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
That is quite nice, thank you ;)
Can you make it work for all monitors?

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
Thanks. Unfortunately, I don't have any experience with multiple monitors.

TheGood
  • Members
  • 589 posts
  • Last active: Mar 22 2014 03:22 PM
  • Joined: 30 Jul 2007

Obsolete for Win7 users --> there is a built in Color inversion function in magnifier.

Isn't there also one in Windows XP's Magnifier?

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
Yes, but Windows XP's Magnifier can't show full screen inverted - half is the maximum. Win7 Magnifier can show full screen inverted.
You can also press alt + shift + print screen to switch to high contrast display, but this looks bad (for my taste)

I'm still on Win XP. I hope I'll upgrade to Win7 soon.

soulfx
  • Guests
  • Last active:
  • Joined: --
Thank you for putting this together. I've been looking for this functionality in windows xp for a while.

lastnikita
  • Guests
  • Last active:
  • Joined: --
Looks like this doesn't work for me : WinSet, Transparent, 255, InvertScreenColors

I'm only getting a black screen :)

berban
  • Members
  • 202 posts
  • Last active: Apr 12 2019 01:08 AM
  • Joined: 30 Dec 2009
This is really really nice!! although as you mentioned, autohotkey.exe using 17% of system resources... not a usual occurrence haha

Find me on the new AutoHotkey forums and send me a message if you have a question about any of the scrips I've posted to this forum!


Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
@lastnikita: I'm on Win XP SP3, using this script daily, and it works fine for me...

lastnikita
  • Guests
  • Last active:
  • Joined: --
I assumed so :)
Do you know what part could fail so that I only get a black screen ?
If I hit F9, it switches fine to normal.
F9 again -> black screen.

If you tell me what part may fail, I'll have a look :)

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
I have no idea so I can't help you :(

iridescentFUZZ
  • Guests
  • Last active:
  • Joined: --
Thank you so much for this script!

I've been looking for a screen inverter for over a year now.

It seems a little buggy when you open an "Always on Top" window after inverting, but it's just a matter of hitting F9 twice. The CPU usage is a little
noticeable, but since I'm going to be using this majorly for text-heavy pages, no real issues.

Thanks a lot, once again!

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006

Not perfect, high CPU usage

Same with low CPU usage would be just perfect! Is this possible somehow in Windows XP, even without ahk, maybe some other external tool? The idea is simple and great already.

x79animal
  • Members
  • 1021 posts
  • Last active: May 14 2013 04:21 PM
  • Joined: 01 May 2010

Obsolete for Win7 users --> there is a built in Color inversion function in magnifier.


This is true, however having the window open is always an annoyance.(and i would like to add it to my autohotkey master script)

do you know of any way to run it with inversion and then hide it?

such as

Run, Magnifier.exe -inverted
WinWait, Magnifier
WinHide
does anyone know what the parameter is to run it through? to get inverted

x79animal
  • Members
  • 1021 posts
  • Last active: May 14 2013 04:21 PM
  • Joined: 01 May 2010
repost~? ok i found it out, this works

Run, Magnify.exe -invert
WinWait, Magnifier
WinHide

:D:D