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 : Tuesday, May 28, 2019 1:10:40 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)
Hello, Rob

I want to know if there is such a script:
Which window (or software) is automatically activated when the mouse is placed on which window (or software) without any keys and gestures。
if there is, how to achieve?

thank you.
Rob  
#2 Posted : Tuesday, May 28, 2019 2:06:14 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
No way to do that in StrokesPlus.net, and I'm not familiar with another software utility which will do that, but I wouldn't be surprised if one exists.
Sofocl  
#3 Posted : Tuesday, May 28, 2019 2:20:35 PM(UTC)
Sofocl

Rank: Member

Reputation:

Groups: Approved
Joined: 5/16/2019(UTC)
Posts: 17
Uzbekistan

ToggleMOUSE
Option ActiMouse
Sorry for my bad English.
2014218866  
#4 Posted : Tuesday, May 28, 2019 2:26:54 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)
Can you help me to achieve it? Thank you,Sofocl
Sofocl  
#5 Posted : Tuesday, May 28, 2019 2:55:53 PM(UTC)
Sofocl

Rank: Member

Reputation:

Groups: Approved
Joined: 5/16/2019(UTC)
Posts: 17
Uzbekistan

Yeah, ask.
Sorry for my bad English.
2014218866  
#6 Posted : Tuesday, May 28, 2019 3:00:27 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 know what you mean. Use another software to implement it. Thanks a lot.
Rob  
#7 Posted : Tuesday, June 4, 2019 3:46:33 AM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 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.

You will 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.
2014218866  
#8 Posted : Tuesday, June 4, 2019 10:23:50 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)
It's a good script, but it's not very practical. It makes my right mouse button not work properly.
As long as it involves right clicking, my program window will flash.
Thank you all the same, Rob


UserPostedImage
Rob  
#9 Posted : Tuesday, June 4, 2019 12:45:46 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
Right, that's why I mentioned it was only a basic example.

To do this properly would need to be a much larger script to examine many things to determine the correct action to take, or not to take.

Here's an updated version which doesn't activate if the window/control under the mouse is a special class, like a menu popup or certain other type.
I also changed the activate window code to be in a function, making it easier to read and modify.
Code:
function ActivateWindow() {
    var mouseWindow = sp.WindowFromPoint(sp.GetCurrentMousePoint(), true);
    var fgWindow = sp.ForegroundWindow();
    var isSpecialClass = mouseWindow.ClassName == "ComboLBox"    //Combobox dropdown list
                         || mouseWindow.ClassName == "#32768"     //Menu popup
                         || mouseWindow.ClassName == "#32769"     //Desktop window
                         || mouseWindow.ClassName == "#32770"     //Dialog box (Save As.., etc)
                         || mouseWindow.ClassName == "#32771"     //Task switch window
                         || mouseWindow.ClassName == "#32772";    //Icon titles
    if(!isSpecialClass && mouseWindow.HWnd != fgWindow.HWnd) {
        mouseWindow.BringToFront();
    }
}
sp.CreateTimer("ActivateWindow", 0, 500, `ActivateWindow();`); 

I'm sure there are other conditions which will need to be accounted for under certain circumstances, but this seems to be a more functional version for you folks to extend further.
2014218866  
#10 Posted : Tuesday, June 4, 2019 2:00:06 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)
Thank you very much, Rob.
In the process of using the updated version,
I deeply realized that there were still many problems in the execution of this script,.
For example, in a child window of Google Browser, it will make it impossible for you to type properly.
Although I admit that this script is very useful. But to some extent, I had to give up.
It often made my S + stop working. But your interaction with you is really enjoyable,
so thank you again.


UserPostedImage
Rob  
#11 Posted : Tuesday, June 4, 2019 2:11:52 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
Yes, this script would be a very complicated one to make perfect, but it should be technically possible.

It would just take a lot of time addressing the variety of possible scenarios and improving the logic.

Perhaps one day someone will take my starting script and enhance it! :)
2014218866  
#12 Posted : Tuesday, June 4, 2019 2:28:39 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 look forward to it.
2014218866  
#13 Posted : Sunday, June 9, 2019 2:32:26 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)
Dear Rob,
I want to know if it is possible to activate (or get) the top window (such as a switch window) and deactivate by clicking.
If you can achieve it. Please help me write the code to activate the switch window, thank you.
Rob  
#14 Posted : Monday, June 10, 2019 12:16:49 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
I am not understanding your request, please provide more details.
2014218866  
#15 Posted : Monday, June 10, 2019 1:26:00 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)
Hi, Rob, I think I already know how to solve that problem, but I don't know how to use GetRegionFromPoint and GetRegions. I can't understand the examples.
I want to do the following:
divide the window into 6×6, how to perform functions in the following regions:

1) in the first two columns (rows),
2)in the fourth column in the third row,
3)in the fourth and fifth rows in the sixth column.

Can you help me?
Rob  
#16 Posted : Monday, June 10, 2019 2:01:22 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
Code:
var columns = 6;
var rows = 6;
var region = sp.GetRegionFromPoint(action.Window.Rectangle, action.Start, columns, rows);
if(region.Column == 1 || region.Column == 2) {
    sp.MessageBox(`Match!\r\nColumn 1 or 2, any Row\r\n\Region: Column: ${region.Column} - Row: ${region.Row}`, "Match");
} else if (region.Column == 4 && region.Row == 3) {
    sp.MessageBox(`Match!\r\nColumn 4, Row 3\r\n\Region: Column: ${region.Column} - Row: ${region.Row}`, "Match");
} else if (region.Column == 6 && (region.Row == 5 || region.Row == 6)) {
    sp.MessageBox(`Match!\r\nColumn 6, Row 5 or Row 6\r\n\Region: Column: ${region.Column} - Row: ${region.Row}`, "Match");
} else {
    sp.MessageBox(`No match, default condition\r\nRegion: Column: ${region.Column} - Row: ${region.Row}`, "No Match");
}
2014218866  
#17 Posted : Monday, June 10, 2019 2:20:45 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)
Thank you,Rob
In addition, I recommend sorting and indexing the problems (or useful scripts) that have been solved, so as to help new people learn, and simple questions or problems that have been solved do not need to be answered again (or you can also make a bulletin, recommend using keywords to index, which can also reduce your burden).
This is just a suggestion for beginners. Because S + will become more and more popular, new members of the forum will become more and more. As a result, you will deal with more and more things .
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.