|
#Persistent #include ../../ #include ./inc/inifile.aik #include ./inc/capture.aik #include ./inc/ftp.aik g_inifile = 屏幕監(jiān)控.ini ;; 配置文件 ifnotexist %g_inifile% { write_ini(g_inifile, "setting", "CaptureTime", "5000") ; 截屏間隔時間 write_ini(g_inifile, "setting", "FTPTime", "60000") ; 上傳間隔時間 write_ini(g_inifile, "setting", "PicDir", a_scriptdir) ; 臨時存放截屏圖像的目錄 write_ini(g_inifile, "setting", "DelAfterFTP", "0") ; 指定將上傳之后的圖像刪除(或移動到其他目錄) write_ini(g_inifile, "FTP", "server", "") ; FTP服務(wù)器 write_ini(g_inifile, "FTP", "port", "21") ; 端口 write_ini(g_inifile, "FTP", "name", "") ; 用戶名 ( 如果用戶名和密碼為空, 將會彈出登錄窗口 ) write_ini(g_inifile, "FTP", "password", "") ; 密碼 write_ini(g_inifile, "FTP", "remotePath", "") ; 遠(yuǎn)程目錄 msgbox 請先設(shè)置配置文件,再運行本程序! run %g_inifile% exitapp } ; 創(chuàng)建保存截圖的文件夾 IfNotExist, PrintScreen { FileCreateDir, PrintScreen } ; 創(chuàng)建FTP目標(biāo) IfNotExist, FTP { FileCreateDir, FTP } ; 按日期命名的FTP的子目錄, 將FTPd的日志和上傳完畢的圖片移動到此目錄 g_ftpLog = FTP/%a_yyyy%-%a_mm%-%a_dd% IfNotExist, %g_ftpLog% { FileCreateDir, %g_ftpLog% } ; 從配置文件中讀取配置 g_captureTime := read_ini(g_inifile, "setting", "CaptureTime", "5000") g_ftpTime := read_ini(g_inifile, "setting", "FTPTime", "60000") g_bDelAfterFTP := read_ini(g_inifile, "setting", "DelAfterFTP", "0") g_Server := read_ini(g_inifile, "FTP", "server", "") g_Port := read_ini(g_inifile, "FTP", "port", "21") g_remotePath := read_ini(g_inifile, "FTP", "remotePath", "") uName := read_ini(g_inifile, "FTP", "name", "") pWord := read_ini(g_inifile, "FTP", "password", "") ;; 如果密碼或賬號有一項為空,那么彈出對話框要求輸入賬號和密碼 ; 這里會彈出兩次輸入框, 在實際項目中, 最好寫個登陸框, 給用戶更好的體驗 if ( uName == "" || pWord == "" ) { InputBox, uName, Please input your username, Please input your username if(ErrorLevel) ; 用戶點擊取消則退出 { ExitApp } InputBox, pWord, Please input your password, Please input your password, HIDE if(ErrorLevel) ; 用戶點擊取消則退出程序 { ExitApp } } ; 其實還需要檢查一下其他配置是否正確, 這個只是演示程序, 故而假設(shè)其他配置都正確. ; 設(shè)置定時器 SetTimer 【定時截屏】, %g_captureTime% SetTimer 【定時上傳FTP】, %g_ftpTime% ; 定時截屏的定時器, 每隔一段時間(鼠標(biāo)/鍵盤空閑時), 截屏一次, 保存到PrintScreen目錄 【定時截屏】: if ( A_TimeIdlePhysical > g_captureTime ) { capfile = PrintScreen/%a_yyyy%%a_mm%%a_dd%%A_Hour%%A_Min%%A_Sec%.jpg CaptureScreen(0, False, capfile, 100) ; 截圖函數(shù) } return ; 定時將截屏的圖像上傳到FTP服務(wù)器 【定時上傳FTP】: if ( A_TimeIdlePhysical > g_ftpTime ) { FileList = Loop, PrintScreen/*.jpg FileList = %FileList%%A_LoopFileName%`n Sort, FileList ; Sort by date. Loop, parse, FileList, `n { if A_LoopField = ; 無效的文件名則跳過 continue ; 上傳一張圖像 file_to_upload = PrintScreen/%A_LoopField% hConnect:=FTP_Open( g_Server, g_Port, Username, Password ) FTP_PutFile( hConnect, file_to_upload, g_remotePath ) FTP_CloseSocket( hConnect ) FTP_Close( ) ; 刪除或移動已經(jīng)上傳的圖像文件 if g_bDelAfterFTP = 1 FileDelete %file_to_upload% else FileMove, %file_to_upload%, %g_ftpLog%/%A_LoopField% , 1 } } return |
|
|