Rank: Member
Groups: Approved
Joined: 12/2/2019(UTC) Posts: 20
Thanks: 2 times
|
Hi I wanted to bind the NumLock hotkey to run a specific application or to bring it up if it's already run. Moreover, next Numlock press must minimize the app. Cany you help me with that? Thanks Edited by user Thursday, February 18, 2021 7:49:59 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,349 Location: Tampa, FL Thanks: 28 times Was thanked: 416 time(s) in 354 post(s)
|
This is an example using notepad - it only is matching on partial title, but it gives you a starting point. I created a hotkey which is bound to NUMLOCK: Code:var wnd = sp.WindowsFromTitlePartial("- Notepad");
if(wnd.Count() === 0) {
sp.Run("notepad");
} else {
if(wnd.First().Minimized) {
wnd.First().Restore();
} else {
if(sp.ForegroundWindow().HWnd.ToString() !== wnd.First().HWnd.ToString()) {
wnd.First().Activate();
} else {
wnd.First().Minimize();
}
}
}
If notepad is not open, it will run notepad. If notepad is open but not active, it will activate it - if notepad is active, it will minimize it.
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Member
Groups: Approved
Joined: 12/2/2019(UTC) Posts: 20
Thanks: 2 times
|
It works well, but sometimes it turns numlock off. Please add a string that will check the numlock status and turns it on
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,349 Location: Tampa, FL Thanks: 28 times Was thanked: 416 time(s) in 354 post(s)
|
I also updated it to restore the window maximized if that was the state before minimizing. Code:var wnd = sp.WindowsFromTitlePartial("- Notepad");
if(wnd.Count() === 0) {
sp.Run("notepad");
} else {
if(wnd.First().Minimized) {
if(sp.GetStoredBool("WindowMaximized")) {
wnd.First().Maximize();
} else {
wnd.First().Restore();
}
} else {
if(sp.ForegroundWindow().HWnd.ToString() !== wnd.First().HWnd.ToString()) {
wnd.First().Activate();
} else {
sp.StoreBool("WindowMaximized", wnd.First().Maximized);
wnd.First().Minimize();
}
}
}
sp.Sleep(250);
if(!sp.IsKeyToggled(vk.NUMLOCK)) {
sp.SendVKey(vk.NUMLOCK);
}
Edited by user Friday, February 19, 2021 2:26:07 PM(UTC)
| Reason: Not specified
|
1 user thanked Rob for this useful post.
|
|
|
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