java調用exe截圖程式實現延遲截圖

來源:互聯網
上載者:User

標籤:screen   退出   close   沒有   opera   operation   etl      err   

之前用Apple鍵盤,在windows系統上沒有快速全屏工具,無法截取下拉式功能表之類的點擊其他地方就會消失的圖片,

又不想寫那麼複雜,就使用java寫了簡單調用exe程式來實現延遲

 1 import javax.swing.*; 2 import java.awt.event.ActionEvent; 3 import java.awt.event.ActionListener; 4  5 /** 6  * Created by ycl on 2017/8/17 2017-8-17 22:33:59. 7  */ 8 public class CutScreen extends JFrame implements ActionListener { 9 10 11     JPanel jp;12     JLabel jlTime;13     JComboBox jcbTime;14     JButton jbTime;15 16     public CutScreen() {17         jp = new JPanel();18         this.setContentPane(jp);19         this.setTitle("延遲");20         this.setVisible(true);21         jp.setLayout(null);22         jlTime = new JLabel("Delay Time:");23         jlTime.setBounds(25, 15, 100, 30);24         jp.add(jlTime);25 26         String[] str = new String[]{"1", "2", "3", "5", "10"};27         jcbTime = new JComboBox(str);28         jcbTime.setBounds(110, 15, 100, 30);29         jp.add(jcbTime);30         jbTime = new JButton("Start");31         jbTime.addActionListener(this);32         jbTime.setBounds(220, 15, 70, 30);33         jp.add(jbTime);34 35         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);36         this.setBounds(600, 300, 325, 100);37     }38 39     @Override40     public void actionPerformed(ActionEvent e) {41         if (e.getSource() == jbTime) {42             String time = jcbTime.getSelectedItem().toString();43             try {44                 this.setExtendedState(JFrame.ICONIFIED);  //點擊後視窗最小化45                 Thread.sleep(Integer.parseInt(time) * 1000);46                 openExe();47                 System.exit(0);    //啟動exe程式後退出主程式48             } catch (InterruptedException e1) {49                 e1.printStackTrace();50             }51         }52     }53 54     //執行exe程式,也是網上copy的55     public static void openExe() {56         final Runtime runtime = Runtime.getRuntime();57         Process process = null;58 59         try {60             process = runtime.exec("D:\\Software\\tengxunjt.exe");61 62         } catch (final Exception e) {63             System.out.println("Error exec!");64         }65     }66 67     public static void main(String[] args) {68         new CutScreen();69     }70 }

 >>>:

 

java調用exe程式實現延遲

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.