Jump to content

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

Never in focus window (or click throughable)


  • Please log in to reply
26 replies to this topic
deletarus
  • Members
  • 9 posts
  • Last active: Dec 13 2007 10:05 AM
  • Joined: 08 Dec 2007
I'm trying to write a script that will allow a window to be "click throughable" That is, it will be a transparent window (right now it is a autoHotkey GUI) that when it receives a mouse click it will pass that click (or any other event) to the window beneath it or the desktop.

One simple way I can think to do it is to just make the window never have focus, if this is possible please let me know, I have searched the forums, but not found the answer.

any help would be appreciated

-thanks

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
The following show some techniques
<!-- m -->http://www.autohotke...pic.php?t=18378<!-- m -->

deletarus
  • Members
  • 9 posts
  • Last active: Dec 13 2007 10:05 AM
  • Joined: 08 Dec 2007
That may have something I can use. I'll try and make it work.

From what I can gather, I may be able to pass through the clicks using this

If anyone has a way to just force a window to never have focus, (or if I'm missing something in this example) let me know, it would be much appreciated.

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
that window never gets focus. you can also poke a hole in your gui using winset, region so the mouseclick goes through.

deletarus
  • Members
  • 9 posts
  • Last active: Dec 13 2007 10:05 AM
  • Joined: 08 Dec 2007
That keyboard does get focus when you click on it though, and the winset, region looks like it will "poke a hole" in the window. What I'm looking for is a way to essentially overly a pic or text on the screen transparently that won't affect anything else.

For example you could have a full screen transparent image over your entire desktop that you can see, but not interact with. Essentially Always on top, but you can't click on it or anything, everything just goes through it.

Thanks a lot for your suggestions and prompt replies.

So far I'm using

CustomColor = EEAA99  ; Can be any RGB color (it will be made transparent below).
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
Gui, Color, %CustomColor%
Gui, Add, Picture, width height, Picture  
WinSet, TransColor, %CustomColor% 150
Gui, Show, x0 y0 NoActivate  ; NoActivate avoids deactivating the currently active window.
return

[Edit]
you're right, it doesn't gain focus unless you left click on it
[Edit again]
That script does seem to have everything I need, I'm just having some trouble extracting it and converting it for my needs

deletarus
  • Members
  • 9 posts
  • Last active: Dec 13 2007 10:05 AM
  • Joined: 08 Dec 2007
<!-- m -->http://www.codeproje... ... ct=1354593<!-- m -->


Truth be told, this trick is ridiculously easy to pull off. To make a form "click-through", all you need to do is:

1. Grab the current value of the Extended Style attributes for the window you want to be invisible to the mouse. This requires a call to the Win32 API function GetWindowLong(hWnd, nIndex). The two parameters are as follows:
* hWnd - The handle to the window we want to get the attributes for
* nIndex - The zero-based offset to the value to be retrieved. In our case, GWL_EXSTYLE, or -20
2. Modify the value returned by GetWindowLong() and turn on the bits you want. This is done using a bit-wise OR operation. We want to turn on the bits specified by WS_EX_LAYERED and WS_EX_TRANSPARENT.

newValue = oldValue Or WS_EX_LAYERED Or WS_EX_TRANSPARENT

3. Write the new value back to the window by calling SetWindowLong(hWnd, nIndex, dwNewLong). The first two are exactly the same as the call to GetWindowLong(). The third is, obviously, the new value we want written to the window.
4. Now that the window is a Layered Window, we have to modify another attribute of the form, the Alpha attribute. If this is not done, the default value for Alpha will be 0, or visibly transparent, and we won't see our form at all! This is accomplished with a call to SetLayeredWindowAttributes(hWnd, crKey, bAlpha, dfFlags).
* hWnd - The handle to the window we want to set the attribute for
* crRef - Specifies a transparency color key. All pixels with this color in the form will be transparent
* bAlpha - Specifies the opacity of the window, 0 (transparent) through 255 (opaque)
* dwFlags - Specifies an action to take
* LWA_COLORKEY - Uses crKey as the transparency color
* LWA_ALPHA - Uses bAlpha to determine the opacity of the window



anyone know how I can do this in autohotkey? I don't have any experience with dll calls and such.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

anyone know how I can do this in autohotkey? I don't have any experience with dll calls and such.


No need for DllCall() for that particular code you have linked:

Gui -Caption +AlwaysOnTop +Border +LastFound 
ID := WinExist()
Gui, Add, Text,, This is a Layered Window
Gui, Show, W640 h480
WinSet, ExStyle, +0x80020, ahk_id %ID% ; See Note
WinSet, Transparent, 125, ahk_id %ID%
Return

#End::ExitApp 
; Note: ( WS_EX_LAYERED:=0x00080000 ) Or ( WS_EX_TRANSPARENT:=0x20 )

:)

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
:shock: :O

