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

Notification

Icon
Error

Options
Go to last post Go to first unread
benderunit  
#1 Posted : Sunday, April 24, 2022 4:49:20 PM(UTC)
benderunit

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/22/2021(UTC)
Posts: 3
Russian Federation
Location: Moscow

Thanks: 2 times
App Specific Shortcuts

Is it possible to define a keyboard shortcut for a certain app that would execute a number of steps?

For example:
If I press a defined shortcut F1 in Total Commander, instead of opening Help by default StrokesPlus overrides it and executes two steps:
1. Send keyboard shortcut F6
2. Send keyboard shortcut ENTER

________________________

Rob, thanks a lot for StrokePlus. Can't imagine my work without it.
Rob  
#2 Posted : Monday, April 25, 2022 2:33:20 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 27 times
Was thanked: 378 time(s) in 328 post(s)
Yeah, you just have to check the foreground window.

I don't have Total Commander installed, so I'm not sure if the title match below will work - just change "Total Commander" as needed to match the title of that window.

I just made a regular hotkey in S+ for F1 (only Active checked, not Unregistered), then added this script. My test used "Notepad" instead of "Total Commander", but it worked fine.
Code:
// If the active window is Total Commander, send F6 then Enter
if(sp.ForegroundWindow().Title.indexOf("Total Commander") > -1) {
    sp.SendVKey(vk.F6);
    sp.SendVKey(vk.RETURN);
} else {
    // Otherwise send F1 for any other app
    sp.SendVKey(vk.F1);
}
thanks 1 user thanked Rob for this useful post.
benderunit on 4/25/2022(UTC)
benderunit  
#3 Posted : Monday, April 25, 2022 3:22:48 PM(UTC)
benderunit

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/22/2021(UTC)
Posts: 3
Russian Federation
Location: Moscow

Thanks: 2 times
Thank you Rob. It works.
But what if I need to define the same shortcut to execute different actions in more than one app?

For example:
If I press F1 in Total Commander, it executes two steps:
1. Send keyboard shortcut F6
2. Send keyboard shortcut ENTER

If I press F1 in CorelDRAW, it executes:
1. Send keyboard shortcut ALT+CTRL+SHIFT+F10



Rob  
#4 Posted : Monday, April 25, 2022 4:59:34 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 27 times
Was thanked: 378 time(s) in 328 post(s)
You just keep adding conditions like this:
Code:
// If the active window is Total Commander, send F6 then Enter
if(sp.ForegroundWindow().Title.indexOf("Total Commander") > -1) {
    sp.SendVKey(vk.F6);
    sp.SendVKey(vk.RETURN);
} else if(sp.ForegroundWindow().Title.indexOf("CorelDRAW") > -1) {
   // do something for Corel
} else if(sp.ForegroundWindow().Title.indexOf("Notepad") > -1) {
   // do something for Notepad
} else {
    // Otherwise send F1 for any other app
    sp.SendVKey(vk.F1);
}
thanks 1 user thanked Rob for this useful post.
benderunit on 4/25/2022(UTC)
benderunit  
#5 Posted : Monday, April 25, 2022 10:54:06 PM(UTC)
benderunit

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/22/2021(UTC)
Posts: 3
Russian Federation
Location: Moscow

Thanks: 2 times
Thank you. It works.
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.