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
Multiple improvements, view comment #2
Conversation
laggykiller
commented
Sep 5, 2021
- Add hotkey for capture and translate
- Uses python module 'keyboard'
- Example: Set hotkey to 'Enter' such that pressing enter can both advance the VN and capture
- User is able to set the hotkey in settings by pressing button and press desired hotkey
- Instead of reading Setting.json everytime the screen is captured, cached settings in memory is read to reduce read from hard drive
- Auto copy resource and user_manual from source through .spec file; Removed redundant files from copy_after_compiling
- Fix typo
- Add files to .gitignore
Notice that capture_UI.getTextAndTranslate() is called in hotkeyPoll() instead of being called directly by hotkeyCallback(). Since hotkeyCallback() is invoked by keyboard module hotkey, I think hotkeyCallback() would be called in separate thread from main thread. It seems that if hotkeyCallback() which is in another thread calls capture_UI.getTextAndTranslate(), which tries to create tkinter.messagebox() in case of error, tkinter would mistaken that there is no instances of tkinter running, hence try to create another instance of tkinter. Tkinter does not like running two instances simultaneously, hence throws RuntimeError. This is solved by creating hotkeyPoll(), which is executed in main thread every 100ms and invoke capture_UI.getTextAndTranslate(), if hotkey was pressed in previous 100ms, tkinter.messagebox() will run in main thread instead of in separate thread, hence prevent creating another instance of tkinter and prevent RuntimeError. This solution is ugly, but it works. Please find better solutions :) |
Please wait, found a bug that cause error when pressing hotkey after saving settings Edit: Fixed |
Sounds awesome, gonna check first before merging |
Caught 2 bugs and fixed
|
Please wait, don't merge yet. |
No worry, I'm still checking out the thing, and about that hotkeypoll, I think we can keep it as it is if there is no other solution for now Edit: About the time delay, are you trying to make it so that the app will capture simultaneously as the user is playing the game? |
Added the time delay for hotkey, which can be customized in settings
Yes |
The file looks good to me, I'm gonna merge it now Edit: That setting cache was smart xD, thanks for the contribution once again |