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

Notification

Icon
Error

Options
Go to last post Go to first unread
Thaworn  
#1 Posted : Thursday, October 15, 2020 10:13:34 AM(UTC)
Thaworn

Rank: Member

Reputation:

Groups: Approved
Joined: 8/8/2020(UTC)
Posts: 12
Thailand

Thanks: 1 times
How to set hotkey only for specific application like mouse gesture?
Rob  
#2 Posted : Thursday, October 15, 2020 12:17:46 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 418 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");
}


thanks 1 user thanked Rob for this useful post.
LukasW on 12/16/2020(UTC)
Thaworn  
#3 Posted : Thursday, October 15, 2020 10:05:44 PM(UTC)
Thaworn

Rank: Member

Reputation:

Groups: Approved
Joined: 8/8/2020(UTC)
Posts: 12
Thailand

Thanks: 1 times
Thank you so much.
Thaworn  
#4 Posted : Thursday, November 5, 2020 4:28:22 PM(UTC)
Thaworn

Rank: Member

Reputation:

Groups: Approved
Joined: 8/8/2020(UTC)
Posts: 12
Thailand

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.???;
}
Rob  
#5 Posted : Friday, November 6, 2020 5:43:24 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 418 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.
thanks 1 user thanked Rob for this useful post.
Thaworn on 11/10/2020(UTC)
Thaworn  
#6 Posted : Tuesday, November 10, 2020 6:18:45 AM(UTC)
Thaworn

Rank: Member

Reputation:

Groups: Approved
Joined: 8/8/2020(UTC)
Posts: 12
Thailand

Thanks: 1 times
Originally Posted by: Rob Go to Quoted Post
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?
Rob  
#7 Posted : Tuesday, November 10, 2020 3:28:34 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 418 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?
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.