窗口透明(鼠标可点击)
执行后鼠标所在窗口透明,且置顶,鼠标可点击后方窗口,再次执行后恢复
不足之处,只能一次设置一个窗口透明以及鼠标穿透,然后恢复,不设置鼠标穿透,可以同时设置多个窗口透明
参照 See Through Windows – 透过窗口看窗口 (当前该软件功能正常)
if(sp.GetStoredObject('WinTrans').Alpha == 128){
var transWnd = sp.GetStoredObject('WinTrans');
//StrokesPlus.Console.Log(transWnd.ExtendedStyle);
transWnd.Alpha = 255; //Remove transparency
transWnd.TopMost = false;
// Can't seem to find a way to negate a flag using the
// ClearScript host.flags call directly, so casting the values to uint,
// performing bitwise operation, then casting back to enum type
transWnd.ExtendedStyle = host.cast(WindowExStyleFlags,
host.cast(System.UInt32,
transWnd.ExtendedStyle)
&
~host.cast(System.UInt32,
WindowExStyleFlags.TRANSPARENT)
);
//StrokesPlus.Console.Log(transWnd.ExtendedStyle);
sp.DeleteStoredObject('WinTrans');
} else {
var mouseWnd = sp.WindowFromPoint(sp.GetCurrentMousePoint(), true);
//StrokesPlus.Console.Log(mouseWnd.ExtendedStyle);
mouseWnd.Alpha = 128; //Make 50% transparent
mouseWnd.TopMost = true;
mouseWnd.ExtendedStyle = host.flags(mouseWnd.ExtendedStyle,
WindowExStyleFlags.TRANSPARENT);
//StrokesPlus.Console.Log(mouseWnd.ExtendedStyle);
sp.StoreObject('WinTrans', mouseWnd);
}
以下失效待修复(功能效果一样)
以下失效待修复(功能效果一样)
以下失效待修复(功能效果一样)
添加到全局动作-启动/退出-启动(开启)
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();
}
执行动作
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 hWnd = sp.WindowFromPoint(sp.GetCurrentMousePoint(), true).HWnd;
sp.WindowFromPoint(sp.GetCurrentMousePoint(), true).Alpha = 128; //Make 50% transparent
sp.WindowFromPoint(sp.GetCurrentMousePoint(), true).TopMost = true;
sp.StoreObject('WinTrans', sp.WindowFromPoint(sp.GetCurrentMousePoint(), true));
NativeModules.User32.GetWindowLong(hWnd, GWL_EXSTYLE);
NativeModules.User32.SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TRANSPARENT | WS_EX_LAYERED);
}