java實現(xiàn)人工智能化屏幕監(jiān)控窗口
更新時間:2018年09月28日 11:48:10 作者:成兮
這篇文章主要為大家詳細介紹了java實現(xiàn)人工智能化屏幕監(jiān)控窗口,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了java實現(xiàn)人工智能化屏幕監(jiān)控窗口的具體代碼,供大家參考,具體內(nèi)容如下
具體代碼實現(xiàn)(含注釋)
public class Main{
public static void main(String[] args) throws Exception{
/* test code */
}
/**
*用于實時監(jiān)控屏幕的窗口
*@author chengxi
*@param void
*@return void
*/
public static void mvcontroll() throws Exception{
/* 建立一個監(jiān)控屏幕的窗口 */
JFrame frame = new JFrame("人工智能化屏幕監(jiān)控系統(tǒng)") ;
frame.setSize(600,600) ;
frame.setVisible(true) ;
/* 設置總是顯示在頂部 */
frame.setAlwaysOnTop(true) ;
/* 獲取默認的工具包 */
Toolkit tk = Toolkit.getDefaultToolkit() ;
/* 使用工具包獲取屏幕的大小,這是創(chuàng)建工具包的唯一作用 */
Dimension dm = tk.getScreenSize() ;
/* 創(chuàng)建圖像的顯示區(qū)域 */
JLabel imageLabel = new JLabel() ;
frame.add(imageLabel) ;
/* 創(chuàng)建一個機器人 */
Robot robot = new Robot() ;
/* 持續(xù)監(jiān)控屏幕 */
while(true) {
/* 創(chuàng)建用于顯示屏幕分享部分的區(qū)域,填入x/y/width/height
Rectangle rec = new Rectangle(frame.getWidth() , 0 , (int)dm.getWidth() - frame.getWidth() , (int)dm.getHeight()) ;
/* 根據(jù)屏幕分享的當前分享圖像創(chuàng)建一個圖像對象 */
BufferedImage bufimg = robot.createScreenCapture(rec)) ;
/* 實時顯示在圖像顯示區(qū)域中 */
imageLabel.setIcon(new ImageIcon(bufimg)) ;
}
}
/**
*打開指定的路徑
public static void midopenQQ(String path) throws Exception{
Desktop desktop = Desktop.getDesktop() ;
/* 打開指定的uri所指定的應用程序 */
desktop.open(new File(path)) ;
/* 創(chuàng)建一個機器人 */
Robot robot = new Robot() ;
/* 因為創(chuàng)建機器人需要時間,因此在后續(xù)操作之前需要進行延遲加載 */
robot.delay(2000) ;
/* 使用robot的mouseMove方法將鼠標的光標移動到指定的位置上,這里我設置的是QQ界面的登錄按鈕上面 */
robot.mouseMove(709,519) ;
/* 定義鼠標事件:按下 */
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK) ;
/* 定義鼠標事件:放開 */
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK) ;
/* 事件的延遲 */
robot.delay(300) ;
}
/**
*簡單的打開path指定的路徑所在的應用程序
*@author chengxi
*@param String path
*@return void
*/
public static void easyopenQQ(String path) throws Exception{
Desktop desktop = Desktop.getDesktop() ;
/* 打開指定的文件 */
desktop.open(new File(path)) ;
}
/**
*打開uri指定的網(wǎng)址
*@author chengxi
*@param String uri
*@return void
*/
public static void openBrowse(String uri) throws Exception{
/* 允許java程序使用在桌面上注冊了的所有應用程序 */
Desktop desktop = Desktop.getDesktop() ;
/* 使用默認的瀏覽器打開指定uri */
desktop.browse(new URI("http://www.baidu.com")) ;
}
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
SpringCloudStream中的消息分區(qū)數(shù)詳解
這篇文章主要介紹了SpringCloudStream中的消息分區(qū)數(shù),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-12-12
解決Spring Boot 多模塊注入訪問不到jar包中的Bean問題
這篇文章主要介紹了解決Spring Boot 多模塊注入訪問不到jar包中的Bean問題。具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-09-09
Spring事務Transaction配置的五種注入方式詳解
這篇文章主要介紹了Spring事務Transaction配置的五種注入方式詳解,具有一定的參考價值,感興趣的小伙伴們可以參考一下。2017-04-04
mybatis-plus動態(tài)數(shù)據(jù)源讀寫分離方式
在分布式項目開發(fā)中,動態(tài)數(shù)據(jù)源的配置與使用至關重要,通過創(chuàng)建DynamicDatasourceService,實現(xiàn)數(shù)據(jù)源的動態(tài)添加與調(diào)用,有效管理主從庫操作,減輕數(shù)據(jù)庫壓力,此外,通過配置類與@DS注解,實現(xiàn)了靈活的分庫查詢功能,為高效處理數(shù)據(jù)提供了強有力的支持2024-10-10
基于Java SSM框架實現(xiàn)簡易的評教系統(tǒng)
這篇文章主要介紹了通過Java SSM框架實現(xiàn)一個簡易的評教系統(tǒng)的示例代碼,文中的代碼講解詳細,感興趣的小伙伴可以了解一下2022-02-02

