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

Notification

Icon
Error

Options
Go to last post Go to first unread
Theinvoker  
#1 Posted : Wednesday, June 3, 2020 11:04:00 AM(UTC)
Theinvoker

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/24/2020(UTC)
Posts: 37
Italy
Location: Milano

Thanks: 2 times
Is it possible to disable secondary button for some applications?

I need it to have more gestures only for video players bot not for other things
Rob  
#2 Posted : Wednesday, June 3, 2020 2:40:16 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)
You can handle that via script in the Global Actions > Window Events > Foreground Window Change tab.

Something like this:
Code:
//If Chrome, set secondary stroke button to middle, otherwise disable secondary stroke button
if(sp.ForegroundWindow().Title.indexOf("- Google Chrome") > -1) {
    sp_config.SecondaryStrokeButton = MouseButtons.Middle;
} else {
    sp_config.SecondaryStrokeButton = MouseButtons.None;
}
Theinvoker  
#3 Posted : Wednesday, June 3, 2020 3:10:11 PM(UTC)
Theinvoker

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/24/2020(UTC)
Posts: 37
Italy
Location: Milano

Thanks: 2 times
EDIT
it's not working. i need to know the exact name to put where you put "Google chrome". how do i get it?

Edited by user Wednesday, June 3, 2020 3:19:25 PM(UTC)  | Reason: Not specified

Rob  
#4 Posted : Wednesday, June 3, 2020 4:34:52 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)
This was just an example, you'd need to make updates as needed to handle each of the applications you want to allow the secondary stroke button for.

This script is just looking for the existence of a partial string match in the foreground window's title. You could use that (combining multiple strings to match), or EXE names.

You can call this when the window is active to get the full title, but you would usually just want to match on a non-variable part of the title so it doesn't fail to match if the caption changes a little (like an active document, etc.)

sp.MessageBox(sp.ForegroundWindow().Title, "Foreground Window Title");

This will get the EXE name of the foreground window:

sp.ForegroundWindow().Process.MainModule.ModuleName

For example:
Code:
//If Chrome or Notepad++ is the foreground (active) window, 
//enable middle mouse as secondary stroke button, otherwise disable secondary
if(sp.ForegroundWindow().Process.MainModule.ModuleName == "chrome.exe" 
   || sp.ForegroundWindow().Process.MainModule.ModuleName == "notepad++.exe"){
    sp_config.SecondaryStrokeButton = MouseButtons.Middle;
} else {
    sp_config.SecondaryStrokeButton = MouseButtons.None;
}
Theinvoker  
#5 Posted : Wednesday, June 3, 2020 5:58:32 PM(UTC)
Theinvoker

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/24/2020(UTC)
Posts: 37
Italy
Location: Milano

Thanks: 2 times
i know nothing about this so when you rite i just copy

And it's not working, sorry
i just changed chrome.exe withthe app i need PotPlayerMini64.exe

I enabled "use secondary button" in app ---> action list
Rob  
#6 Posted : Wednesday, June 3, 2020 6:42:40 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)
This works fine for me:
Code:
try
{
    if(sp.ForegroundWindow().Process.MainModule.ModuleName == "chrome.exe" 
       || sp.ForegroundWindow().Process.MainModule.ModuleName == "PotPlayerMini64.exe"){
        sp_config.SecondaryStrokeButton = MouseButtons.Middle;
    } else {
        sp_config.SecondaryStrokeButton = MouseButtons.None;
    }
}
catch {}


Of course, make sure to change MouseButtons.Middle to whatever mouse button you want to use as your secondary.
Theinvoker  
#7 Posted : Wednesday, June 3, 2020 7:45:12 PM(UTC)
Theinvoker

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/24/2020(UTC)
Posts: 37
Italy
Location: Milano

Thanks: 2 times
UserPostedImage

UserPostedImage

Nothing happens
Theinvoker  
#8 Posted : Thursday, June 4, 2020 8:43:48 AM(UTC)
Theinvoker

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/24/2020(UTC)
Posts: 37
Italy
Location: Milano

Thanks: 2 times
i tried to activate "draw gestures" and now i sse that using middle button on potplayer drwas a red line, that is good because red is for secondary button
But i don't understand why it doesn't perfmorm ALT+Arrow command

A second problem is that i have 2 monitors and when i change from having both on or just one, this script stop working and i have to restart strokesplus

EDIT
i found the problem. it was in app definition for potplayer.

But i found a new problem

Usually gestures work even if the window i want to move it is not selected before. I mean...let's say i'm on firefox on monitor 1 and i have potplayer fullscreen on monitor 2. if i use a gesture on potplayer with primary button, it works perfectly just because potplayer was below the cursor.
But if i use the secondary button, with the script, it doesn't work the first time. the first time is needed to take focus of that window and then the gesture works.

I would like to have the same behavior i have when i use primary button

Edited by user Thursday, June 4, 2020 9:05:24 AM(UTC)  | Reason: Not specified

Rob  
#9 Posted : Thursday, June 4, 2020 12:51:29 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)
That's because the script which enables the secondary button only executes when the foreground (active) window changes.

So until PotPlayer is the active window, the secondary button is not enabled - there's no easy way around this since you don't want the secondary active in other applications. To configure stroke buttons based on the window below the cursor would require a major rewrite of S+ and is not something I am considering at this point in time due to the amount of work involved and that it would affect performance since S+ would constantly be examining windows every time the mouse moves.

Why it works the second time is because the secondary button is being clicked on PotPlayer just as if S+ was not running, which causes PotPlayer to become activated, this then executes the foreground window change script which enables the secondary button.
Theinvoker  
#10 Posted : Thursday, June 4, 2020 1:27:15 PM(UTC)
Theinvoker

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/24/2020(UTC)
Posts: 37
Italy
Location: Milano

Thanks: 2 times
Ok it's still useful. if i want to use mouse buttons to do same thing (next or previous video) i have to select potplayer window, only a different way to do the same thing
Users browsing this topic
Similar Topics
sp.MouseClick() fails after switching primary and secondary buttons (Scripts)
by sdhdsp 4/28/2021 5:32:02 PM(UTC)
enable/disable secondary button base on the foreground program (Feature Requests)
by dirtyacc 12/8/2019 1:38:39 AM(UTC)
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.