Clickthrough overlay
Posted: Sat Apr 28, 2018 4:28 pm
Has anyone actually managed to create a clickthrough overlay yet?
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
OpenWindow(0, 0, 0, 320, 200, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
TextGadget(0, 10, 10, 300, 30, "depends...")
SetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE, GetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE)|#WS_EX_LAYERED|#WS_EX_TRANSPARENT)
SetLayeredWindowAttributes_(WindowID(0), 0, 150, #LWA_ALPHA)
StickyWindow(0, 1)
While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
Using another window as overlay only works as long as your program is not a fullscreen game (DirectX, OpenGL, ...)k10k10 wrote:I am basically talking about something that you can use as a fullscreen overlay
Code: Select all
InitSprite()
OpenWindow(0, 10, 10, 200, 200, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered | #PB_Window_BorderLess | #PB_Window_Tool)
OpenWindowedScreen(WindowID(0), 0, 0, 200, 200)
SetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE, GetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE)|#WS_EX_LAYERED|#WS_EX_TRANSPARENT)
SetLayeredWindowAttributes_(WindowID(0), 0, 55, #LWA_ALPHA)
StickyWindow(0, 1)
While WaitWindowEvent() <> #PB_Event_CloseWindow
StartDrawing(WindowOutput(0))
Circle(100, 100, 5, RGB(0, 255, 0))
StopDrawing()
Wend
not reallyk10k10 wrote:Could you provide a little example?
UpdateLayeredWindow wont work with PB's sprite engine. You have to create a 32bit image (rgba(0,0,0,0)) and draw on it (needs premultiplied alpha) and send it to UpdateLayeredWindow to render the window... Not as simple to code as it soundsk10k10 wrote:The main problem I would have with this code is, that I can not make the window itself fully transparent, without also making the things drawn on it transparent!