StrokesPlus.net Forum
»
General Discussion
»
General Discussion
»
How to set hotkey only for specific application?
Rank: Member
Groups: Approved
Joined: 8/8/2020(UTC) Posts: 12 Thanks: 1 times
|
How to set hotkey only for specific application like mouse gesture?
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Hotkeys are normally registered globally with Windows (if the Unregistered box is not checked), so these cannot be application-specific. Regardless of whether or not the hotkey is registered (the Unregistered option is to allow hotkeys that Windows won't allow), you can put the logic into the hotkey. For example: Code:var fgWindow = sp.ForegroundWindow();
var exeName = fgWindow.Process.MainModule.ModuleName;
//exeName comparisons below are case-sensitive!
if(exeName === "chrome.exe")
{
sp.MessageBox("Chrome", "Chrome");
}
else if(exeName === "notepad++.exe")
{
sp.MessageBox("Notepad++", "Notepad++");
}
else if(exeName === "Discord.exe")
{
sp.MessageBox("Discord", "Discord");
}
else
{
sp.MessageBox("Other: " + exeName, "Other");
}
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Member
Groups: Approved
Joined: 8/8/2020(UTC) Posts: 12 Thanks: 1 times
|
|
|
|
|
Rank: Member
Groups: Approved
Joined: 8/8/2020(UTC) Posts: 12 Thanks: 1 times
|
If I set key "Z" as "LEFT" only for KMPayer64.exe and I want keyboard "Z" to type normally on other application, what should I put in sp.???; ?
var fgWindow = sp.ForegroundWindow(); var exeName = fgWindow.Process.MainModule.ModuleName;
//exeName comparisons below are case-sensitive! if(exeName === "KMPlayer64.exe") { sp.SendVKey(vk.LEFT); } else { sp.???; }
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Is this script in a hotkey? I just want to make sure I understand where it is starting. If it is a hotkey, make sure to check Active, Unregistered, and Consume, then use this: Code:var fgWindow = sp.ForegroundWindow();
var exeName = fgWindow.Process.MainModule.ModuleName;
//exeName comparisons below are case-sensitive!
if(exeName === "KMPlayer64.exe")
{
sp.SendVKey(vk.LEFT);
}
else
{
sp.SendVKey(vk.VK_Z);
}
Since we checked Consume, the Z key will never be seen by any application. So we need to manually send it, unless the foreground window is KMPlayer64.exe, in which case we send LEFT.
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Member
Groups: Approved
Joined: 8/8/2020(UTC) Posts: 12 Thanks: 1 times
|
Originally Posted by: Rob Is this script in a hotkey? I just want to make sure I understand where it is starting. If it is a hotkey, make sure to check Active, Unregistered, and Consume, then use this: Code:var fgWindow = sp.ForegroundWindow();
var exeName = fgWindow.Process.MainModule.ModuleName;
//exeName comparisons below are case-sensitive!
if(exeName === "KMPlayer64.exe")
{
sp.SendVKey(vk.LEFT);
}
else
{
sp.SendVKey(vk.VK_Z);
}
Since we checked Consume, the Z key will never be seen by any application. So we need to manually send it, unless the foreground window is KMPlayer64.exe, in which case we send LEFT. Yes, that's right, but when I press SHIFT + LEFT then press LEFT while SHIFT is down in other application, SHIFT + LEFT will become only LEFT without SHIFT. How to correct it?
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
When you say SHIFT+LEFT, are you referring to the left mouse button, or the left arrow key?
But that aside, why would the shift be affecting anything in regards to the LEFT, as I thought this hotkey was for the "z" key?
|
|
|
|
StrokesPlus.net Forum
»
General Discussion
»
General Discussion
»
How to set hotkey only for specific application?
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