Jump to content


Photo

Ghoster: Put a transparent image across your screen


  • Please log in to reply
27 replies to this topic

#1 skrommel

skrommel
  • Members
  • 193 posts

Posted 19 July 2005 - 03:40 AM

: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 


#2 corrupt

corrupt
  • Members
  • 2558 posts

Posted 19 July 2005 - 04:26 AM

Nice effect :) .

SetBatchLines, -1


#3 skrommel

skrommel
  • Members
  • 193 posts

Posted 20 July 2005 - 10:58 AM

:D I've updated the Ghoster script at the top to use an ini-file.

Skrommel

#4 Norbert

Norbert
  • Guests

Posted 23 January 2006 - 11:32 PM

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

#5 skrommel

skrommel
  • Members
  • 193 posts

Posted 24 January 2006 - 09:40 PM

:D Try the latest version from my home page at http://www.donationcoders.com/skrommel

Skrommel

#6 fisheromen1031

fisheromen1031
  • Members
  • 3 posts

Posted 22 February 2006 - 07:03 PM

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?

#7 fisheromen1031

fisheromen1031
  • Members
  • 3 posts

Posted 22 February 2006 - 07:14 PM

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.

#8 skrommel

skrommel
  • Members
  • 193 posts

Posted 22 February 2006 - 10:41 PM

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

#9 Guests

  • Guests

Posted 22 February 2006 - 11:05 PM

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

#10 PhiLho

PhiLho
  • Fellows
  • 6850 posts

Posted 23 February 2006 - 09:45 AM

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.

#11 polyethene

polyethene

    Administrator

  • Administrators
  • 5473 posts

Posted 23 February 2006 - 10:32 AM

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?

#12 JSLover

JSLover
  • Members
  • 920 posts

Posted 23 February 2006 - 11:19 AM

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:

#13 skrommel

skrommel
  • Members
  • 193 posts

Posted 23 February 2006 - 11:35 AM

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

#14 PhiLho

PhiLho
  • Fellows
  • 6850 posts

Posted 23 February 2006 - 03:03 PM

:shock: You don't like continuation sections, don't you? :)

#15 skrommel

skrommel
  • Members
  • 193 posts

Posted 25 February 2006 - 09:05 PM

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