Shortcut key to clear console in Eclipse

前端 未结 6 1120
暗喜
暗喜 2021-02-02 08:34

What is the shortcut key to clear console in Eclipse or how can it be configured? Any work-arounds to achieve this?

6条回答
  •  孤独总比滥情好
    2021-02-02 09:27

    I found a solution for the wiping the console in an Eclipse IDE. It uses the Robot class. Please see code below and caption for explanation:

       import java.awt.AWTException;
       import java.awt.Robot;
       import java.awt.event.KeyEvent;
    
       public void wipeConsole() throws AWTException{
            Robot robbie = new Robot();
            //shows the Console View
            robbie.keyPress(KeyEvent.VK_ALT);
            robbie.keyPress(KeyEvent.VK_SHIFT);
            robbie.keyPress(KeyEvent.VK_Q);
            robbie.keyRelease(KeyEvent.VK_ALT);
            robbie.keyPress(KeyEvent.VK_SHIFT);
            robbie.keyPress(KeyEvent.VK_Q);
            robbie.keyPress(KeyEvent.VK_C);
            robbie.keyRelease(KeyEvent.VK_C);
    
            //clears the console
            robbie.keyPress(KeyEvent.VK_SHIFT);
            robbie.keyPress(KeyEvent.VK_F10);
            robbie.keyRelease(KeyEvent.VK_SHIFT);
            robbie.keyRelease(KeyEvent.VK_F10);
            robbie.keyPress(KeyEvent.VK_R);
            robbie.keyRelease(KeyEvent.VK_R);
        }
    

    Assuming you haven't changed the default hot key settings in Eclipse and import those java classes, this should work.

提交回复
热议问题