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)
|
Originally Posted by: soooulp Originally Posted by: Rob Okay, this is a complicated setup, but it can be done. I also have not done a lot of testing, so it might have problems. When it is all setup, you would hold down the stroke button and scroll the mouse wheel up or down, release to reset things for the next time.
First, Ensure This Option is Enabled:Next, enable your load script and put this script line:Next, enable your Release script and put this script line:Code:sp.DeleteTimer("clearLastWindow");
Now, create your actions:Scroll Up (starts from bottom of windows and moves up)Code://Get the last window index used by these scripts
var lastWindowIndex = sp.GetStoredNumber("lastWindowIndex");
//If there is none, if the window list is empty, or if we're at the top of the
//stack then reset everything
if(lastWindowIndex == 0 || !allWindowsList) {
allWindowsList = sp.AllApplications();
//Set the window index to be the last window in the stack
//Note this is technically out of bounds, but the decrement below
//will bring it back to the last item
lastWindowIndex = allWindowsList.Length ;
}
if(allWindowsList && allWindowsList.Length > 0) {
//Decrement the window list to get the previous window
lastWindowIndex--;
//Activate the window
allWindowsList[lastWindowIndex].Activate();
//store the last window so the scripts know where we are in the stack
sp.StoreNumber("lastWindowIndex", lastWindowIndex);
//clear the previous timer, if it exists
sp.DeleteTimer("clearLastWindow");
//Create a timer that will reset the window after 2 seconds (2000 milliseconds)
//This ensures that if you do not scroll the wheel within 2 seconds, it resets
//the window list and order, this is to prevent getting stuck in certain
//situations
sp.CreateTimer("clearLastWindow", 2000, -1, String.raw`sp.StoreNumber("lastWindowIndex", 0);`);
}
Scroll down scriptCode://Get the last window index used by these scripts
var lastWindowIndex = sp.GetStoredNumber("lastWindowIndex");
//If there is none, if the window list is empty, or if we're at the top of the
//stack then reset everything
if(lastWindowIndex == 0 || !allWindowsList) {
lastWindowIndex = 0;
allWindowsList = sp.AllApplications();
}
if(allWindowsList && allWindowsList.Length > 0) {
//Increment the window list to get the previous window
lastWindowIndex++;
//If we are at the bottom of the window stack, set to 0
//so it is back at the top of the window stack
if(lastWindowIndex > allWindowsList.Length - 1) {
lastWindowIndex = 0;
}
//Activate the window
allWindowsList[lastWindowIndex].Activate();
//store the last window so the scripts know where we are in the stack
sp.StoreNumber("lastWindowIndex", lastWindowIndex);
//clear the previous timer, if it exists
sp.DeleteTimer("clearLastWindow");
//Create a timer that will reset the window after 2 seconds (2000 milliseconds)
//This ensures that if you do not scroll the wheel within 2 seconds, it resets
//the window list and order, this is to prevent getting stuck in certain
//situations
sp.CreateTimer("clearLastWindow", 2000, -1, String.raw`sp.StoreNumber("lastWindowIndex", 0);`);
}
(Note: Script in screenshot below doesn't match after edit, use script above)
Dear Rob, It is me again, I tested this Alt+Tab similar function just now. There is a problem that it can not change to the Telegram desktop window. If I press Alt+Tab fast, it only changes the window between two programs. I use the script in above, it can change the windows among the many programs, as a change to Chrome, to StrokePlusnet setting, to my fold, but except change to the Telegram desktop window. Why it can not do this? A temporary way to substitute the Alt+Tab script Code:
if(wheel.Delta > 0) {
//If Alt is down
try {
if(sp.GetStoredBool("AltDown")) {
sp.SendVKeyDown(vk.SHIFT);
sp.Sleep(50);
sp.SendVKeyDown(vk.TAB);
sp.Sleep(50);
sp.SendVKeyUp(vk.TAB);
sp.Sleep(50);
sp.SendVKeyUp(vk.SHIFT);
} else {
//First stroll, send Alt down
sp.StoreBool("AltDown", true);
sp.SendAltDown();
sp.Sleep(50);
sp.SendVKeyDown(vk.SHIFT);
sp.Sleep(50);
sp.SendVKeyDown(vk.TAB);
sp.Sleep(50);
sp.SendVKeyUp(vk.TAB);
sp.Sleep(50);
sp.SendVKeyUp(vk.SHIFT);
}
sp.CreateTimer("TimerAltDown", 800, 0, `sp.SendAltUp(); sp.DeleteTimer("TimerAltDown");`);
sp.DeleteStoredBool("AltDown");
} catch {}
} else {
//If Alt is down
try {
if(sp.GetStoredBool("AltDown")) {
sp.SendVKeyDown(vk.TAB);
sp.Sleep(50);
sp.SendVKeyUp(vk.TAB);
} else {
//First stroll, send Alt down
sp.StoreBool("AltDown", true);
sp.SendAltDown();
sp.Sleep(50);
sp.SendVKeyDown(vk.TAB);
sp.Sleep(50);
sp.SendVKeyUp(vk.TAB);
}
sp.CreateTimer("TimerAltDown", 800, 0, `sp.SendAltUp(); sp.DeleteTimer("TimerAltDown");`);
sp.DeleteStoredBool("AltDown");
} catch {}
}
|