1414package org .eclipse .swt .tests .win32 ;
1515
1616import org .eclipse .swt .SWT ;
17+ import org .eclipse .swt .internal .win32 .INPUT ;
18+ import org .eclipse .swt .internal .win32 .MOUSEINPUT ;
1719import org .eclipse .swt .internal .win32 .OS ;
1820import org .eclipse .swt .widgets .Event ;
1921import org .junit .jupiter .api .Disabled ;
@@ -79,6 +81,21 @@ private boolean isSystemHotkey(int state, UsScan scanCode) {
7981 return true ;
8082 }
8183 break ;
84+ case PrtScr :
85+ switch (state ) {
86+ case ____ :
87+ case ___S :
88+ case __C_ :
89+ case A___ :
90+ case AG__ :
91+ case __CS :
92+ case A__S :
93+ case AG_S :
94+ case A_C_ :
95+ case A_CS :
96+ case AGCS :
97+ return true ;
98+ }
8299 case _0 :
83100 if (state == __CS ) {
84101 // Windows bug. Ctrl+Shift+0 is assigned to switch to Japanese layout,
@@ -235,6 +252,8 @@ public void testEnglishUs_stdKeys() {
235252 new KeyDescription (UsScan .F9 , SWT .F9 , '\0' , '\0' ),
236253 new KeyDescription (UsScan .F10 , SWT .F10 , '\0' , '\0' ),
237254 new KeyDescription (UsScan .PrtScr , SWT .PRINT_SCREEN ,'\0' , '\0' ),
255+ // The repeated Esc here is necessary to ensure that the snipping tool started with PtrScr is closed again
256+ // new KeyDescription(UsScan.Esc, SWT.ESC, SWT.ESC, SWT.ESC),
238257 new KeyDescription (UsScan .Oem102 , '\\' , '\\' , '|' ),
239258 new KeyDescription (UsScan .F11 , SWT .F11 , '\0' , '\0' ),
240259 new KeyDescription (UsScan .F12 , SWT .F12 , '\0' , '\0' ),
@@ -296,6 +315,21 @@ public void testEnglishUs_stdKeys() {
296315 () -> emulateScanCode (state , testKey .scanCode ),
297316 expectKeyUp (state , expectedChar , 0 , testKey .keyCode )
298317 );
318+
319+ // for (int i = 0; i < 20; i++) {
320+ // processEvents();
321+ // try {
322+ // Thread.sleep(50);
323+ // } catch (InterruptedException e) {
324+ // // TODO Auto-generated catch block
325+ // e.printStackTrace();
326+ // }
327+ // }
328+
329+ // Snipping tool may open now, so click somewhere to close it and reactive the test shell
330+ // emulateMouseClick();
331+ // shell.forceActive();
332+ // shell.forceFocus();
299333 continue ;
300334 }
301335
@@ -313,6 +347,16 @@ public void testEnglishUs_stdKeys() {
313347 });
314348 }
315349
350+ private void emulateMouseClick () {
351+ MOUSEINPUT mouseinput = new MOUSEINPUT ();
352+ mouseinput .dwFlags = OS .MOUSEEVENTF_LEFTUP ;
353+ INPUT pInputs = new INPUT ();
354+ pInputs .type = OS .INPUT_MOUSE ;
355+ pInputs .mi = mouseinput ;
356+ OS .SendInput (1 , pInputs , INPUT .sizeof );
357+ processEvents ();
358+ }
359+
316360 /**
317361 * Extensive test for English US layout
318362 */
0 commit comments