@@ -1102,14 +1102,22 @@ private void OpenRunAction()
11021102
11031103 var childWindow = new RunCommandChildWindow ( this ) ;
11041104
1105+ // A message of an application that was run with Ctrl+Enter (the dialog stays open, e.g. an error of the Ping
1106+ // Monitor) closes the dialog first, so the dialogs are not shown on top of each other.
1107+ void DialogHelper_DialogOpening ( object sender , EventArgs e ) => CloseDialog ( ) ;
1108+
11051109 void CloseDialog ( )
11061110 {
1111+ DialogHelper . DialogOpening -= DialogHelper_DialogOpening ;
1112+
11071113 childWindow . IsOpen = false ;
11081114 ConfigurationManager . Current . IsChildWindowOpen = false ;
11091115
11101116 ConfigurationManager . OnDialogClose ( ) ;
11111117 }
11121118
1119+ DialogHelper . DialogOpening += DialogHelper_DialogOpening ;
1120+
11131121 var childWindowViewModel = new RunCommandViewModel ( instance =>
11141122 {
11151123 // Ctrl+Enter: the dialog stays open to run another command.
@@ -1464,18 +1472,24 @@ private void UpdateOnWindowResize()
14641472 private void RegisterHotKeys ( )
14651473 {
14661474 if ( SettingsManager . Current . HotKey_ShowWindowEnabled )
1467- {
1468- RegisterHotKey ( new WindowInteropHelper ( this ) . Handle , 1 , SettingsManager . Current . HotKey_ShowWindowModifier ,
1475+ RegisterHotKey ( 1 , SettingsManager . Current . HotKey_ShowWindowModifier ,
14691476 SettingsManager . Current . HotKey_ShowWindowKey ) ;
1470- _registeredHotKeys . Add ( 1 ) ;
1471- }
14721477
14731478 if ( SettingsManager . Current . HotKey_RunCommandEnabled )
1474- {
1475- RegisterHotKey ( new WindowInteropHelper ( this ) . Handle , 2 , SettingsManager . Current . HotKey_RunCommandModifier ,
1479+ RegisterHotKey ( 2 , SettingsManager . Current . HotKey_RunCommandModifier ,
14761480 SettingsManager . Current . HotKey_RunCommandKey ) ;
1477- _registeredHotKeys . Add ( 2 ) ;
1478- }
1481+ }
1482+
1483+ /// <summary>
1484+ /// Registers a hotkey. It fails if the combination is already used (e.g. by the other hotkey or another
1485+ /// application), then it is logged and not unregistered later.
1486+ /// </summary>
1487+ private void RegisterHotKey ( int id , int modifier , int key )
1488+ {
1489+ if ( RegisterHotKey ( new WindowInteropHelper ( this ) . Handle , id , modifier , key ) )
1490+ _registeredHotKeys . Add ( id ) ;
1491+ else
1492+ Log . Warn ( $ "Hotkey { id } could not be registered, the key combination is already in use.") ;
14791493 }
14801494
14811495 private void UnregisterHotKeys ( )
0 commit comments