Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mouse Scroll over winow caption but not active
#1
I have a function that will lower (and raise) the transparency when I scroll the mouse wheel when over the window's caption.  I'd like for it to work on the non-active window as well.
How can I do this?

Function Trans_Lower
Trigger #Dh2 0x1     Help - how to add the trigger to the macro
Code:
Copy      Help
dll user32 #GetLayeredWindowAttributes hwnd *crKey !*bAlpha *dwFlags
int col flags; byte alpha
int z
GetLayeredWindowAttributes win &col &alpha &flags
z=18
if alpha=0
,alpha=255
else
,alpha-z
;out "alpha %i" alpha
if alpha<18
,bee "C:\downloads\sounds\system\comp3.wav"
,Transparent(win 25)
,3
,end
Transparent(win alpha)
An old blog on QM coding and automation.

The Macro Hook
#2
just need to grap the windowhandle from the mouse and change win to hwnd so it will work on inactive window as well

Function Trans_Lower
Trigger #Dh2 0x1     Help - how to add the trigger to the macro
Code:
Copy      Help
int hwnd=win(mouse)
int col flags; byte alpha
int z
GetLayeredWindowAttributes hwnd &col &alpha &flags
z=18
if alpha=0
,alpha=255
else
,alpha-z
;out "alpha %i" alpha
if alpha<18
,bee "C:\downloads\sounds\system\comp3.wav"
,Transparent(hwnd 25)
,3
,end
Transparent(hwnd alpha)
#3
dang!  I was just using win(mouse) earlier too!!

thanks.
An old blog on QM coding and automation.

The Macro Hook
#4
SHoot....this seems to only work for some windows (most notably QM).  anyone have an idea as to why?

Function Trans_Lower
Trigger #Dh2 0x1     Help - how to add the trigger to the macro
Code:
Copy      Help
int hwnd=win(mouse)
int col flags
byte alpha
int z
GetLayeredWindowAttributes hwnd &col &alpha &flags
out "alpha %i" alpha
z=18
if alpha=0
,alpha=255
else
,alpha-z
out "alpha %i %i" alpha hwnd
if alpha<24
,Transparent(hwnd 25)
,3
,end
Transparent(hwnd alpha)
An old blog on QM coding and automation.

The Macro Hook
#5
Its because GetLayeredWindowAttributes is for layered windows. On non layered windows the function doesn't work correctly .reports alpha incorrectly.
#6
sorry wasn't at pc when I posted before. This should work as expected.
just need to add a check to see if the window is layered first and if not make it so.
Function Trans_Lower
Trigger #Dh2     Help - how to add the trigger to the macro
Code:
Copy      Help
int hwnd=win(mouse)
int col flags z
byte alpha
int e(GetWindowLong(hwnd GWL_EXSTYLE)) t(e&WS_EX_LAYERED!=0)
if(!t) 
,out "not Layered"
,SetWindowLong(hwnd GWL_EXSTYLE e|WS_EX_LAYERED)
,SetLayeredWindowAttributes(hwnd 0 255 2)
GetLayeredWindowAttributes hwnd &col &alpha &flags
out "alpha %i" alpha
z=15
if alpha=0
,alpha=255
else
,alpha-z
out "alpha %i %i" alpha hwnd
if alpha<15
,Transparent(hwnd 15)
,3
,end
Transparent(hwnd alpha)
#7
I adjusted this version so it will go all the way down and when it gets to 0 will set alpha to 255.

Function Trans_Lower_Mod1
Trigger #Dh2     Help - how to add the trigger to the macro
Code:
Copy      Help
int hwnd=win(mouse)
int col flags
byte alpha
int e(GetWindowLong(hwnd GWL_EXSTYLE)) t(e&WS_EX_LAYERED!=0)
if(!t)
,out "not Layered"
,SetWindowLong(hwnd GWL_EXSTYLE e|WS_EX_LAYERED)
,SetLayeredWindowAttributes(hwnd 0 255 2)
GetLayeredWindowAttributes hwnd &col &alpha &flags
alpha-17
out "alpha %i" alpha
if alpha<17
,alpha=255
,Transparent(hwnd -alpha)
else
,Transparent(hwnd alpha)

Function Trans_Raise_Mod1
Trigger #Uh2     Help - how to add the trigger to the macro
Code:
Copy      Help
int hwnd=win(mouse)
int col flags
byte alpha
int e(GetWindowLong(hwnd GWL_EXSTYLE)) t(e&WS_EX_LAYERED!=0)
if(!t)
,out "not Layered"
,SetWindowLong(hwnd GWL_EXSTYLE e|WS_EX_LAYERED)
,SetLayeredWindowAttributes(hwnd 0 0 2)
GetLayeredWindowAttributes hwnd &col &alpha &flags
alpha+17
if alpha =255
,Transparent(hwnd -alpha)
else
,Transparent(hwnd alpha)
out "alpha %i" alpha    
#8
Fantastic!!!1
works great!  I never even thought you could change the window to into a layered one.
THANKS!!!
An old blog on QM coding and automation.

The Macro Hook


Forum Jump:


Users browsing this thread: 1 Guest(s)