To create a "shortcut key" for an inactive window, you must use the HotKeySet function to associate it. Instead, you cannot use GUISetAccelerators to associate the shortcut to the form or space.
1 $ Form1 = GUICreate ("AcceleratorDemo", 160, 60,-1,-1)
2 Opt ("GUICoordMode", 2)
3 $ Btn1 = GUICtrlCreateButton ("Button1", 30, 10)
4 $ Btn2 = GUICtrlCreateButton ("Button2", 0,-1)
5; Dim $ AccelKeys [2] [2] = [["{F9}", $ Btn1], ["a", $ Btn2];
6; GUISetAccelerators ($ AccelKeys)
7 GUISetState (@ SW_SHOW)
Because GUISetAccelerator can only quickly associate an activated form. If the form loses focus, the corresponding "Acceleration key" does not work. Use HotKeySet to directly bind the function to be called.
To understand the relationship between the "Accelerator key" and "hotkey", both are used to handle Keyboard Events and then processed by corresponding processing functions. However, they have different application scopes. The "Acceleration key" is associated with the application context, so it only works for the focused form. The "hotkey" is useful in the system.