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

Always-on window polling for command mode #33

Closed
synkarius opened this issue Mar 2, 2015 · 11 comments
Closed

Always-on window polling for command mode #33

synkarius opened this issue Mar 2, 2015 · 11 comments
Labels
Enhancement Enhancement of an existing feature
Milestone

Comments

@synkarius
Copy link
Collaborator

As per @chajadan's suggestion, add always-on window polling to monitor when command mode should turn on and off.

  • trigger via keypress
  • make enable-able in the settings
@synkarius synkarius added the Enhancement Enhancement of an existing feature label Mar 2, 2015
@synkarius synkarius modified the milestone: v4 Mar 3, 2015
@synkarius
Copy link
Collaborator Author

Make the key for the keypress configurable in settings: "pyHook_KeyID"

@chajadan
Copy link

chajadan commented Mar 6, 2015

it occurs to me -- you could send a sequence of keys such as "Lshift, Rshift, Rshift, Lshift": such keys won't need to be gobbled up, since they won't alter the window with foculs, so as long as you poll the keyboard and restore any keystates in action (such as shift down), it would be an incognito sequence you could catch and not likely to be a false positive.

@synkarius
Copy link
Collaborator Author

That's a great idea about using the shift key. I've basically got this working now except for one thing. After about 8-11 keypresses, pyHook seems to stop detecting anything, whether i send it via win32 or just by pressing keys on the keyboard. Then, I have to reboot Dragon NaturallySpeaking to make it detect the next 8-11 times. Do you have any idea why that might be?

@synkarius
Copy link
Collaborator Author

Disregard that. It's not 8-11 keypresses, it's 8-11 keypresses which trigger the Mimic action.

@chajadan
Copy link

chajadan commented Mar 8, 2015

I don't quite follow -- I can't tell if you figured it out yourself, or not. If not, if you can link me to the code it would help. I've never had the hook stop registering, but my hooks only stay on for short periods until they've gathered what they are expecting, and then they shut down until I purposely initiate them by a voice command.

@synkarius
Copy link
Collaborator Author

I haven't figured it out yet. Here are the relevant sections of code.

This is the script which runs externally. If it detects that a window has changed at all, it presses whenever key the settings file tells it to, in this case, RShift. It works fine, no problems.
https://github.com/synkarius/caster/blob/master/asynch/auto_com/poller.py

This is the one which is run from inside Dragonfly. If it gets inside the if statement on line 35, it will execute those Mimic commands when they are supposed to be executed (when the designated keypress is detected) for the first 8-11 times, then after that, the OnKeyboardEvent callback doesn't execute anymore, nor does it throw any errors. It just fails silently.
https://github.com/synkarius/caster/blob/master/asynch/auto_com/hooks.py#L35

Also, let me say, whether I figure this out or not, thank you for the suggestion and the help. :-)

@chajadan
Copy link

chajadan commented Mar 8, 2015

After the failure point, does OnKeyboardEvent get called at all?

@chajadan
Copy link

chajadan commented Mar 8, 2015

You mentioned that it silently fails, but lack of executing wouldn't qualify in my head as a failure on its part. And I'm happy to help! I'm all about dragonfly coding lately =)

@synkarius
Copy link
Collaborator Author

No, after the failure point, OnKeyboardEvent doesn't get called at all.

@chajadan
Copy link

chajadan commented Mar 8, 2015

You seem to use a global pyHook manager -- maybe that's the issue -- you
use hooks elsewhere?

I have multiple managers that are at module level, and they don't conflict.
pyHook seems to only allow a single hook per event type.

You can put debug code in the pyHook code under SubscribeKeyDown to see if
something else is getting set. Or just print out the pyHookManager's
keyboard_funcs dictionary to make sure your callback is still registered at
the point of failure.

On Sun, Mar 8, 2015 at 12:53 AM, David Conway [email protected]
wrote:

No, after the failure point, OnKeyboardEvent doesn't get called at all.


Reply to this email directly or view it on GitHub
synkarius#33 (comment).

@synkarius
Copy link
Collaborator Author

I'm pretty sure the hooks weren't being used elsewhere, but you gave me an interesting idea which seems to have solved my problem.

my hooks only stay on for short periods

I tried reregistering the hooks every single time a Mimic action is executed, and now they don't shut off. It's not pretty but it works. Thanks again!

LexiconCode pushed a commit to LexiconCode/Caster that referenced this issue Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Enhancement of an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants