AutoHotkey Community

It is currently May 27th, 2012, 1:39 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: July 19th, 2005, 4:40 am 
Offline

Joined: July 30th, 2004, 8:50 pm
Posts: 192
: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.autohotkey.com/forum/viewtopic.php?t=4510.

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

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

Skrommel


Code:
;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


Last edited by skrommel on February 23rd, 2006, 6:35 pm, edited 5 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 19th, 2005, 5:26 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
Nice effect :) .

Code:
SetBatchLines, -1


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Update
PostPosted: July 20th, 2005, 11:58 am 
Offline

Joined: July 30th, 2004, 8:50 pm
Posts: 192
:D I've updated the Ghoster script at the top to use an ini-file.

Skrommel


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Eats CPU
PostPosted: January 24th, 2006, 12:32 am 
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).


Report this post
Top
  
Reply with quote  
 Post subject: Look at my home page
PostPosted: January 24th, 2006, 10:40 pm 
Offline

Joined: July 30th, 2004, 8:50 pm
Posts: 192
:D Try the latest version from my home page at http://www.donationcoders.com/skrommel

Skrommel


Report this post
Top
 Profile  
Reply with quote  
 Post subject: click through problems
PostPosted: February 22nd, 2006, 8:03 pm 
Offline

Joined: January 31st, 2006, 8:14 am
Posts: 3
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: an idea
PostPosted: February 22nd, 2006, 8:14 pm 
Offline

Joined: January 31st, 2006, 8:14 am
Posts: 3
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Please explain
PostPosted: February 22nd, 2006, 11:41 pm 
Offline

Joined: July 30th, 2004, 8:50 pm
Posts: 192
:) 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:
Quote:
...cut off the overlap of unactive windows with the active window...


Please explain, I didn't understand...

Skrommel


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2006, 12:05 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2006, 10:45 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2006, 11:32 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
PhiLho wrote:
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?

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2006, 12:19 pm 
Offline
User avatar

Joined: December 20th, 2004, 12:19 pm
Posts: 798
Location: LooseChange911.com Ask Questions, Demand Answers █ The WTC bldgs █ shouldn't have fallen █ that fast
PhiLho wrote:
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:

_________________
AutoHotkey-Hotstring.ahk - Helping the world spell "AutoHotkey" correctly! (btw, it's a lowercase k!)


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Old script
PostPosted: February 23rd, 2006, 12:35 pm 
Offline

Joined: July 30th, 2004, 8:50 pm
Posts: 192
:) 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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2006, 4:03 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
:shock: You don't like continuation sections, don't you? :)

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject: All tansparent
PostPosted: February 25th, 2006, 10:05 pm 
Offline

Joined: July 30th, 2004, 8:50 pm
Posts: 192
:) @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.autohotkey.com/forum/viewtopic.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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group