eltos / PasteIntoFile

Paste clipboard data into files and copy file contents directly via hotkey or context menu
MIT License
84 stars 6 forks source link

Hotkey not working for hungarian keyboard on Windows 11 #14

Closed SZLMCL closed 1 year ago

SZLMCL commented 1 year ago

Hello,

Unfortunatelly in my case the hotkey WIN+ALT+V is not working, nothing happen when I press the hotkey.

I found an another global keypress catch method here: https://stackoverflow.com/questions/2450373/set-global-hotkeys-using-c-sharp (Lumo -s answer)

This works well in debug mode.

Can I replace the hotkey to another hotkey? For example CTRL+Y ? It would be very good when I can change the hotkey from the config (settings) file.

Thank you very much!

eltos commented 1 year ago

Unfortunatelly in my case the hotkey WIN+ALT+V is not working, nothing happen when I press the hotkey.

Are you sure you are using tray mode, i.e. restarted your PC? What version are you using; are both, the latest 4. and 5. affected? What Windows version do you have? Is there any other app using global hotkeys or even that same hotkey?

I found an another global keypress catch method here: https://stackoverflow.com/questions/2450373/set-global-hotkeys-using-c-sharp (Lumo -s answer)

This works well in debug mode.

What do you mean with "this works well in debug mode"? The code I use is taken from the same stack overflow question (AaronLS answer), so it's the same thing.

Can I replace the hotkey to another hotkey? For example CTRL+Y ? It would be very good when I can change the hotkey from the config (settings) file.

The hotkey is hardcoded and currently not changeable. You can change it here and recompile. If a config option should be added is debatable: The advantage is of course allowing users to easily use one of their preference. However this will probably not solve your issue if the hotkey is not recognised at all. On the other hand a global hotkey must be chosen wisely, because it must not conflict with hotkeys used by other programs (CTRL-Y is a bad choice as it is the "redo" action of windows explorer). In addition, it must be usable with and without the CTRL and SHIFT modifiers used to toggle automode and subdirectory mode. Under these constraints, there is not much left except the WIN-ALT-? option. What is your opinion on this?

SZLMCL commented 1 year ago

Thank you for fast reply! Yes, it is run in tray mode. After restart, the hotkey not working in my case.

I use version 5.0.2 and latest version of Windows 11 (hungarian).

Oh sorry, I not analyze your keypress solution deeply. I download the source code and insert the keypress code (Lumo) and that works in VS in debug mode.

About hotkey: My opinion is not problem if there a default hotkey (WIN+ALT+V) but the user can change in config when will. In my opinion pressing the WIN+ALT+V is not "comfortable". Different languages ​​have different keyboard layouts, for example in a hungarian keyboard CTRL+Í would be the best, because it is near to the "V" char (I think this is not used by another app). With the config hotkey option every user can find the best hotkey in his language and if it is not working (because it is used by another app) it can be changed easily again. In Lumo's answer the hotkey is a string, so it could be easily add to C# config file.

I changed the hotkey subscription in your code (as you linked above), but the hotkey is not catched. I not analyze why Lumo's answer works, and the build-in solution why not.

With this code I can catch the keypress (hotkey is an example only):

GlobalHotKey.RegisterHotKey("Control + Y", () => { MessageBox.Show("Pressed"); });

My final goal is: press the hotkey in any folder and insert the image from clipboard to file without opening the form. Thank you!

SZLMCL commented 1 year ago

I tested a little more with a Windows 10 virtual machine too:

What do you mean: it is possible to assign a shortcut for the context menu item in the registry? I not find solution for this yet, but that would be the perfect solution I think.

eltos commented 1 year ago

That is interesting, Lumo writes he took AaronLS code and only re-wrote it. Obviously, he did something more. Maybe you can quickly confirm that it is not in any way related to VS debugging, but also works for you in the usual tray mode after restart? If that is positive, could you prepare a PR with the changes? Basically replacing the code in KeyboardHook.cs and update the calling function to use strings as you describe? For the moment, stick to the WIN+ALT+V and confirm that all combinations of the modifiers as mentioned above work on Win 11. Unfortunately, I can't do it because I don't have a Win11 machine to test with.

After you submit the PR with the fix for Win 11, we can add a config option in a second step to allow changing the key.