StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
2014218866  
#1 Posted : Monday, May 13, 2019 12:58:18 PM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

Thanks: 19 times
Was thanked: 1 time(s) in 1 post(s)
I'm glad to meet you here.
Everyone knows that "ALT + TAB" is a fast way to switch the currently open window.
But, how to switch different windows by rolling wheel, then open the selected window after loosening. Can you help me? Thank you.
Yuichi  
#2 Posted : Monday, May 13, 2019 4:41:38 PM(UTC)
Yuichi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/13/2018(UTC)
Posts: 54
Poland

Thanks: 18 times
Was thanked: 18 time(s) in 13 post(s)
Maybe this will help you (i use Win key from my old script)

As gesture:
Code:
if (!sp.GetStoredBool("Window_selection")) {
    sp.SendVKeyDown(vk.RWIN); // vk.LMENU (ALT)
    sp.SendVKey(vk.TAB);
    sp.StoreBool("Window_selection", true);
}


this to Left Mouse Button:
Code:
if (sp.GetStoredBool("Window_selection") && !click.Down) {
    sp.SendVKeyUp(vk.RWIN);
    sp.StoreBool("Window_selection", false);
}
thanks 1 user thanked Yuichi for this useful post.
zyxi on 6/2/2019(UTC)
Rob  
#3 Posted : Monday, May 13, 2019 5:10:21 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
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:

First Ensure This Option is Enabled



Next, enable your load script and put this script line:
Code:
var allWindowsList;


Load Action



Next, enable your Release script and put this script line:
Code:
sp.DeleteTimer("clearLastWindow");


Release script



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 up script



Scroll down script
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) {
    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)
Scroll down script

Edited by user Wednesday, May 15, 2019 11:59:06 AM(UTC)  | Reason: Updated Scroll Down script

2014218866  
#4 Posted : Wednesday, May 15, 2019 10:32:46 AM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

Thanks: 19 times
Was thanked: 1 time(s) in 1 post(s)
First of all, thank you very much for your kind response. But there are some problems with the scripts you provide.
This may be the reason for my computer, or other reasons.


For Yuichi' script , my computer has an abnormal phenomenon, such as not being able to copy.

For Rob' script , this gesture shows an error in the Scroll down script. as the picture shows。

down

I still want to implement the software to cycle through the small windows,
and then determine the selected window by releasing the right mouse button.
Although the results are not perfect, thank you very much.


Rob  
#5 Posted : Wednesday, May 15, 2019 11:59:55 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
I edited my post above, updated the Scroll Down script, replace it using the new Scroll Down script and see if it works.
thanks 1 user thanked Rob for this useful post.
2014218866 on 5/16/2019(UTC)
2014218866  
#6 Posted : Thursday, May 16, 2019 9:59:17 AM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

Thanks: 19 times
Was thanked: 1 time(s) in 1 post(s)
This time it has become much easier to use, thank you again for your selfless sharing, Rob
zyxi  
#7 Posted : Sunday, June 2, 2019 2:43:01 AM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

Thanks: 8 times
Was thanked: 1 time(s) in 1 post(s)
Dear Yuichi,

The script you provided is very suitable for me,
but there is a problem when I use the Alt+TAB.
When my mouse is not in the small window range,
clicking the left mouse button will not choose the selected window.

In other words, clicking does not work. Is there any way to solve this problem?


UserPostedImage


I look forward to your reply.

Thank you.
Yuichi  
#8 Posted : Sunday, June 2, 2019 6:32:19 PM(UTC)
Yuichi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/13/2018(UTC)
Posts: 54
Poland

Thanks: 18 times
Was thanked: 18 time(s) in 13 post(s)
Hi
I could do that by getting information which window is in process of selecting and then with that information i can do what i want.
But the problem with the ALT+TAB option is that when the Switch Window is active, it force be at the top and i cannot get that info.
Few days ago i writed code that stick Switch Window to the mouse and move up and down but still needs adjustment because when many windows are running Switch Window can separate windows in more than 1 row.

Second my idea is to parted screen in columns and address the windows to each column, but that in the future.

if you want some of this scripts just tell me.

Edited by user Sunday, June 2, 2019 6:33:56 PM(UTC)  | Reason: Not specified

