我在热门的脚本上收到一条错误消息,按下prtscr然后自动发送电子邮件到我的Gmail。错误消息说明
C:\用户\ gto11 \桌面\ screenshot.au3" (53):==> " Func键"声明 没有匹配" EndFunc"。:Func _INETSMTPMAILCOM($ S_SMTPSERVER, $ S_FROMNAME,$ S_FROMADDRESS,$ S_TOADDRESS,$ S_SUBJECT ="",$ aS_BODY = "",$ S_ATTACHFILES ="",$ S_CCADDRESS ="",$ S_BCCADDRESS ="", $ s_Importance ="正常",$ S_USERNAME ="",$ S_PASSWORD ="",$ IPPort = 25,$ Ssl = 0)
退出代码:1时间:0.07399
以下是我提交的代码,我必须赞扬Varian在2010年发布此信息。链接https://www.autoitscript.com/forum/topic/119652-screen-shot-then-email/
此程序在执行时只能运行一次,但是当我尝试使用具有热键功能的开关案例时,会给出上述错误消息。
没有编译器或构建错误......似乎是运行时错误
#include <misc.au3>
; Capture full screen
; Fist parameter - filename, last - jpeg quality.
$Name = @DesktopDir & '\' & @MON & @MDAY & @YEAR & @HOUR & @MIN & @SEC & ".jpg"
DllCall("captdll.dll", "int:cdecl", "CaptureScreen", "str", @MON & @MDAY & @YEAR & @HOUR & @MIN & @SEC & ".jpg", "int", 20)
Global $g_bPaused = False
HotKeySet("{PAUSE}", "HotKeyPressed")
HotKeySet("{ESC}", "HotKeyPressed")
HotKeySet("+!d", "HotKeyPressed") ; Shift-Alt-d
HotKeySet("{PrtScr}", "HotKeyPressed")
While 1
Sleep(100)
WEnd
Func HotKeyPressed()
Switch @HotKeyPressed ; The last hotkey pressed.
Case "{PAUSE}" ; String is the {PAUSE} hotkey.
$g_bPaused = Not $g_bPaused
While $g_bPaused
Sleep(100)
ToolTip('Script is "Paused"', 0, 0)
WEnd
ToolTip("")
Case "{PrtScr}" ;
_INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $Ssl)
Case "{ESC}" ; String is the {ESC} hotkey.
Exit
Case "+!d" ; String is the Shift-Alt-d hotkey.
MsgBox($MB_SYSTEMMODAL, "", "This is a message.")
EndSwitch
EndFunc ;==>HotKeyPressed
Do
Sleep(10)
Until FileExists($Name)
;##################################
$SmtpServer = "smtp.gmail.com" ; address for the smtp-server to use - REQUIRED
$FromName = "Screen shot" ; name from who the email was sent
$FromAddress = "myself@gmail.com" ; address from where the mail should come
$ToAddress = "sender@gmail.com" ; destination address of the email - REQUIRED
$Subject = "this is from you" ; subject from the email - can be anything you want it to be
$Body = "here is your scrrenshot" ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = $Name ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
$CcAddress = "" ; address for cc - leave blank if not needed
$BccAddress = "" ; address for bcc - leave blank if not needed
$Importance = "High" ; Send message priority: "High", "Normal", "Low"
$Username = "sender@gmail.com" ; username for the account used from where the mail gets sent - REQUIRED
$Password = "passord" ; password for the account used from where the mail gets sent - REQUIRED
$IPPort = 465 ; port used for sending the mail
$ssl = 1 ; enables/disables secure socket layer sending - put to 1 if using httpS
;~ $IPPort=465 ; GMAIL port used for sending the mail
;~ $ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS
;##################################
Func _INETSMTPMAILCOM($S_SMTPSERVER, $S_FROMNAME, $S_FROMADDRESS, $S_TOADDRESS, $S_SUBJECT = "", $aS_BODY = "", $S_ATTACHFILES = "", $S_CCADDRESS = "", $S_BCCADDRESS = "", $s_Importance = "Normal", $S_USERNAME = "", $S_PASSWORD = "", $IPPort = 25, $Ssl = 0)
Global $oMYRET
$oBJEMAIL = ObjCreate("CDO.Message")
$oBJEMAIL.From = '"' & $S_FROMNAME & '" <' & $S_FROMADDRESS & ">"
$oBJEMAIL.To= $S_TOADDRESS
Local $I_ERROR = 0
Local $I_ERROR_DESCIPTION = ""
If $S_CCADDRESS <> "" Then $oBJEMAIL.Cc = $S_CCADDRESS
If $S_BCCADDRESS <> "" Then $oBJEMAIL.Bcc = $S_BCCADDRESS
$oBJEMAIL.Subject = $S_SUBJECT
If StringInStr($aS_BODY, "<") And StringInStr($aS_BODY, ">") Then
$oBJEMAIL.HTMLBody = $aS_BODY
Else
$oBJEMAIL.Textbody = $aS_BODY & @CRLF
EndIf
If $S_ATTACHFILES <> "" Then
Local $S_FILES2ATTACH = StringSplit($S_ATTACHFILES, ";")
For $x = 1 To $S_FILES2ATTACH[0]
$File = _PathSplitByRegExp($S_FILES2ATTACH[$x])
$S_FILES2ATTACH[$x] = $File[0]
If FileExists($S_FILES2ATTACH[$x]) Then
$oBJEMAIL.AddAttachment($S_FILES2ATTACH[$x])
Else
$I_ERROR_DESCIPTION = $I_ERROR_DESCIPTION & @LF & "File not found to attach: " & $S_FILES2ATTACH[$x]
SetError(1)
Return 0
EndIf
Next
EndIf
$oBJEMAIL.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
$oBJEMAIL.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $S_SMTPSERVER
$oBJEMAIL.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
If $S_USERNAME <> "" Then
$oBJEMAIL.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
$oBJEMAIL.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = $S_USERNAME
$oBJEMAIL.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $S_PASSWORD
EndIf
If $Ssl Then
$oBJEMAIL.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
EndIf
$oBJEMAIL.Configuration.Fields.Update
; Set email Importance
Switch $s_Importance
Case "High"
$oBJEMAIL.Fields.Item("urn:schemas:mailheader:Importance") = "High"
Case "Normal"
$oBJEMAIL.Fields.Item("urn:schemas:mailheader:Importance") = "Normal"
Case "Low"
$oBJEMAIL.Fields.Item("urn:schemas:mailheader:Importance") = "Low"
EndSwitch
$oBJEMAIL.Fields.Update
$oBJEMAIL.Send
If @error Then
SetError(2)
Return $oMYRET[1]
EndIf
EndFunc ;_inetsmtp
Func _PathSplitByRegExp($sPath)
If $sPath = "" Or (StringInStr($sPath, "\") And StringInStr($sPath, "/")) Then Return SetError(1, 0, -1)
Local $RetArray[8], $pDelim = ""
If StringRegExp($sPath, '^(?i)([A-Z]:|\\)(\\[^\\]+)+$') Then $pDelim = "\"
If StringRegExp($sPath, '(?i)(^.*:/)(/[^/]+)+$') Then $pDelim = "//"
If $pDelim = "" Then $pDelim = "/"
If Not StringInStr($sPath, $pDelim) Then Return $sPath
If $pDelim = "\" Then $pDelim &= "\"
$RetArray[0] = $sPath
$RetArray[1] = StringReplace($sPath, StringRegExpReplace($sPath, '(?i)([A-Z]:' & $pDelim & '|\\\\\w*|\\w*\\)', ''), "")
$RetArray[2] = StringRegExpReplace($sPath, $pDelim & '[^' & $pDelim & ']*$', '')
$RetArray[3] = StringRegExpReplace($sPath, '\.[^.]*$', '')
$RetArray[4] = StringRegExpReplace($sPath, '(?i)([A-Z]:' & $pDelim & '|\\\\\w*\\|\\w*\\)', '')
$RetArray[5] = StringRegExpReplace($sPath, '^.*' & $pDelim, '')
$RetArray[6] = StringRegExpReplace($RetArray[5], '\.[^.]*$', '')
$RetArray[7] = StringRegExpReplace($sPath, '^.*\.', '')
Return $RetArray
EndFunc ;==>_PathSplitByRegExp