Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,349 Location: Tampa, FL Thanks: 28 times Was thanked: 416 time(s) in 354 post(s)
|
For the mouse swap, use these. Global Actions > Load/Unload > Load (script) Code:if(!NativeModules.MouseSwap)
{
var Int32T = host.typeOf(clr.System.Int32);
var BooleanT = host.typeOf(clr.System.Boolean);
var mouseSwapTB = sp.NativeModule().DefineType(
"MouseSwap",
"Class,Public,SequentialLayout,Serializable"
);
mouseSwapTB.DefinePInvokeMethod(
"SystemParametersInfo",
"user32.dll",
[Int32T,Int32T,Int32T,Int32T],
Int32T,
"PreserveSig"
);
mouseSwapTB.Create();
}
function SwapMouseButtons() {
var SM_SWAPBUTTON = 23;
var SPIF_SENDCHANGE = 0x0002;
var SPI_SETMOUSEBUTTONSWAP =0x0021;
var mouseSwapped = sp.GetSystemMetricsByIndex(SM_SWAPBUTTON);
NativeModules.MouseSwap.SystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, mouseSwapped ? 0 : 1, 0, SPIF_SENDCHANGE);
}
function MouseClick(pt, btn, down, up) {
var SM_SWAPBUTTON = 23;
var mouseSwapped = sp.GetSystemMetricsByIndex(SM_SWAPBUTTON);
if(mouseSwapped) {
if(btn === MouseButtons.Left) {
btn = MouseButtons.Right;
} else if(btn === MouseButtons.Right) {
btn = MouseButtons.Left;
}
}
sp.MouseClick(pt, btn, down, up);
}
Instead of your script to swap mouse buttons, just call this function instead (defined above) - this swaps buttons without having to open the mouse settings window. Then instead of sp.MouseClick just use MouseClick (function defined above) which has the logic of checking the state of the swapped mouse buttons and converts automatically. Code:sp.Sleep(100);
MouseClick(action.Start, MouseButtons.Right, true, true); // <-- Notice: no "sp." just MouseClick
sp.Sleep(50);
sp.SendKeys("t");
Edited by user Thursday, April 29, 2021 5:30:18 PM(UTC)
| Reason: Not specified
|