zyxi  
#9 Posted : Monday, June 3, 2019 4:26:11 AM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

Thanks: 8 times
Was thanked: 1 time(s) in 1 post(s)
Thank you for your reply. At present, my alternative is to move the mouse to the switching window and replace the left mouse button with the wheel click.
It's not a very good alternative. But I'm not very proficient in JavaScript, so I can only expect you to successfully debug this perfect gesture and forgive my rudeness.
Yuichi  
#10 Posted : Monday, June 3, 2019 9:22:13 AM(UTC)
Yuichi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/13/2018(UTC)
Posts: 54
Poland

Thanks: 18 times
Was thanked: 18 time(s) in 13 post(s)
Hi
I try to do that but need a little more time.
zyxi  
#11 Posted : Monday, June 3, 2019 2:49:48 PM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

Thanks: 8 times
Was thanked: 1 time(s) in 1 post(s)

No problem. Take your time. I look forward to your success.

Thank you again.
Rob  
#12 Posted : Monday, June 3, 2019 3:51:19 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Actually, you can do this via a timer in your Global Actions > Load/Unload Scripts > Load Script:

Code:
sp.CreateTimer("ActivateWindow", 0, 200, `if(sp.WindowFromPoint(sp.GetCurrentMousePoint(), true).HWnd != sp.ForegroundWindow().HWnd) {
                                                sp.WindowFromPoint(sp.GetCurrentMousePoint(), true).BringToFront();
                                         }`); 


HOWEVER this script just covers the very basic functionality! Quick testing reveals it would need to be tweaked to better handle certain scenarios.

For example, right click the S+ tray menu and the menu disappears because it's activating the main parent window, etc.

So it would probably need to have some additional logic and checks to function smoothly.

Also, having a script error in this timer function, which executes every 200 milliseconds, can get you stuck in an endless loop of script error popup messages.

If that happens, go to Task Manager and kill StrokesPlus.net.exe. Then hold the Control key and start S+. This will start S+ in Safe Mode which prevents pretty much everything from working. But you can then go into the Load Script tab and correct or comment the code, click OK, then Exit and restart S+ without holding the Control key.
zyxi  
#13 Posted : Tuesday, June 4, 2019 3:43:34 AM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

Thanks: 8 times
Was thanked: 1 time(s) in 1 post(s)
Thank you for your advice, Rob.
Could you consider replacing “sp. Exit ()” with this function (go to Task Manager and kill StrokesPlus.net.exe. Then hold the Control key and start S+. )
or add it to the software as a new feature? because it is often more practical than "sp. Exit ()" when errors occur.
Rob  
#14 Posted : Tuesday, June 4, 2019 3:45:16 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
I was just about to delete my comment as I meant to post it to another thread (automatically activating windows), lol.

So I will leave it here.

I'm not following what you're asking. Could you provide more details?

Edited by user Tuesday, June 4, 2019 3:47:23 AM(UTC)  | Reason: Not specified

zyxi  
#15 Posted : Tuesday, June 4, 2019 3:59:22 AM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

Thanks: 8 times
Was thanked: 1 time(s) in 1 post(s)
Yeah, I mean it's a good feature---go to Task Manager and kill StrokesPlus.net.exe. Then hold the Control key and start S+, compared to “sp. Exit“, when my script goes wrong
Rob  
#16 Posted : Tuesday, June 4, 2019 1:18:12 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
I guess I'm not following you. If there's a script error, there's no guarantee that an sp. function will be able to be executed (e.g. the script engines are locked up, or something).

You can create the code to handle failures gracefully if you want, which would be the recommended method; though it does require a decent level of programming knowledge to do properly.

How are you calling sp.Exit()? Do you have this as another action, or in a hot key?

If the assumption is that you are still able to execute scripts, there's technically no reason you would need to exit S+; though the specific situation would need to be known in regards to the best way to handle each case.

For example, let's say that I have a Load script with a timer that is causing a problem (and I'm still able to execute actions..), this script disables the Load script, saves the settings, then reloads S+:
Code:
sp_config.FireOnLoadAction = false;
sp_config.Save();  //Save() does not currently show in the auto complete list
sp.Reload();