My head is being flooded with ideas! Thanks for that link deletarus! :)

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
A similar solution was posted here:
Gui Color, 0,0                  ; Black

Gui -Caption +ToolWindow +E0x20 ; No title bar, no taskbar button, Transparent

Gui Show, W200 H200             ; Create a semi-transparent window

WinGet ID, ID, A                ; ...with HWND/handle ID



Winset AlwaysOnTop, ON, ahk_id %ID%     ; Keep it always on the top

WinSet Transparent, 99, ahk_id %ID%


SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Oh my! I was trying it as a style like Gui, +0x20 instead of ExStyle.
For my current project I wanted show a semi-transparent GUI in lieu of a TrayTip. This will make it perfect.

Thanks. :)

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Totally unobtrusive:

VarSetCapacity(W,16),  DllCall( "SystemParametersInfo", UInt,0x30, Int,0, UInt,&W, Int,0)
Gui -Caption +AlwaysOnTop +Border +ToolWindow +E0x20 +LastFound
Gui1:=WinExist(),     GW:=320,  GH:=42,     GX:=NumGet(W,8)-GW-4,  GY:=NumGet(W,12)-GH-4
Gui, Add, Picture, x3 y5 Icon1, %A_AhkPath%
Gui, Font, s18 Bold, Tahoma
Gui, Add, Text, x+5 w270 h32 +0x201 c404040, AutoHotkey Rocks !!!
Gui, Show, x%GX% y%GY% w%GW% h%GH% [color=red]HIDE NA [/color]  
WinSet Transparent, 150, ahk_id %Gui1%

:)

Edit1: That 0x30 is SPI_GETWORKAREA

deletarus
  • Members
  • 9 posts
  • Last active: Dec 13 2007 10:05 AM
  • Joined: 08 Dec 2007
Well, it looks like we got that one figured out.

Thanks a lot to all who contributed, and happy coding.

Leon
  • Members
  • 179 posts
  • Last active: May 22 2008 02:41 PM
  • Joined: 27 Aug 2007
I replaced the Gui Show line form Skan's first code to use this,
Gui, Show, w%A_ScreenWidth% h%A_ScreenHeight%
in an attempt to cover the whole screen but the lower half of the taskbar is always left uncovered.

I also tried SysGet to get the height including taskbar but got the same result.
Why?

ie. this code shows 2 identical MsgBox results
SysGet, Mon1, Monitor, 1
MsgBox, %Mon1Right% %Mon1Bottom%
MsgBox, %A_ScreenWidth% %A_ScreenHeight%
ExitApp


Micahs
  • Members
  • 463 posts
  • Last active: Mar 01 2013 06:01 AM
  • Joined: 01 Dec 2006
This covers my entire screen.
Gui -Caption +AlwaysOnTop +ToolWindow +E0x20 +LastFound
WinSet Transparent, 100
Gui, Add, Picture, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight% Icon1, %A_AhkPath%
Gui, Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight% NA

Posted Image

heresy
  • Members
  • 291 posts
  • Last active: Sep 26 2008 10:47 PM
  • Joined: 11 Mar 2008
what a kickass trick
here's mine a screen dimmer :lol:

Ctrl + NumpadSub for dim
Ctrl + NumpadAdd for undim

Gui +AlwaysOnTop +ToolWindow +LastFound +E0x20 -Caption
Gui, Color, 0, 0
Gui, Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight% na
id:=winexist()
d:=0
SetFormat,float,0.0
Return

^NumpadAdd:: ;undim
If d!=0
{
  d-=5
  WinSet, Transparent, %d%,ahk_id %id%
  traytip,,% d*100/255 "%"
}
Return

^NumpadSub:: ;dim
If d!=255
{
  d+=5
  WinSet, Transparent, %d%,ahk_id %id%
  traytip,,% d*100/255 "%"
}
Return

Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com