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

Multiple improvements, view comment #2

Merged
merged 11 commits into from Sep 5, 2021

Conversation

laggykiller
Copy link
Contributor

  • 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

@laggykiller
Copy link
Contributor Author

laggykiller commented Sep 5, 2021

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 :)

@laggykiller
Copy link
Contributor Author

laggykiller commented Sep 5, 2021

Please wait, found a bug that cause error when pressing hotkey after saving settings

Edit: Fixed

@Dadangdut33
Copy link
Owner

Sounds awesome, gonna check first before merging

- fix crash if no hotkey set when saving settings
- caching setting when saving
@laggykiller
Copy link
Contributor Author

Caught 2 bugs and fixed

  • fix crash if no hotkey set when saving settings
  • caching setting when saving

@laggykiller
Copy link
Contributor Author

Please wait, don't merge yet.
To make the hotkey function useful, a time delay has to be implemented as text won't instantly appear in VN

@Dadangdut33
Copy link
Owner

Dadangdut33 commented Sep 5, 2021

Please wait, don't merge yet.
To make the hotkey function useful, a time delay has to be implemented as text won't instantly appear in VN

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?

@laggykiller
Copy link
Contributor Author

Added the time delay for hotkey, which can be customized in settings

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?

Yes

@Dadangdut33
Copy link
Owner

Dadangdut33 commented Sep 5, 2021

Yes
Great thinking bro these are some great improvements

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

@Dadangdut33 Dadangdut33 merged commit 98def63 into Dadangdut33:main Sep 5, 2021
Repository owner locked as resolved and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants