Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 161 Thanks: 46 times Was thanked: 23 time(s) in 17 post(s)
|
Refer to this program See Through Windows, which uses hotkey to make the foreground Window transparency. And it also can let the mouse "Click-Through and keep the Window on top of all other Windows", which is interesting. Based on this post, I improve Window Transparency with the Click-Through function. It will do the same thing as the program, but the Window is where the mouse is, also it will recover the Window and the mouse when doing the action again. The insufficiency is that it can only set one Window transparency to 50% with the mouse Click Trough once and then recover it. It has been rewritten by Rob in 2#Put the first code into Global Actions-Load/UnloadCode:if(!NativeModules.User32)
{
var IntPtrT = host.typeOf(clr.System.IntPtr);
var Int32T = host.typeOf(clr.System.Int32);
var user32TB = sp.NativeModule().DefineType("User32", "Class,Public,SequentialLayout,Serializable");
user32TB.DefinePInvokeMethod("GetWindowLong",
"user32.dll",
[IntPtrT,Int32T],
Int32T,
"PreserveSig");
user32TB.DefinePInvokeMethod("SetWindowLong",
"user32.dll",
[IntPtrT,Int32T,Int32T],
Int32T,
"PreserveSig");
user32TB.Create();
}
Action script Code:var WS_EX_LAYERED = 0x80000;
var WS_EX_TRANSPARENT = 0x20;
var GWL_EXSTYLE = (-20);
if(sp.GetStoredObject('WinTrans').Alpha == 128){
var hWnds = sp.GetStoredObject('WinTrans').HWnd;
sp.GetStoredObject('WinTrans').Alpha = 255; //Remove transparency
sp.GetStoredObject('WinTrans').TopMost = false;
//Which will disable the Preview Pciture Window activate
/*if(sp.GetStoredObject('WinTrans').ClassName != 'WindowsForms10.Window.8.app.0.13965fa_r6_ad1') {
sp.GetStoredObject('WinTrans').Activate();
}*/
NativeModules.User32.SetWindowLong(hWnds ,GWL_EXSTYLE, NativeModules.User32.GetWindowLong(hWnds, GWL_EXSTYLE) & (~WS_EX_TRANSPARENT));
sp.DeleteStoredObject('WinTrans');
} else {
var wnd = sp.WindowFromPoint(sp.GetCurrentMousePoint(), true);
var hWnd = wnd.HWnd;
wnd.Alpha = 128; //Make 50% transparent
wnd.TopMost = true;
sp.StoreObject('WinTrans', wnd);
NativeModules.User32.GetWindowLong(hWnd, GWL_EXSTYLE);
NativeModules.User32.SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TRANSPARENT | WS_EX_LAYERED);
}
Edited by user Sunday, March 6, 2022 7:25:47 AM(UTC)
| Reason: Not specified
|