Jump to content

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

Ghoster: Put a transparent image across your screen


  • Please log in to reply
29 replies to this topic
skrommel
  • Members
  • 193 posts
  • Last active: Jun 07 2010 08:30 AM
  • Joined: 30 Jul 2004
:D You've probably seen programs like Ghost-It put a transparent image across the screen? I stumbeled across a solution using WinSet,Region.

Ghoster creates a colored, transparent Gui to cover the screen, loads an image and keeps punching holes in it to make the mouse work.

This originally started as DimInactive at http://www.autohotke...opic.php?t=4510.

:!: Update: Moved the settings to an ini-file.

:!: Update: Please visit http://www.donationcoders.com/skrommel for the latest version.

Skrommel


;Ghoster
; Shows a transparent image across the desktop, dims inactive windows
;Skrommel @2005

#SingleInstance,Force
SetBatchLines,-1
SetWindelay,0
OnExit,QUIT

START:
Gosub,READINI
Gosub,TRAYMENU
CoordMode,Mouse,Screen
WinGet,oldid,ID,A
WinGet,oldtop,ExStyle,ahk_id %oldid%
oldtop:=oldtop & 0x8

params=
If multimon=1
{
  SysGet,mon1,Monitor,1
  SySGet,mon2,Monitor,2
  SysGet,mon3,Monitor,3
  SySGet,mon4,Monitor,4
  desktopw:=mon1Right
  If mon2Right>%desktopw%
    desktopw:=mon2Right
  If mon3Right>%desktopw%
    desktopw:=mon3Right
  If mon4Right>%desktopw%
    desktopw:=mon4Right
  desktoph:=mon1Bottom
  If mon2Bottom>%desktoph%
    desktoph:=mon2Bottom
  If mon3Bottom>%desktoph%
    desktoph:=mon3Bottom
  If mon4Bottom>%desktoph%
    desktoph:=mon4Bottom
}
Else
{
  desktopw=%desktopw%
  desktoph=%desktoph%
}
If stretchwidth=1
{
  width=%desktopw%
  x=0
}
If stretchheight=1
{
  height=%desktoph%
  y=0
}
If keepaspect=1
  If width<>
    height=-1
  Else
    width=-1
If x<>
  params=%params% X%x%
If y<>
  params=%params% Y%y%
If width<>
  params=%params% W%width%
If height<>
  params=%params% H%height%
  
Gui,+ToolWindow +AlwaysOnTop -Disabled -SysMenu -Caption
Gui,Margin,0,0
If backcolor<>
  Gui,Color,%backcolor% 
If image<>
  Gui,Add,Picture,%params%,%image%
Gui,Show,X0 Y0 W%A_ScreenWidth% H%A_ScreenHeight%,GhosterWindow
WinSet,Transparent,%transparency%,GhosterWindow


LOOP:
Sleep,50
WinGet,winid,ID,A
If winid<>%oldid%
{
  WinGet,wintop,ExStyle,ahk_id %winid%
  wintop:=wintop & 0x8
  If oldtop
    WinSet,AlwaysOnTop,On,ahk_id %oldid%
  Else
    WinSet,AlwaysOnTop,Off,ahk_id %oldid%
  If !showontop
    WinSet,Top,,GhosterWindow
  WinGetClass,winclass,ahk_id %winid%
  If showdesktop
    If winclass=Progman 
      WinHide,GhosterWindow
    Else
      WinShow,GhosterWindow
  WinSet,Top,,ahk_id %winid%
  If jump
    WinSet,AlwaysOnTop,On,ahk_id %winid%
  oldid=%winid%
  oldtop=%wintop%
}
MouseGetPos,x,y
SetEnv,x1,%x%
SetEnv,y1,%y%
EnvAdd,x1,1
EnvAdd,y1,1
EnvSub,x,1
EnvSub,y,1
WinSet,Region,0-0 %A_ScreenWidth%-0 %A_ScreenWidth%-%A_ScreenHeight% 0-%A_ScreenHeight% 0-0 %x%-%y% %x1%-%y% %x1%-%y1% %x%-%y1% %x%-%y%,GhosterWindow
Goto,LOOP


ABOUT:
Gosub,DESTROY
about=Ghoster shows a transparent image across the screen and dims inactive windows.
about=%about%`n
about=%about%`nChange the image and other settings by editing the Ghoster.ini-file.
about=%about%`n
about=%about%`nSkrommel @2005    http://www.donationcoders.com/skrommel
MsgBox,0,Ghoster,%about%
about=
Goto,START
Return


READINI:
IfNotExist,Ghoster.ini 
{
ini=;Ghoster.ini
ini=%ini%`n`;backcolor=000000-FFFFFF or leave blank to speed up screen redraw.
ini=%ini%`n`;image=                     Path to image or leave blank to speed up screen redraw.
ini=%ini%`n`;x=any number or blank      Moves the image to the right.
ini=%ini%`n`;y=any number or blank      Moves the image down.
ini=%ini%`n`;width=any number or blank  Makes the image wider.
ini=%ini%`n`;height=any number or blank Makes the image taller.
ini=%ini%`n`;stretchwidth=1 or 0        Makes the image fill the width of the screen.
ini=%ini%`n`;stretchheight=1 or 0       Makes the image fill the height of the screen.
ini=%ini%`n`;keepaspect=1               Keeps the image from distorting.
ini=%ini%`n`;transparency=0-255         Makes the ghosting more or less translucent.
ini=%ini%`n`;jump=1 or 0                Makes the active window show through the ghosting.
ini=%ini%`n`;showdesktop=1 or 0         Removes the ghosting when the desktop is active.
ini=%ini%`n`;showontop=1 or 0           Removes ghosting from ontop windows like the taskbar.
ini=%ini%`n`;multimon=1 or 0            Dim all monitors in a multimonitor system
ini=%ini%`n
ini=%ini%`n[Settings]
ini=%ini%`nbackcolor=000000
ini=%ini%`nimage=C:\Windows\Bubbles.bmp
ini=%ini%`nx=
ini=%ini%`ny=
ini=%ini%`nwidth=
ini=%ini%`nheight=
ini=%ini%`nstretchwidth=1
ini=%ini%`nstretchheight=1
ini=%ini%`nkeepaspect=1
ini=%ini%`ntransparency=150
ini=%ini%`njump=1
ini=%ini%`nshowdesktop=1
ini=%ini%`nshowontop=0
ini=%ini%`nmultimon=1
ini=%ini%`n
FileAppend,%ini%,Ghoster.ini
ini=
}
IniRead,backcolor,Ghoster.ini,Settings,backcolor
IniRead,image,Ghoster.ini,Settings,image
IniRead,x,Ghoster.ini,Settings,x
IniRead,y,Ghoster.ini,Settings,y

IniRead,width,Ghoster.ini,Settings,width
IniRead,height,Ghoster.ini,Settings,height
IniRead,stretchwidth,Ghoster.ini,Settings,stretchwidth
IniRead,stretchheight,Ghoster.ini,Settings,stretchheight
IniRead,keepaspect,Ghoster.ini,Settings,keepaspect
IniRead,transparency,Ghoster.ini,Settings,transparency
IniRead,jump,Ghoster.ini,Settings,jump
IniRead,showdesktop,Ghoster.ini,Settings,showdesktop
IniRead,showontop,Ghoster.ini,Settings,showontop
IniRead,multimon,Ghoster.ini,Settings,multimon
Return


TRAYMENU:
Menu,Tray,NoStandard
Menu,Tray,DeleteAll
Menu,Tray,Add,Ghoster,ABOUT
Menu,Tray,Add,
Menu,Tray,Add,&Settings,SETTINGS
Menu,Tray,Add,&About,ABOUT
Menu,Tray,Add,&Restart,RESTART
Menu,Tray,Add,E&xit,QUIT
Menu,Tray,Default,Ghoster
Return


SETTINGS:
Run,Ghoster.ini
Return


RESTART:
Gosub,DESTROY
Goto,START


DESTROY:
If oldtop
  WinSet,AlwaysOnTop,On,ahk_id %oldid%
Else
  WinSet,AlwaysOnTop,Off,ahk_id %oldid%
Gui,Destroy
Return


QUIT:
WinActivate,ahk_class Shell_TrayWnd
WinWaitActive,ahk_class Shell_TrayWnd,,1
Gosub,DESTROY
WinActivate,ahk_id %oldid%
ExitApp 


corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004
Nice effect :) .

SetBatchLines, -1


skrommel
  • Members
  • 193 posts
  • Last active: Jun 07 2010 08:30 AM
  • Joined: 30 Jul 2004
:D I've updated the Ghoster script at the top to use an ini-file.

Skrommel

Norbert
  • Guests
  • Last active:
  • Joined: --
Perfect effect! I'm using it when watching movies to dim the second of my monitors. However it consumes a lot of CPU (55% of a top level one).

skrommel
  • Members
  • 193 posts
  • Last active: Jun 07 2010 08:30 AM
  • Joined: 30 Jul 2004
:D Try the latest version from my home page at http://www.donationcoders.com/skrommel

Skrommel

fisheromen1031
  • Members
  • 3 posts
  • Last active: Mar 11 2006 08:42 AM
  • Joined: 31 Jan 2006
I tried this out and it is pretty cool, but I have trouble clicking on things when I move my mouse around quickly. The click through region doesn't follow my pointer. Is there anything that could be done about this?

Also, why does it use up so much CPU?

fisheromen1031
  • Members
  • 3 posts
  • Last active: Mar 11 2006 08:42 AM
  • Joined: 31 Jan 2006
I just had an idea for making background image come through all windows. You could make all windows partially transparent and cut off the overlap of unactive windows with the active window so as to not break up the image with the overlap. That seems like it accomplishes the same effect as Ghoster and doesn't require the mouse click-through.

skrommel
  • Members
  • 193 posts
  • Last active: Jun 07 2010 08:30 AM
  • Joined: 30 Jul 2004
:) Speed is a problem. You could try enlarging the hole around the cursor, but it wouldn't look so pretty. A mouse hook could solve the problem, too.

You wrote:

...cut off the overlap of unactive windows with the active window...


Please explain, I didn't understand...

Skrommel

  • Guests
  • Last active:
  • Joined: --
when windows are made transparent, you can see the windows behind them. So the overlapping portions of those windows can make it difficult to read the top active window. If the portions of the underlying windows that overlap with the active, topmost window could be cut off then it would look like there is an image overlay. This is assuming you have the desired image set as your desktop background. I noticed on your '1 hour software' page that you have a script that does the cutting off, so it seems doable.

I hope that made more sense

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Mmm, obviously JSLover didn't saw this ;-)
Suggestion: put the INI code in continuation section: you won't need to type `n, it would be more readable, easier to change, and the message would be much less wide, avoiding to scroll the browser window.
Idem for MsgBox, althought it has spaces. Can't do much for WinSet, can we?

You can also put the initial content of the ini file in a separate code section, up to the users to create a second file. But your solution allows to simply delete the ini file to get back the initial settings.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012

Mmm, obviously JSLover didn't saw this ;-)

Hell yeah, you might want to break up your long lines skrommel.

I love this script, but unfortunately it takes up a lot of CPU (~ 40%). I haven't studied the code but I noticed a loop, perhaps a workaround in a SetTimer would be more efficient?

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


JSLover
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004

Mmm, obviously JSLover didn't saw this ;-)

...(note: better English is "didn't see this")...lol...I did, but I didn't figure I'd need to come in here much...so I left it...ok...you asked for it...

:evil: WAR ON HORIZ SCROLLING!!! :evil:
Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?

skrommel
  • Members
  • 193 posts
  • Last active: Jun 07 2010 08:30 AM
  • Joined: 30 Jul 2004
:) The script on top was a bit old, so I changed it for the latest version from http://www.donationcoders.com/skrommel.

I seem to remember the speed was better, too.

Skrommel

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
:shock: You don't like continuation sections, don't you? :)
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

skrommel
  • Members
  • 193 posts
  • Last active: Jun 07 2010 08:30 AM
  • Joined: 30 Jul 2004
:) @Guest:

Putting the image in the background and clipping and making all windows transparent is doable, but I think it would be slower, and very much so when moving a windows around. You can try DimInactive at http://www.autohotke...opic.php?t=4510 to see the response when clipping around just one moving window.

I think a better alternative would be to catch the mouse clicks and send them through, as it is the hole punching that hogs the CPU.

Skrommel