So I just execute that script, say via hot key, and the load script is disabled.

Again, this is a specific example, but there are many ways this can be achieved. I would say that most issues can be handled via proper script logic and checks to prevent failures, or by handling them gracefully when they occur.

If you can provide an example script where this is some error condition which you would have to exit S+ to address, post it here and I can try to give you an example of how to handle it.

Yuichi  
#17 Posted : Thursday, June 6, 2019 12:08:49 PM(UTC)
Yuichi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/13/2018(UTC)
Posts: 54
Poland

Thanks: 18 times
Was thanked: 18 time(s) in 13 post(s)
Hi, Rob can you help if want?

Before start change "s_wTitle". (info in code)
I made few mistakes and i don't have ideas how to solve it.

How it works:
Script run and wait to action.
When you touch left side (not all height) of screen Switch Window will active.
When the cursor is in the Switch Window, the script will start selecting items with the right mouse button, and when the cursor leaves the window, it accepts the selection. (Switch Window will not allow to select item/window by going outside and click on it. I tested it many times.)

Problems:
1) - when the cursor touches the activation field it fires only once, re-entering the field does not activate Switch Window (without "sp.GetCurrentMousePoint().Y >= y_rect" and "sp.GetCurrentMousePoint().Y <= (y_rect*2)" work fine)

2) - line in code"sp.SendVKeyDown(vk.CONTROL); sp.Sleep(20); sp.SendVKeyDown(vk.LMENU); ..." sometimes change working of keyboard (CTRL work as ALT)

3) - when you move mouse fast, it can sometimes click outside the window "if (sp.WindowFromPoint(sp.GetCurrentMousePoint(), true).Title == s_wTitle)"

Even guidance on solving problems would be great :)

PS. I turn off "Aero Peek" in Win7 to get Switch Window on top and I installed program could "Winaero Tweaker" to change size of the window.


Code:
// AUTO ////////////////////////////////////////////////////////////////////////////////////////////
if (sp.GetStoredBool("AutoSwitcher")) { // if "AutoSwitcher" if runing
    sp.StoreBool("AutoSwitcher", false); // send info to the loop to close
    sp.ShowBalloonTip("Auto Switch Windows", "Turn off", "Info", 1000);
} else {
    sp.StoreBool("AutoSwitcher", true); // send info to the loop to start
    sp.ShowBalloonTip("Auto Switch Windows", "Turn on", "Info", 1000);
    var s_wTitle = "Przełączanie zadań"; // name depends on the languane in Windows (somehow ".ClassName" create a problem)
    var b_m_touch = false; // contol if mouse is inside activation area
    var b_m_notTouch = true; // contol if mouse is outside activation area
    var screenRect = Screen.FromPoint(sp.GetCurrentMousePoint()).Bounds; // reusing :)
    var y_rect = Math.floor(screenRect.Height / 3); // the middle part of the 1/3 of the screen
    var x_rect = 1;

    // RUN "AUTOSWITCHER"
    while (sp.GetStoredBool("AutoSwitcher")) { // or instead "while" use "CreateTimer"? (And "b_m_Touch" and "b_m_notTouch" define as "StoredBool"?)

        sp.Sleep(50); // refresh time when switch window is not active

        // ACTIVATION RECT
        // this part activates the switch window (CTRL+ALT+TAB) once, to restart it you have to leave the field and enter again
        //if (!sp.WindowFromClassOrTitle("TaskSwitcherWnd", "")) { // do not work if switch window is running (PART TO FIX!)
            if (b_m_notTouch) {
                if (sp.GetCurrentMousePoint().X <= x_rect &&
                      sp.GetCurrentMousePoint().Y >= y_rect && // (PART TO FIX!)
                      sp.GetCurrentMousePoint().Y <= (y_rect*2)) { // (PART TO FIX!)
                            b_m_touch = true;
                            b_m_notTouch = false;
                }
            } else {
                if (sp.GetCurrentMousePoint().X > x_rect &&
                      sp.GetCurrentMousePoint().Y < y_rect && // (PART TO FIX!)
                      sp.GetCurrentMousePoint().Y > (y_rect*2)) { // (PART TO FIX!)
                            b_m_touch = false;
                            b_m_notTouch = true;
                } else {
                    b_m_touch = false;
                }
            }
        //}

        if (b_m_touch) {
            sp.SendVKeyDown(vk.CONTROL); sp.Sleep(20); sp.SendVKeyDown(vk.LMENU); sp.Sleep(20); sp.SendVKey(vk.TAB); sp.Sleep(20); sp.SendVKeyUp(vk.LMENU); sp.Sleep(20); sp.SendVKeyUp(vk.CONTROL); // when you hit ctrl+alt+tab switching window will be in "stay mode" (PART TO FIX!)
            sp.StoreBool("w_selection", true); // window selection / switcher window
            sp.StoreBool("m_click", false); // mouse click
            var m_oldPos = 0; // mouse old position
            var b_m_InW = false; // mouse in window

            while (!sp.GetStoredBool("m_click")) {
                sp.Sleep(20); // refresh time in switch window

                // EMERGENCY STOP
                if (sp.ForegroundWindow().Title != s_wTitle) { // if switcher somehow disappear
                    sp.StoreBool("w_selection", false);
                    sp.StoreBool("m_click", true);
                    break;
                }

                if (sp.WindowFromPoint(sp.GetCurrentMousePoint(), true).Title == s_wTitle) b_m_InW = true; // cursor is in window
                if (b_m_InW) {
                    if (m_oldPos != sp.GetCurrentMousePoint().ToString()) { // do not allow to click in the same point
                        if (sp.WindowFromPoint(sp.GetCurrentMousePoint(), true).Title == s_wTitle) { // select item (PART TO FIX!)
                            sp.MouseClick(sp.GetCurrentMousePoint(), "Right", false, true); // if switcher is in "stay mode" right click will select item
                            sp.ShowBalloonTip("In window", sp.GetCurrentMousePoint().ToString() + " ", "Info", 100);
                        } else { // if mouse go outside of switch window
                            sp.Sleep(20);
                            sp.SendKeys("~"); // accept selection
                            sp.StoreBool("w_selection", false);
                            sp.StoreBool("m_click", true);
                        }
                    }
                    m_oldPos = sp.GetCurrentMousePoint().ToString(); // remember last mouse position
                }
            } // while 2
        } // b_m_touch "true"
    } // while 1
} // sp.GetStoredBool("AutoSwitcher")



