Jump to content


Photo

Invert screen colors


  • Please log in to reply
25 replies to this topic

#1 Learning one

Learning one
  • Members
  • 1292 posts

Posted 25 February 2010 - 11:45 PM

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


#2 HotKeyIt

HotKeyIt
  • Fellows
  • 6119 posts

Posted 26 February 2010 - 07:06 AM

That is quite nice, thank you ;)
Can you make it work for all monitors?

#3 Learning one

Learning one
  • Members
  • 1292 posts

Posted 26 February 2010 - 07:41 PM

Thanks. Unfortunately, I don't have any experience with multiple monitors.

#4 TheGood

TheGood
  • Members
  • 589 posts

Posted 27 February 2010 - 12:00 AM

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

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

#5 Learning one

Learning one
  • Members
  • 1292 posts

Posted 27 February 2010 - 05:10 PM

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.

#6 soulfx

soulfx
  • Guests

Posted 29 April 2010 - 04:30 AM

Thank you for putting this together. I've been looking for this functionality in windows xp for a while.

#7 lastnikita

lastnikita
  • Guests

Posted 21 October 2010 - 12:38 AM

Looks like this doesn't work for me : WinSet, Transparent, 255, InvertScreenColors

I'm only getting a black screen :)

#8 berban

berban
  • Members
  • 180 posts

Posted 21 October 2010 - 10:55 AM

This is really really nice!! although as you mentioned, autohotkey.exe using 17% of system resources... not a usual occurrence haha

#9 Learning one

Learning one
  • Members
  • 1292 posts

Posted 21 October 2010 - 06:26 PM

@lastnikita: I'm on Win XP SP3, using this script daily, and it works fine for me...

#10 lastnikita

lastnikita
  • Guests

Posted 22 October 2010 - 12:02 AM

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 :)

#11 Learning one

Learning one
  • Members
  • 1292 posts

Posted 23 October 2010 - 09:04 AM

I have no idea so I can't help you :(

#12 iridescentFUZZ

iridescentFUZZ
  • Guests

Posted 25 October 2010 - 02:13 PM

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!

#13 automaticman

automaticman
  • Members
  • 658 posts

Posted 08 November 2010 - 01:01 PM

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.

#14 x79animal

x79animal
  • Members
  • 1021 posts

Posted 08 November 2010 - 01:33 PM

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

#15 x79animal

x79animal
  • Members
  • 1021 posts

Posted 08 November 2010 - 01:36 PM

repost~? ok i found it out, this works

Run, Magnify.exe -invert
WinWait, Magnifier
WinHide

:D:D