Hofknecht / SystemTrayMenu

SystemTrayMenu - Browse and open your files easily
http://hofknecht.eu/systemtraymenu/
GNU General Public License v3.0
642 stars 45 forks source link

[BUG] The program opens when the icons in the Start menu are rearranged #452

Open anemomylos opened 1 year ago

anemomylos commented 1 year ago

The SystemTrayMenu window opens, as when you left-click its icon in the systray. Note that this happens only once per Windows session. (not true, read this: https://github.com/Hofknecht/SystemTrayMenu/issues/452#issuecomment-1268210576)

I attach screenshots with the program configuration in case they may be helpful.

general advanced customize expert sizeandlocation

Hofknecht commented 1 year ago

@anemomylos Thank you for the feedback!

I thought it might be related to https://github.com/Hofknecht/SystemTrayMenu/issues/447 but i see 'Show in Taskbar' is disabled

on the first try now i couldn't reproduce it

maybe can you make a short video of the behavior e.g. with 'Apowersoft Free Screen Recorder'?

Does this also occure in windows 10?

anemomylos commented 1 year ago

Yes, sure, I will try to record the screen. I never noticed that in Windows 10. It's very strange that to reproduce it you have to reboot Windows because it doesn't do it again - only the first time that you rearrange an icon in Start menu it happens.

anemomylos commented 1 year ago

I never noticed that in Windows 10

Maybe it's because I didn't use the program in Windows 10. :)

I only found the program and started using it when I started using Windows 11 because MS decided to remove the "Desktop" toolbar from the task bar.

anemomylos commented 1 year ago

https://user-images.githubusercontent.com/46785941/193921053-b42ab366-a01f-4a24-b704-ab5705ed99be.mp4

anemomylos commented 1 year ago

I've noticed that changing the virtual desktop makes it possible to reproduce the above behavior without having to reboot Windows.

Hofknecht commented 1 year ago

tested in win 10 & win 11, can still not reproduce .... we will check again

anemomylos commented 1 year ago

Let me know if you want to create a test version that displays some debug message when the popup opens, indicating what kind of action caused it to open, so that I can test it on my system.

anemomylos commented 1 year ago

I noticed that when i choose as hotkey to open the program the combination Ctrl+Alt+L, the bug does not occur. Btw, don't use this combination since is the default Windows 11 combination for live captions.

If I set the default hotkey (Ctrl+Win) the program opens every time I change the virtual desktop of Windows using the default Windows combination (Ctrl+Win+Left/Right arrow).

When the hotkey field is cleared, the behavior is as I initially described.

Most likely the code to be reviewed is the one that handles the hotkey.

Hofknecht commented 1 year ago

Thanks, thats a great hint!

so workaround for now is to change hotkey to fix this case!

this is weird because we just register the hotkey, we don't do anything special with this hotkey. I won't be there at the weekend, but I'm considering writing a small test program next week that will show the error. For me it is just buggy that after registering the hotkey we are triggered even though the hotkey is not pressed in the situation. We've been using the Ctrl + LWin hotkey for a while and haven't seemed to have any side effects so far. Maybe there's nothing we can do about it except changing the hotkey default. but we'll see again next week

anemomylos commented 1 year ago

Can you point me to the code that handles the hotkey setting and the code that is executed once the hotkey is activated? I did a quick search to find them but with no luck.

Hofknecht commented 1 year ago

@anemomylos

Hey, yes sure

this is in RegisterHotKeys,cs private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint virtualKeyCode);

SystemTrayMenu.dll!SystemTrayMenu.DllImports.NativeMethods.User32RegisterHotKey(System.IntPtr hWnd, int id, uint fsModifiers, uint vk) Line 19  C#

SystemTrayMenu.dll!SystemTrayMenu.Helper.KeyboardHook.RegisterHotKey(uint modifier, System.Windows.Forms.Keys key) Line 117 C# SystemTrayMenu.dll!SystemTrayMenu.Helper.KeyboardHook.RegisterHotKey(SystemTrayMenu.Helper.KeyboardHookModifierKeys modifier, System.Windows.Forms.Keys key) Line 105 C# SystemTrayMenu.dll!SystemTrayMenu.Helper.KeyboardHook.RegisterHotKey() Line 92 C# SystemTrayMenu.dll!SystemTrayMenu.Handler.KeyboardInput.RegisterHotKey() Line 56 C# SystemTrayMenu.dll!SystemTrayMenu.Business.Menus.Menus() Line 66 C# SystemTrayMenu.dll!SystemTrayMenu.App.App() Line 21 C# SystemTrayMenu.dll!SystemTrayMenu.Program.Main(string[] args) Line 35 C#

2022-10-17 19_18_01-Window

here is also the callstack when pressing the hotkey

SystemTrayMenu.dll!SystemTrayMenu.Business.Menus.SwitchOpenClose(bool byClick, bool isMainPreload) Line 189 C# SystemTrayMenu.dll!SystemTrayMenu.Business.Menus.KeyboardInput_HotKeyPressed() Line 1184 C# SystemTrayMenu.dll!SystemTrayMenu.Handler.KeyboardInput.Hook_KeyPressed(object sender, SystemTrayMenu.Helper.KeyPressedEventArgs e) Line 228 C# SystemTrayMenu.dll!SystemTrayMenu.Helper.KeyboardHook.Window_KeyPressed(object sender, SystemTrayMenu.Helper.KeyPressedEventArgs e) Line 110 C# SystemTrayMenu.dll!SystemTrayMenu.Helper.KeyboardHook.Window.WndProc(ref System.Windows.Forms.Message m) Line 161 C#

Hofknecht commented 1 year ago

@anemomylos Maybe you can debug a bit -make a breakpoint at SwitchOpenClose and check if you have same stacktrace -comment out: content of method RegisterHotKey, rebuild and try if this solves the issue to verify it is really causing by hotkey. -maybe try if you find similar hotkeys which have the same issue, but i think you already said other ones do not have this problem.

Hofknecht commented 11 months ago

https://github.com/Hofknecht/SystemTrayMenu/issues/474 https://github.com/Hofknecht/SystemTrayMenu/issues/452 https://github.com/Hofknecht/SystemTrayMenu/issues/505 seems to be related