Global Actions > Load/Unload Scripts > Load Script:

Code:
// AUTO SWITCHER
if (sp.GetStoredBool("AutoSwitcher")) { // if "AutoSwitcher" if runing
    sp.StoreBool("AutoSwitcher", false);
    sp.ShowBalloonTip("Auto Switch Windows", "Turn off", "Info", 1000);
}



Mouse button script:

Code:
// ACCEPT WINDOW SELECTION (SWITCH WINDOW)
if (sp.GetStoredBool("w_selection") && !click.Down) {
    sp.StoreBool("w_selection", false);
    sp.StoreBool("m_click", true);
    sp.Sleep(50);
    if (sp.WindowFromPoint(sp.GetCurrentMousePoint(), true).Title == "Przełączanie zadań") {
        sp.SendVKey(vk.PAUSE); // close switch window if you missclick
    }
}
Rob  
#18 Posted : Friday, June 7, 2019 12:43:53 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
I'm still trying to figure out exactly how this is all tied together, you mention selecting with the right button, but there's also a button script.

1)
This logic is faulty:
Code:
if (sp.GetCurrentMousePoint().X > x_rect &&
      sp.GetCurrentMousePoint().Y < y_rect && // (PART TO FIX!)
      sp.GetCurrentMousePoint().Y > (y_rect*2)) { // (PART TO FIX!)
            b_m_touch = false;
            b_m_notTouch = true;
            console.log('check B');
} else {
    b_m_touch = false;
    console.log('check C');
}

It is impossible for the mouse pointer to be both at the top and bottom part of the screen at the same time BigGrin :
Code:
sp.GetCurrentMousePoint().Y < y_rect && sp.GetCurrentMousePoint().Y > (y_rect*2)

You want an OR condition check:
Code:
if (sp.GetCurrentMousePoint().X > x_rect &&
      (
        sp.GetCurrentMousePoint().Y < y_rect 
        ||  //OR 
        sp.GetCurrentMousePoint().Y > (y_rect*2)
      ) //Enclose both of these to form a single condition for the if
) { 
            b_m_touch = false;
            b_m_notTouch = true;
            console.log('check B');
} else {
    b_m_touch = false;
    console.log('check C');
}



2)
If you're not in US keyboard layout, try using the LCONTROL vk instead, but also, why not use this:
Code:
sp.SendModifiedVKeys([vk.LCONTROL,vk.LMENU], [vk.TAB]);



3)
Not sure about that one, again I think I'm not understanding exactly how this is being used, where right-click up event is in play.
I found it was very helpful to enable V8 debugging and log data to the console to see what the values were, like this:
Code:
console.log(`Loop Top - sp.GetCurrentMousePoint().X: ${sp.GetCurrentMousePoint().X} - sp.GetCurrentMousePoint().Y: ${sp.GetCurrentMousePoint().Y} - x_rect: ${x_rect} - y_rect: ${y_rect} - (y_rect*2): ${(y_rect*2)}`);
console.log(`b_m_notTouch: ${b_m_notTouch} - b_m_touch: ${b_m_touch}`);

A few things to keep in mind about this:
  1. Any time you click OK or Apply, the script engines are reloaded. Any Chrome Dev tools window you have open will lose connection to the scripts.
  2. You will need to close the Dev Tools window and refresh this URL, then wait several seconds to show the S+ inspect link again to connect to the newly created script engines: chrome://inspect/#devices
  3. I changed the sleep at the top of the script to 2000 when testing, otherwise the console window fills up with data too fast



Yes, I would recommend this script being in a timer. Take the whole script and put it inside a function in the Load script area, like:
Code:
function TaskSwitcher() {
  //code
}

Then create a timer to call that function. Some things will need to be changed, like you'd need to call delete timer to stop it, etc.
thanks 1 user thanked Rob for this useful post.
Yuichi on 6/10/2019(UTC)
Rob  
#19 Posted : Friday, June 7, 2019 1:04:45 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Also, it seems that class isn't right, at least not for the latest Windows 10; this seems to work for me:

Code:
sp.WindowFromClassOrTitle('MultitaskingViewFrame','')
thanks 1 user thanked Rob for this useful post.
Yuichi on 6/10/2019(UTC)
Yuichi  
#20 Posted : Monday, June 10, 2019 12:49:17 PM(UTC)
Yuichi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/13/2018(UTC)
Posts: 54
Poland

Thanks: 18 times
Was thanked: 18 time(s) in 13 post(s)
Thank you very Rob for your help, i will follow your advices.
2014218866  
#21 Posted : Wednesday, August 21, 2019 7:40:25 AM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

Thanks: 19 times
Was thanked: 1 time(s) in 1 post(s)
Quote:
Code:
if (!sp.GetStoredBool("Window_selection")) {
sp.SendVKeyDown(vk.LMENU); // vk.LMENU (ALT)
sp.SendVKey(vk.TAB);
sp.StoreBool("Window_selection", true);
}


this to Left Mouse Button:
Code:
if (sp.GetStoredBool("Window_selection") && !click.Down) {
sp.SendVKeyUp(vk.LMENU);
sp.StoreBool("Window_selection", false);
}


Hello, Rob, I used the Yuichi's script. There is a problem.
When I click on the left key, the ALT key will not be released. When I use the wheel key instead of the left key, the script will work and the ALT key can be released normally.
In addition, when the ALT key is pressed all the time, the ALT will not be released even if S + is killed by me.
Can you help me solve this problem, thank you.

Rob  
#22 Posted : Wednesday, August 21, 2019 2:15:24 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
The original scripts used the WIN key, for Win+Tab, not the ALT key.

As gesture:
Code:
if (!sp.GetStoredBool("Window_selection")) {
    sp.SendVKeyDown(vk.RWIN); // vk.LMENU (ALT)
    sp.SendVKey(vk.TAB);
    sp.StoreBool("Window_selection", true);
}

this to Left Mouse Button:
Code:
if (sp.GetStoredBool("Window_selection") && !click.Down) {
    sp.SendVKeyUp(vk.RWIN);
    sp.StoreBool("Window_selection", false);
}


