AutoHotkey Community

It is currently May 26th, 2012, 3:48 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: December 8th, 2007, 8:58 pm 
Offline

Joined: December 8th, 2007, 8:52 pm
Posts: 9
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2007, 9:22 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
The following show some techniques
http://www.autohotkey.com/forum/viewtopic.php?t=18378

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2007, 10:00 pm 
Offline

Joined: December 8th, 2007, 8:52 pm
Posts: 9
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2007, 10:41 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
that window never gets focus. you can also poke a hole in your gui using winset, region so the mouseclick goes through.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2007, 11:33 pm 
Offline

Joined: December 8th, 2007, 8:52 pm
Posts: 9
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2007, 12:53 am 
Offline

Joined: December 8th, 2007, 8:52 pm
Posts: 9
http://www.codeproject.com/KB/vb/ClickT ... ct=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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2007, 1:27 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
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 )


:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2007, 1:36 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
:shock: :o

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2007, 1:42 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2007, 1:52 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
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. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2007, 3:17 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2007, 12:11 am 
Offline

Joined: December 8th, 2007, 8:52 pm
Posts: 9
Well, it looks like we got that one figured out.

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2008, 8:46 pm 
Offline

Joined: August 27th, 2007, 8:00 pm
Posts: 179
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 2nd, 2008, 8:16 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
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

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2008, 9:27 pm 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
what a kickass trick
here's mine a screen dimmer :lol:

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

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


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO and 22 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