Rank: Newbie
Groups: Approved
Joined: 12/22/2021(UTC) Posts: 7  Location: Moscow Thanks: 3 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.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,308  Location: Tampa, FL Thanks: 28 times Was thanked: 410 time(s) in 351 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);
}
|
 1 user thanked Rob for this useful post.
|
|
|
Rank: Newbie
Groups: Approved
Joined: 12/22/2021(UTC) Posts: 7  Location: Moscow Thanks: 3 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
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,308  Location: Tampa, FL Thanks: 28 times Was thanked: 410 time(s) in 351 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);
}
|
 1 user thanked Rob for this useful post.
|
|
|
Rank: Newbie
Groups: Approved
Joined: 12/22/2021(UTC) Posts: 7  Location: Moscow Thanks: 3 times
|
|
|
|
|
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.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close