The context of this script was to show the task switcher and when you click on an item, to select and release the WIN key.
Using the ALT key for Alt+Tab doesn't really make sense for this script pair.

What exactly is it that you're trying to accomplish?
2014218866  
#23 Posted : Thursday, August 22, 2019 2:38:44 AM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

Thanks: 19 times
Was thanked: 1 time(s) in 1 post(s)
I want to point out that left-clicking scripts are sometimes not executed when I press the left-click, even if the win key is in the original script. And when I put the click script on the wheel and click it, it will work properly (the win key is released). I don't know why the win key is not released after I click the left key. This often happens in my win7 system, both computers are like this.
Rob  
#24 Posted : Thursday, August 22, 2019 1:02:56 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Hmm, I can't seem to make this happen. I will continue to test randomly. The fact that it works sometimes would seem to indicate the internal code isn't broken, otherwise it would be consistent.

I would guess this is some kind of timing issue, but I'm not sure. If you can find any specific sequence which consistently reproduces the behavior, let me know.

I'll add some additional logging in the trace builds for the next release, this might help us narrow down the source of the problem.
2014218866  
#25 Posted : Friday, August 23, 2019 12:31:07 AM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

Thanks: 19 times
Was thanked: 1 time(s) in 1 post(s)
Rob, thank you for your patience in answering my questions.

I suggest you replace the win key with ALT so that you can find the questions better. In the process of using this script many times, I often have the problem that the ALT key is not released. I guess there should be a bug in the execution of the left-click script. Because the same script is placed in the click wheel key, S + will not cause ALT not to be released.

Thank you again for your continued attention, Rob.
2014218866  
#26 Posted : Friday, August 23, 2019 12:36:09 AM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

Thanks: 19 times
Was thanked: 1 time(s) in 1 post(s)
Rob,
As you said, it may be a matter of time, because when I execute the release script, sometimes Alt is released after a period of time.
However, if I change to the wheel key to execute this script, then S + will not have the problem of delay, which is worthy of our attention.
Rob  
#27 Posted : Friday, August 23, 2019 5:05:02 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
I used Alt instead and have executed it over a hundred times, each time the Alt key is released properly.

I might be a matter of your configuration, upload the file or full export and I can see if there's anything I can find.
2014218866  
#28 Posted : Saturday, August 24, 2019 12:33:48 AM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

Thanks: 19 times
Was thanked: 1 time(s) in 1 post(s)
Rob, please give me more time to find out the rules that lead to this problem. Because the problem is random.
Thank you again for your patient reply.
lyscop  
#29 Posted : Friday, May 8, 2020 5:30:05 PM(UTC)
soooulp

Rank: Advanced Member

Reputation:

Groups: Moderators, Approved
Joined: 4/23/2020(UTC)
Posts: 161
China

Thanks: 46 times
Was thanked: 23 time(s) in 17 post(s)
Originally Posted by: Rob Go to Quoted Post
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.




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?
soooulp  
#30 Posted : Wednesday, May 5, 2021 6:24:42 AM(UTC)
soooulp

Rank: Advanced Member

Reputation:

Groups: Moderators, Approved
Joined: 4/23/2020(UTC)
Posts: 161
China

Thanks: 46 times
Was thanked: 23 time(s) in 17 post(s)
Originally Posted by: soooulp Go to Quoted Post
Originally Posted by: Rob Go to Quoted Post
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.




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 {}
    }





zyxi  
#31 Posted : Sunday, August 15, 2021 2:44:28 PM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

Thanks: 8 times
Was thanked: 1 time(s) in 1 post(s)
Since using the new version 0.5.4.6, I found that the scroll wheel does not work in this script. Can you give me some help, thank you very much

Quote:
Code:
if (!sp.GetStoredBool("Window_selection")) {
sp.SendVKeyDown(vk.RWIN); // vk.LMENU (ALT)
sp.SendVKey(vk.TAB);
sp.StoreBool("Window_selection", true);
}

this to Left Mouse Button:
Code:
if (sp.GetStoredBool("Window_selection") && !click.Down) {
sp.SendVKeyUp(vk.RWIN);
sp.StoreBool("Window_selection", false);
}


