Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to activate/deactivate macros based on a lock state #50

Open
BeegMan27 opened this issue May 10, 2024 · 1 comment
Open

Comments

@BeegMan27
Copy link

I'm not totally sure if this is the right way to ask a question like this, but I found that the existing documentation was not specific enough to be helpful in this case.

I want to create a script/macro/task/whatever-tf-it's-called that uses the scroll lock key to toggle the numpad between normal functionality and a 'macro mode'. This is to say, while scroll lock is inactive, the numpad acts as normal and while active, each key sends an 'F#' key or other custom keystroke combination. Is this kind of thing supported?

@hptruong93
Copy link
Contributor

There's a Java code (seemingly only works in Windows) to detect whether Scroll Lock is activated.

Check this answer on Stackoverflow https://stackoverflow.com/a/7435344/1974520.
So you could just write a precondition at the start of the task.

boolean isOn = java.awt.Toolkit.getDefaultToolkit().getLockingKeyState(java.awt.event.KeyEvent.VK_NUM_LOCK);
if (!isOn) {
  return;
}

Another way is to create a 2nd task, and have that task be activated on ScrollLock, then use a variable to store the state of the scroll lock (assuming it's off as a starting state). Then the main task can read that shared variable to retrieve the state of the scroll lock.
Let me know if that's clear or you'd want some code for this 2nd option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants