 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
deletarus
Joined: 08 Dec 2007 Posts: 9
|
Posted: Sat Dec 08, 2007 8:58 pm Post subject: Never in focus window (or click throughable) |
|
|
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 |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6307 Location: Pacific Northwest, US
|
|
| Back to top |
|
 |
deletarus
Joined: 08 Dec 2007 Posts: 9
|
Posted: Sat Dec 08, 2007 10:00 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6307 Location: Pacific Northwest, US
|
Posted: Sat Dec 08, 2007 10:41 pm Post subject: |
|
|
that window never gets focus. you can also poke a hole in your gui using winset, region so the mouseclick goes through. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
deletarus
Joined: 08 Dec 2007 Posts: 9
|
Posted: Sat Dec 08, 2007 11:33 pm Post subject: |
|
|
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
| Code: |
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 |
|
| Back to top |
|
 |
deletarus
Joined: 08 Dec 2007 Posts: 9
|
Posted: Sun Dec 09, 2007 12:53 am Post subject: |
|
|
http://www.codeproject.com/KB/vb/ClickThroughWindows.aspx?df=100&forumid=262268&exp=0&select=1354593
| Quote: |
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. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5574
|
Posted: Sun Dec 09, 2007 1:27 am Post subject: |
|
|
| deletarus wrote: | | 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:
| Code: | 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 ) |
 |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5574
|
Posted: Sun Dec 09, 2007 1:36 am Post subject: |
|
|
My head is being flooded with ideas! Thanks for that link deletarus!  |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 3941 Location: Pittsburgh
|
Posted: Sun Dec 09, 2007 1:42 am Post subject: |
|
|
A similar solution was posted here: | Code: | 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% |
|
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5574
|
Posted: Sun Dec 09, 2007 1:52 am Post subject: |
|
|
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.  |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5574
|
Posted: Sun Dec 09, 2007 3:17 am Post subject: |
|
|
Totally unobtrusive:
| Code: | 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% HIDE NA
WinSet Transparent, 150, ahk_id %Gui1% |
Edit1: That 0x30 is SPI_GETWORKAREA |
|
| Back to top |
|
 |
deletarus
Joined: 08 Dec 2007 Posts: 9
|
Posted: Thu Dec 13, 2007 12:11 am Post subject: |
|
|
Well, it looks like we got that one figured out.
Thanks a lot to all who contributed, and happy coding. |
|
| Back to top |
|
 |
Leon
Joined: 27 Aug 2007 Posts: 179
|
Posted: Fri Apr 25, 2008 8:46 pm Post subject: |
|
|
I replaced the Gui Show line form Skan's first code to use this,
| Code: | | 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
| Code: | SysGet, Mon1, Monitor, 1
MsgBox, %Mon1Right% %Mon1Bottom%
MsgBox, %A_ScreenWidth% %A_ScreenHeight%
ExitApp
|
|
|
| Back to top |
|
 |
Micahs
Joined: 01 Dec 2006 Posts: 328
|
Posted: Fri May 02, 2008 8:16 am Post subject: |
|
|
This covers my entire screen.
| Code: | 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
|
_________________
 |
|
| Back to top |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 224
|
Posted: Sun May 04, 2008 9:27 pm Post subject: |
|
|
what a kickass trick
here's mine a screen dimmer
Ctrl + NumpadSub for dim
Ctrl + NumpadAdd for undim
| Code: | 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 |
_________________ Consider a Donation to AutoHotkey & let's support Wiki & Join IRC |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|