Similarly, in mouse events, the horizontal scroll wheel does not work anymore, I don’t know why



UserPostedImage





2014218866  
#32 Posted : Monday, August 16, 2021 12:23:23 PM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

Thanks: 19 times
Was thanked: 1 time(s) in 1 post(s)
Unfortunately, I found that when the volume is adjusted by the scroll wheel on the right edge of the screen (the function that comes with the mouse will also appear when sliding down), this is a problem that does not exist in the old version. For example, when Google Chrome uses the scroll wheel script to adjust the volume, At the same time it will automatically page down. This effect experience is very bad.
Rob  
#33 Posted : Monday, August 16, 2021 7:09:03 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
I've tried both of the scripts in the two recent posts, and they are working fine for me. I even bought a mouse with a horizontal wheel to be sure.

I might need you to send me your config file so I can try to run it on my system in debug mode.
zyxi  
#34 Posted : Tuesday, August 17, 2021 12:26:28 AM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

Thanks: 8 times
Was thanked: 1 time(s) in 1 post(s)
Profile Link:
https://send.cm/d/4LJg

UserPostedImage

Dear Rob, thank you for your reply.
1. When I execute the ATL + Tab script, the check box does not scroll with my mouse wheel. I end the script by pressing the middle mouse button or the left mouse button.

UserPostedImage

2. Second problem: when I adjust the volume at the lower right edge of the window through the scroll wheel, the page will scroll, that is, the original function of the mouse scroll wheel will appear when the script is executed.

UserPostedImage

3. I want to use the horizontal mouse wheel to enter or backspace in word, but it does move the horizontal picture left and right, but it can switch labels in Google browser.

UserPostedImage









Rob  
#35 Posted : Tuesday, August 17, 2021 3:34:12 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Quote:
1. When I execute the ATL + Tab script, the check box does not scroll with my mouse wheel. I end the script by pressing the middle mouse button or the left mouse button.

I feel like the implementation of these scripts do not make sense, based on what I am assuming would be the desired result. I don't believe the Left or Middle script for window_selection are necessary.
I imagine you would want to hold the right button, scroll the wheel up or down to change selected window, then release right button to switch to that window, like this:


Back:

UserPostedImage


Forward:

UserPostedImage


Release script to select:

UserPostedImage




Quote:
2. Second problem: when I adjust the volume at the lower right edge of the window through the scroll wheel, the page will scroll, that is, the original function of the mouse scroll wheel will appear when the script is executed.

If you do not consume the wheel event, S+ will execute the script, but not prevent the application from receiving the wheel message as well. Most of your script code sends the mouse wheel event as a condition, so you should be able to check the Consume box and the volume would not cause Chrome to scroll.

UserPostedImage


Quote:
3. I want to use the horizontal mouse wheel to enter or backspace in word, but it does move the horizontal picture left and right, but it can switch labels in Google browser.

I cannot reproduce this issue, it works fine for me using your settings export in Word. My only thought is to use Console lines to help debug what is happening in the horizontal scroll script.


Add console logging line:

UserPostedImage



Scroll horizontal in Word and see output:

UserPostedImage

Try adding other logging to help isolate where the code is failing, but it works okay for me.



thanks 1 user thanked Rob for this useful post.
zyxi on 8/18/2021(UTC)
randomConstant  
#36 Posted : Thursday, November 4, 2021 1:25:36 PM(UTC)
randomConstant

Rank: Advanced Member

Reputation:

Groups: Translators, Approved
Joined: 7/17/2021(UTC)
Posts: 135

Thanks: 35 times
Was thanked: 18 time(s) in 15 post(s)
You can also 'cycle through open windows' using these Windows shortcuts:

Cycle forward:
Shortcut: Alt + Esc
Code:
sp.SendModifiedVKeys([vk.LMENU], [vk.ESCAPE]);


Cycle backward:
Shortcut: Alt + Shift + Esc
Code:
sp.SendModifiedVKeys([vk.LMENU,vk.LSHIFT], [vk.ESCAPE]);


These shortcuts can be binded on mousewheel Up and Down events(scripts). There are no previews and the shift is instant. Might be helpful to some.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.