1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. Message

Beiträge von Message

  • CSV Datei auslesen?

    • Message
    • 9. April 2010 um 08:56

    Hi. Ist es möglich mit Autoit eine CSV Datei auszulesen?

    Folgender Grundgedanke steht dahinter:
    In der CSV Datei steht immer an dritter Stelle (also Zahl1;Zahl2;Zahl3) ein bestimmter Wert. Dieser Wert muss ausgelesen werden und danach soll die CSV Datei dann umbenannt werden, also "$Datum-$Zahl3.csv" oder so ähnlich. Haut sowas hin? Wo kann ich dazu Informationen finden? Danke!

  • PDF Mailer 64Bit fähig machen

    • Message
    • 30. Juli 2009 um 11:44

    Hi. Ich habe folgendes Skript seit langem im Einsatz:

    Code
    $g_szVersion = 'PDF Mailer'
    If WinExists($g_szVersion) Then Exit; It's already running
    AutoItWinSetTitle($g_szVersion)
    
    
    Opt("RunErrorsFatal", 0)
    Opt("TrayAutoPause", 0)
    
    
    Global $Sender, $Recipient, $MailUser, $MailPass
    Global $Enable_Encryption = True
    If $CmdLine[0] > 0 Then
    	If StringInStr($CmdLine[1], "1") AND StringInStr($CmdLine[1], "2") Then Exit ;;can't run both at the same time!
    	If StringInStr($CmdLine[1], "1") Then
    		$Sender = 'xxx1@xxx.de'
    		$Recipient = 'xxx2@xxx.de'
    		$MailUser = 'xxx'
    		$MailPass = 'xxx'
    	ElseIf StringInStr($CmdLine[1], "2") Then
    		$Sender = 'xxx2@xxx.de'
    		$Recipient = 'xxx1@xxx.de'
    		$MailUser = 'xxx'
    		$MailPass = 'xxx'
    	ElseIf StringInStr($CmdLine[1], "/?") Then
    		MsgBox(32, $g_szVersion, "This program has two arguments, which must be in order." & @CRLF & _
    		"The first argument is country, which can either be 1or 2." & @CRLF & @CRLF & _
    		"The second argument is optional, controlling encryption." & @CRLF & _
    		"Passing noencrypt as the second argument will disable encryption")
    		Exit
    	Else
    		Exit
    	EndIf
    	If $CmdLine[0] > 1 Then
    		If StringInStr($CmdLine[2], "noencrypt") Then $Enable_Encryption = False
    	EndIf
    Else
    	Exit
    EndIf
    
    
    #region Configuration Settings
    Global Const $Blowfish_Password = 'xxx'
    
    
    Global Const $POP3Server = 'pop3.xxx.de'
    Global Const $SMTPServer = 'smtp.xxx.de'
    
    
    ;SendMail Configuration
    Global Const $SendMail = 'D:\scanner\scanner\sendmail'
    Global Const $PDF_Dir = 'D:\scanner\sendmail\Emails'
    
    
    ;GetMail Configuration
    Global Const $GetMail = 'D:\scanner\getmail'
    Global Const $source = 'D:\scanner\getmail\Emails' ; Location of encrypted PDF files
    Global Const $dest = 'D:\scanner\getmail\Emails\Archives' ; Location of decrypted PDF files
    Global Const $GSPrintDir = 'D:\scanner\Print\Ghostgum\gsview' ;Path to PDF Printer Program
    
    
    #endregion Configuration Settings
    
    
    #region Do Not Edit!!!!!
    
    
    #region GetMail Functions
    Func GetMail()
    	If Not FileExists($source) Then DirCreate($source)
    	If Not FileExists($dest) Then DirCreate($dest)
    	FileChangeDir($GetMail)
    
    
    	RunWait('getmail.exe -u ' & $MailUser & ' -pw ' & $MailPass & ' -s ' & $POP3Server & ' -xtract -delete', '', @SW_HIDE)
    	FileDelete('*.txt')
    	FileDelete('*.out')
    	FileMove('*.pdf', $source & '\*.pdf', 1)
    	Sleep(1000)
    
    
    	Local $file = FileFindFirstFile($source & '\*.pdf')
    	If $file = -1 Then Return 0
    	While 1
    		Local $pdffile = FileFindNextFile($file)
    		If @error Then ExitLoop
    		If $Enable_Encryption Then
    			RunWait('bfish.exe /I:"' & $source & '\' & $pdffile & '" /O:"' & $dest & '\' & $pdffile & '" /P:"' & $Blowfish_Password & '" /D /Q', "", @SW_HIDE)
    			If FileExists($dest & '\' & $pdffile) Then
    				;File successfully decrypted, print it!
    				Local $WorkingDir = @WorkingDir
    				FileChangeDir($GSPrintDir)
    				RunWait('gsprint.exe "' & $dest & '\' & $pdffile & '"', $GSPrintDir, @SW_HIDE)
    				FileChangeDir($WorkingDir)
    			EndIf
    		Else
    			FileMove($source & '\*.pdf', $dest & '\')
    			Local $WorkingDir = @WorkingDir
    			FileChangeDir($GSPrintDir)
    			RunWait('gsprint.exe "' & $dest & '\' & $pdffile & '"', $GSPrintDir, @SW_HIDE)
    			FileChangeDir($WorkingDir)
    		EndIf
    		While FileExists($source & '\' & $pdffile)
    			FileDelete($source & '\' & $pdffile) ;delete the encrypted version
    		WEnd
    	WEnd
    	FileClose($file)
    	Return 1
    EndFunc   ;==>GetMail
    #endregion
    
    
    #region SendMail Functions
    Func SendMail()
    	If Not FileExists($PDF_Dir) Then DirCreate($PDF_Dir)
    	If Not FileExists($PDF_Dir & '\Encrypted\') Then DirCreate($PDF_Dir & '\Encrypted\')
    	If Not FileExists($PDF_Dir & '\Archives\') Then DirCreate($PDF_Dir & '\Archives\')
    	If Not FileExists($PDF_Dir & '\*.pdf') Then Return 0
    
    
    	Local $PDFfiles[1]
    	FileChangeDir($SendMail)
    	Local $PDFHandle = FileFindFirstFile($PDF_Dir & '\*.pdf')
    	While 1
    		Local $file = FileFindNextFile($PDFHandle)
    		If $file <> '' Then
    			ReDim $PDFfiles[ (UBound($PDFfiles) + 1) ]
    			$PDFfiles[0] += 1
    			$PDFfiles[ (UBound($PDFfiles) - 1) ] = $file
    		Else
    			ExitLoop
    		EndIf
    	WEnd
    	FileClose($PDFHandle)
    
    
    	For $x = 1 To $PDFfiles[0]
    		If $Enable_Encryption = True Then
    			RunWait('bfish.exe /I:"' & $PDF_Dir & '\' & $PDFfiles[$x] & '" /O:"' & $PDF_Dir & '\Encrypted\' & $PDFfiles[$x] & '" /P:"' & $Blowfish_Password & '" /E /Q', "", @SW_HIDE)
    			FileSend($PDFfiles[$x], $PDF_Dir & '\Encrypted\' & $PDFfiles[$x])
    		Else
    			FileSend($PDFfiles[$x], $PDF_Dir & '\' & $PDFfiles[$x])
    		EndIf
    			FileMove($PDF_Dir & '\' & $PDFfiles[$x], $PDF_Dir & '\Archives\' & $PDFfiles[$x])
    			FileDelete($PDF_Dir & '\Encrypted\' & $PDFfiles[$x])
    	Next
    	Return 1
    EndFunc   ;==>SendMail
    
    
    Func FileSend($FileName, $Attachment)
    
    
    	Local $objMessage = ObjCreate('CDO.Message')
    	With $objMessage
    		.Subject = $FileName
    		.Sender = $Sender
    		.From = $Sender
    		.To = $Recipient
    		.TextBody = $FileName & ' is attached and encrypted.'
    		.AddAttachment ($Attachment)
    	EndWith
    
    
    	With $objMessage.Configuration.Fields
    		.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    		.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $SMTPServer
    		.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    		.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $MailUser
    		.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $MailPass
    		.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    		.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    		.Update
    	EndWith
    	$objMessage.Send
    	Return 1
    EndFunc   ;==>FileSend
    #endregion
    
    
    Func _ReduceMemoryUsage()
    	Local $ai_GetCurrentProcessId = DllCall('kernel32.dll', 'int', 'GetCurrentProcessId')
    	Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ai_GetCurrentProcessId[0])
    	Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
    	DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    	Return $ai_Return[0]
    EndFunc
    #endregion Do Not Edit
    
    
    While 1
    	If (@Hour >= 7) AND ((@HOUR & @MIN) <=1630) Then
    		GetMail()
    		Sleep(1000 * 15) ;;Wait for 15 seconds
    		SendMail()
    	EndIf
    	_ReduceMemoryUsage()
    	Sleep(1000 * 60 * 4.75) ;;Wait for 5 minutes
    WEnd
    Alles anzeigen

    Bis jetzt lief das Ganze auf einem Windows 2000 Betriebssystem, nun soll es auf einem 64 Bit Windows Vista laufen. Es funktioniert auch alles tadellos, die Dokumente werden verschickt und empfangen, aber nicht gedruckt. Ich vermute, dass es an dem GSViewer liegt. Davon habe ich nun auch die 64 Bit Version installiert, aber da diese neue Dateinamen hat, muss ich das Skript neu kompilieren. Genau da scheitert es schon bei Zeile 5, da die Ausdrücke anscheinend nicht richtig sind. Könnt ihr mir hier helfen? Theoretisch könnte das Skript auch radikal gekürzt werdenn, da sich Empfänger und Sender nun in einem Netzwerk befinden. Dann müsste die Datein ja nurnoch in einem Freigegebenen Ordner abgelegt werden und von dort aus gedruckt werden. Dann könnte man sich den Schritt des verschlüsselns und per Email versenden sparen. Aber ich hab keine Idee wie ich das umprogrammiere.

  • Array variable has incorrect number of subscripts...

    • Message
    • 29. März 2008 um 16:09

    Das wars leider nicht, jetzt passiert einfach garnichts. Allerdings startet das Programm immerhin schonmal ohne Fehlermeldung ;)

    Ich habe noch eine "alte" Version ausgegraben, die funktioniert. Nur leider sind da 2 Dinge nicht enthalten (nur von MO-Fr ausführen + die Laufwerksbuchstaben nach dem Argument wählen).

    Spoiler anzeigen
    Code
    $g_szVersion = 'PDF Mailer'
    If WinExists($g_szVersion) Then Exit; It's already running
    AutoItWinSetTitle($g_szVersion)
    
    
    Opt("RunErrorsFatal", 0)
    Opt("TrayAutoPause", 0)
    
    
    Global $Sender, $Recipient, $MailUser, $MailPass
    Global $Enable_Encryption = True
    If $CmdLine[0] > 0 Then
    If StringInStr($CmdLine[1], "deutschland") AND StringInStr($CmdLine[1], "polen") Then Exit ;;can't run both at the same time!
    If StringInStr($CmdLine[1], "deutschland") Then
    $Sender = 'x'
    $Recipient = 'x'
    $MailUser = 'x'
    $MailPass = 'x'
    ElseIf StringInStr($CmdLine[1], "polen") Then
    $Sender = 'x'
    $Recipient = 'x'
    $MailUser = 'x'
    $MailPass = 'x'
    ElseIf StringInStr($CmdLine[1], "/?") Then
    MsgBox(32, $g_szVersion, "This program has two arguments, which must be in order." & @CRLF & _
    "The first argument is country, which can either be deutschland or polen." & @CRLF & @CRLF & _
    "The second argument is optional, controlling encryption." & @CRLF & _
    "Passing noencrypt as the second argument will disable encryption")
    Exit
    Else
    Exit
    EndIf
    If $CmdLine[0] > 1 Then
    If StringInStr($CmdLine[2], "noencrypt") Then $Enable_Encryption = False
    EndIf
    Else
    Exit
    EndIf
    
    
    #region Configuration Settings
    Global Const $Blowfish_Password = 'x'
    
    
    Global Const $POP3Server = 'pop3.x'
    Global Const $SMTPServer = 'smtp.x'
    
    
    ;SendMail Configuration
    Global Const $SendMail = 'D:\scanner\scanner_de\sendmail'
    Global Const $PDF_Dir = 'D:\scanner\sendmail\Emails'
    
    
    ;GetMail Configuration
    Global Const $GetMail = 'D:\scanner\getmail'
    Global Const $source = 'D:\scanner\getmail\Emails' ; Location of encrypted PDF files
    Global Const $dest = 'D:\scanner\getmail\Emails\Archives' ; Location of decrypted PDF files
    Global Const $GSPrintDir = 'D:\scanner\Print\Ghostgum\gsview' ;Path to PDF Printer Program
    
    
    #endregion Configuration Settings
    
    
    #region Do Not Edit!!!!!
    
    
    #region GetMail Functions
    Func GetMail()
    If Not FileExists($source) Then DirCreate($source)
    If Not FileExists($dest) Then DirCreate($dest)
    FileChangeDir($GetMail)
    
    
    RunWait('getmail.exe -u ' & $MailUser & ' -pw ' & $MailPass & ' -s ' & $POP3Server & ' -xtract -delete', '', @SW_HIDE)
    FileDelete('*.txt')
    FileDelete('*.out')
    FileMove('*.pdf', $source & '\*.pdf', 1)
    Sleep(1000)
    
    
    Local $file = FileFindFirstFile($source & '\*.pdf')
    If $file = -1 Then Return 0
    While 1
    Local $pdffile = FileFindNextFile($file)
    If @error Then ExitLoop
    If $Enable_Encryption Then
    RunWait('bfish.exe /I:"' & $source & '\' & $pdffile & '" /O:"' & $dest & '\' & $pdffile & '" /P:"' & $Blowfish_Password & '" /D /Q', "", @SW_HIDE)
    If FileExists($dest & '\' & $pdffile) Then
    ;File successfully decrypted, print it!
    Local $WorkingDir = @WorkingDir
    FileChangeDir($GSPrintDir)
    RunWait('gsprint.exe "' & $dest & '\' & $pdffile & '"', $GSPrintDir, @SW_HIDE)
    FileChangeDir($WorkingDir)
    EndIf
    Else
    FileMove($source & '\*.pdf', $dest & '\')
    Local $WorkingDir = @WorkingDir
    FileChangeDir($GSPrintDir)
    RunWait('gsprint.exe "' & $dest & '\' & $pdffile & '"', $GSPrintDir, @SW_HIDE)
    FileChangeDir($WorkingDir)
    EndIf
    While FileExists($source & '\' & $pdffile)
    FileDelete($source & '\' & $pdffile) ;delete the encrypted version
    WEnd
    WEnd
    FileClose($file)
    Return 1
    EndFunc   ;==>GetMail
    #endregion
    
    
    #region SendMail Functions
    Func SendMail()
    If Not FileExists($PDF_Dir) Then DirCreate($PDF_Dir)
    If Not FileExists($PDF_Dir & '\Encrypted\') Then DirCreate($PDF_Dir & '\Encrypted\')
    If Not FileExists($PDF_Dir & '\Archives\') Then DirCreate($PDF_Dir & '\Archives\')
    If Not FileExists($PDF_Dir & '\*.pdf') Then Return 0
    
    
    Local $PDFfiles[1]
    FileChangeDir($SendMail)
    Local $PDFHandle = FileFindFirstFile($PDF_Dir & '\*.pdf')
    While 1
    Local $file = FileFindNextFile($PDFHandle)
    If $file <> '' Then
    ReDim $PDFfiles[ (UBound($PDFfiles) + 1) ]
    $PDFfiles[0] += 1
    $PDFfiles[ (UBound($PDFfiles) - 1) ] = $file
    Else
    ExitLoop
    EndIf
    WEnd
    FileClose($PDFHandle)
    
    
    For $x = 1 To $PDFfiles[0]
    If $Enable_Encryption = True Then
    RunWait('bfish.exe /I:"' & $PDF_Dir & '\' & $PDFfiles[$x] & '" /O:"' & $PDF_Dir & '\Encrypted\' & $PDFfiles[$x] & '" /P:"' & $Blowfish_Password & '" /E /Q', "", @SW_HIDE)
    FileSend($PDFfiles[$x], $PDF_Dir & '\Encrypted\' & $PDFfiles[$x])
    Else
    FileSend($PDFfiles[$x], $PDF_Dir & '\' & $PDFfiles[$x])
    EndIf
    FileMove($PDF_Dir & '\' & $PDFfiles[$x], $PDF_Dir & '\Archives\' & $PDFfiles[$x])
    FileDelete($PDF_Dir & '\Encrypted\' & $PDFfiles[$x])
    Next
    Return 1
    EndFunc   ;==>SendMail
    
    
    Func FileSend($FileName, $Attachment)
    
    
    Local $objMessage = ObjCreate('CDO.Message')
    With $objMessage
    .Subject = $FileName
    .Sender = $Sender
    .From = $Sender
    .To = $Recipient
    .TextBody = $FileName & ' is attached and encrypted.'
    .AddAttachment ($Attachment)
    EndWith
    
    
    With $objMessage.Configuration.Fields
    .Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $SMTPServer
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    .Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $MailUser
    .Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $MailPass
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    .Update
    EndWith
    $objMessage.Send
    Return 1
    EndFunc   ;==>FileSend
    #endregion
    
    
    Func _ReduceMemoryUsage()
    Local $ai_GetCurrentProcessId = DllCall('kernel32.dll', 'int', 'GetCurrentProcessId')
    Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ai_GetCurrentProcessId[0])
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Return $ai_Return[0]
    EndFunc
    #endregion Do Not Edit
    
    
    While 1
    If (@Hour >= 7) AND ((@HOUR & @MIN) <=1630) Then
    GetMail()
    Sleep(1000 * 15) ;;Wait for 15 seconds
    SendMail()
    EndIf
    _ReduceMemoryUsage()
    Sleep(1000 * 60 * 4.75) ;;Wait for 5 minutes
    WEnd
    Alles anzeigen

    Habe schon versucht wie beim ersten Skript einfach "If ((@WDAY > 1) AND (@WDAY < 6)) Then" einzufügen, nur kommt dann leider wieder eine Fehlermeldung.
    Gibts eigentlich mittlerweile ein "sichereres" Tool welches sich per Autoit ansteuern lässt als diese bfish.exe? undefinedundefinedundefinedundefined

  • Array variable has incorrect number of subscripts...

    • Message
    • 27. März 2008 um 15:04

    Also meinst du so?


    Spoiler anzeigen
    [autoit]

    $g_szVersion = 'PDF Mailer'
    If WinExists($g_szVersion) Then Exit; It's already running
    AutoItWinSetTitle($g_szVersion)
    opt("RunErrorsFatal", 0)
    opt("TrayAutoPause", 0)
    Global $Sender, $Recipient, $MailUser, $MailPass
    Global $Enable_Encryption = True
    Global $Drive
    If $CmdLine[0] > 0 Then
    If StringInStr($CmdLine[1], "deutschland") And StringInStr($CmdLine[1], "polen") Then Exit ;;can't run both at the same time!
    If StringInStr($CmdLine[1], "deutschland") Then
    $Sender = '1@sender.com'
    $Recipient = '2@sender.com'
    $MailUser = 'x'
    $MailPass = 'x'
    $Drive = 'C:'
    ElseIf StringInStr($CmdLine[1], "polen") Then
    $Sender = '2@sender.com'
    $Recipient = '1@sender.com'
    $MailUser = 'x'
    $MailPass = 'x'
    $Drive = 'D:'
    ElseIf StringInStr($CmdLine[1], "/?") Then
    MsgBox(32, $g_szVersion, "This program has two arguments, which must be in order." & @CRLF & _
    "The first argument is country, which can either be deutschland or polen." & @CRLF & @CRLF & _
    "The second argument is optional, controlling encryption." & @CRLF & _
    "Passing noencrypt as the second argument will disable encryption")
    Exit
    Else
    Exit
    EndIf
    If $CmdLine[0] > 1 Then
    If StringInStr($CmdLine[2], "noencrypt") Then $Enable_Encryption = False
    EndIf
    Else
    Exit
    EndIf
    #region Configuration Settings
    Global Const $Blowfish_Password = 'passwort'
    Global Const $POP3Server = 'pop3.sender.com'
    Global Const $SMTPServer = 'smtp.sender.com'
    ;SendMail Configuration
    Global Const $SendMail = $Drive & '\scanner\sendmail'
    Global Const $PDF_Dir = $Drive & '\scanner\sendmail\Emails'
    ;GetMail Configuration
    Global Const $GetMail = $Drive & '\scanner\getmail'
    Global Const $source = $Drive & '\scanner\getmail\Emails' ; Location of encrypted PDF files
    Global Const $dest = $Drive & '\scanner\getmail\Emails\Archives' ; Location of decrypted PDF files
    Global Const $GSPrintDir = $Drive & '\scanner\Print\Ghostgum\gsview' ;Path to PDF Printer Program
    #endregion Configuration Settings
    #region Do Not Edit!!!!!
    #region GetMail Functions
    Func GetMail()
    Local $Files[1][1]
    If Not FileExists($source) Then DirCreate($source)
    If Not FileExists($dest) Then DirCreate($dest)
    FileChangeDir($GetMail)
    RunWait('getmail.exe -u ' & $MailUser & ' -pw ' & $MailPass & ' -s ' & $POP3Server & ' -xtract -delete', '', @SW_HIDE)
    ;FileDelete('*.txt')
    FileDelete('*.out')
    FileMove('*.pdf', $source & '\*.pdf', 1)
    FileMove('MSG*.txt', $source & '\MSG*.pdf', 1)
    Sleep(1000)
    Local $file = FileFindFirstFile($source & '\*.pdf')
    If $file = -1 Then Return 0
    While 1
    Local $pdffile = FileFindNextFile($file)
    If @error Then ExitLoop
    ReDim $Files[UBound($Files) + 1][2]
    $Files[UBound($Files) - 1][0] = $pdffile
    WEnd
    FileClose($file)
    Local $file = FileFindFirstFile($source & '\MSG*.txt')
    If $file = -1 Then Return 0
    While 1
    Local $txtfile = FileFindNextFile($file)
    If @error Then ExitLoop
    Local $fHandle, $fLine, $fMD5, $fName
    $fHandle = FileOpen($txtfile, 0)
    While 1
    $fLine = FileReadLine($fHandle)
    If @error = -1 Then ExitLoop
    If StringInStr($fLine, "Subject: ") Then
    $fMD5 = StringRight($fLine, StringLen($fLine) - 9)
    EndIf
    If StringInStr($fLine, "Content-Type: application/pdf;") Then
    $fLine = FileReadLine($fHandle)
    $fName = StringRight($fLine, StringLen($fLine) - 7)
    $fName = StringLeft($fLine, StringLen($fName) - 1)
    ExitLoop
    EndIf
    WEnd
    FileClose($fHandle)
    FileDelete($txtfile)
    For $iCurrentPos = 0 To UBound($Files) - 1
    If ($Files[$iCurrentPos][0] = $fName) Then $Files[$iCurrentPos][1] = $fMD5
    Next
    WEnd
    FileClose($file)
    For $x = 0 To UBound($Files) - 1
    If $Enable_Encryption Then
    RunWait('bfish.exe /I:"' & $source & '\' & $Files[$x][0] & '" /O:"' & $dest & '\' & $Files[$x][0] & '" /P:"' & $Blowfish_Password & '" /D /Q', "", @SW_HIDE)
    If FileExists($dest & '\' & $Files[$x][0]) Then
    ;File successfully decrypted, print it!
    ;If (FileMD5($dest & '\' $Files[$x][0]) = $Files[$x][1]) Then
    Local $WorkingDir = @WorkingDir
    FileChangeDir($GSPrintDir)
    RunWait('gsprint.exe "' & $dest & '\' & $Files[$x][0] & '"', $GSPrintDir, @SW_HIDE)
    FileChangeDir($WorkingDir)
    ;Else
    ;Send Error Log Entry
    ;EndIf
    EndIf
    Else
    FileMove($source & '\' & $Files[$x][0], $dest & '\')
    ;If (FileMD5($dest & '\' & $Files[$x][0]) = $Files[$x][1]) Then
    Local $WorkingDir = @WorkingDir
    FileChangeDir($GSPrintDir)
    RunWait('gsprint.exe "' & $dest & '\' & $Files[$x][0] & '"', $GSPrintDir, @SW_HIDE)
    FileChangeDir($WorkingDir)
    ;Else
    ;Send Error Log Entry
    ;EndIf
    EndIf
    FileDelete($source & '\' & $Files[$x][0]) ;delete the encrypted version
    Next
    Return 1
    EndFunc ;==>GetMail
    #endregion
    #region SendMail Functions
    Func SendMail()
    If Not FileExists($PDF_Dir) Then DirCreate($PDF_Dir)
    If Not FileExists($PDF_Dir & '\Encrypted\') Then DirCreate($PDF_Dir & '\Encrypted\')
    If Not FileExists($PDF_Dir & '\Archives\') Then DirCreate($PDF_Dir & '\Archives\')
    If Not FileExists($PDF_Dir & '\*.pdf') Then Return 0
    Local $PDFfiles[1][2]
    FileChangeDir($SendMail)
    Local $PDFHandle = FileFindFirstFile($PDF_Dir & '\*.pdf')
    While 1
    Local $file = FileFindNextFile($PDFHandle)
    If $file <> '' Then
    ReDim $PDFfiles[ (UBound($PDFfiles) + 1) ][2]
    $PDFfiles[0][0] += 1
    $PDFfiles[ (UBound($PDFfiles) - 1) ][0] = $file
    ;$PDFfiles[ (UBound($PDFfiles) - 1) ][1] = FileMD5($file)
    $PDFfiles[(UBound($PDFfiles) - 1 ][1] = ''
    Else
    ExitLoop
    EndIf
    WEnd
    FileClose($PDFHandle)
    For $x = 1 To $PDFfiles[0][0]
    If $Enable_Encryption = True Then
    RunWait('bfish.exe /I:"' & $PDF_Dir & '\' & $PDFfiles[$x][0] & '" /O:"' & $PDF_Dir & '\Encrypted\' & $PDFfiles[$x][0] & '" /P:"' & $Blowfish_Password & '" /E /Q', "", @SW_HIDE)
    FileSend($PDFfiles[$x][0], $PDFfiles[$x][1], $PDF_Dir & '\Encrypted\' & $PDFfiles[$x][0])
    Else
    FileSend($PDFfiles[$x][0], $PDFfiles[$x][1], $PDF_Dir & '\' & $PDFfiles[$x][0])
    EndIf
    FileMove($PDF_Dir & '\' & $PDFfiles[$x][0], $PDF_Dir & '\Archives\' & $PDFfiles[$x][0])
    FileDelete($PDF_Dir & '\Encrypted\' & $PDFfiles[$x][0])
    Next
    Return 1
    EndFunc ;==>SendMail
    Func FileSend($FileName, $MD5Val, $Attachment)
    Local $objMessage = ObjCreate('CDO.Message')
    With $objMessage
    .Subject = $MD5Val
    .Sender = $Sender
    .From = $Sender
    .To = $Recipient
    .TextBody = ''
    .AddAttachment ($Attachment)
    EndWith
    With $objMessage.Configuration.Fields
    .Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $SMTPServer
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    .Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $MailUser
    .Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $MailPass
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    .Update
    EndWith
    $objMessage.Send
    Return 1
    EndFunc ;==>FileSend
    #endregion
    Func ReduceMemoryUsage()
    Local $ai_GetCurrentProcessId = DllCall('kernel32.dll', 'int', 'GetCurrentProcessId')
    Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ai_GetCurrentProcessId[0])
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Return $ai_Return[0]
    EndFunc ;==>_ReduceMemoryUsage
    #endregion Do Not Edit
    ReduceMemoryUsage()
    While 1
    If ((@WDAY > 1) AND (@WDAY < 6)) Then
    If (@Hour >= 7) AND ((@HOUR & @MIN) <= 1630) Then
    GetMail()
    Sleep(1000 * 15) ;;Wait for 15 seconds
    SendMail()
    ReduceMemoryUsage()
    Sleep(1000 * 60 * 4.75) ;;Wait for 5 minutes
    EndIf
    Else
    Sleep(1000 * 60 * 60) ;Sleep for 1 hour if not
    EndIf
    WEnd

    [/autoit]

    Nur Zeile 142 ändern? Dann kommt noch der selbe Fehler.

    Edit Mega: Spoiler und Autoit Tags

  • Array variable has incorrect number of subscripts...

    • Message
    • 26. März 2008 um 15:39

    Danke für deine Antwort Xenobiologist, nur wie spreche ich das Redim denn mit 1D an? Habe das Skript nicht selbst geschrieben und kenne mich auch mit Autoit nicht so furchtbar gut aus. Nur der der das Skript geschrieben hat ist leider nicht mehr erreichbar. Wäre nett wenn du mir da helfen könntest.

  • Array variable has incorrect number of subscripts...

    • Message
    • 19. März 2008 um 11:18

    Hi. Habe ein "kleines" Problem mit dem folgenden Skript. Wurde mal geschrieben um Datein aus einem Ordner zu verschlüsseln, per Mail zu senden, wieder zu entschlüsseln und zu drucken. Jetzt muss ich eigentlich nur den Mailserver ändern, bekomme aber beim kompilieren immer folgende Fehlermeldung:

    Zitat

    Line 0 (File "C:\scanner\get-sendmail-de.v2.exe")

    $PDFfiles[0][0]+=1
    ^ERROR

    Error: Array variable hast incorrect number of subscripts or subscript dimension range exceeded

    Hier der Programmcode:

    Spoiler anzeigen
    [autoit]

    $g_szVersion = 'PDF Mailer'
    If WinExists($g_szVersion) Then Exit; It's already running
    AutoItWinSetTitle($g_szVersion)
    opt("RunErrorsFatal", 0)
    opt("TrayAutoPause", 0)
    Global $Sender, $Recipient, $MailUser, $MailPass
    Global $Enable_Encryption = True
    Global $Drive
    If $CmdLine[0] > 0 Then
    If StringInStr($CmdLine[1], "deutschland") And StringInStr($CmdLine[1], "polen") Then Exit ;;can't run both at the same time!
    If StringInStr($CmdLine[1], "deutschland") Then
    $Sender = '1@sender.com'
    $Recipient = '2@sender.com'
    $MailUser = 'x'
    $MailPass = 'x'
    $Drive = 'C:'
    ElseIf StringInStr($CmdLine[1], "polen") Then
    $Sender = '2@sender.com'
    $Recipient = '1@sender.com'
    $MailUser = 'x'
    $MailPass = 'x'
    $Drive = 'D:'
    ElseIf StringInStr($CmdLine[1], "/?") Then
    MsgBox(32, $g_szVersion, "This program has two arguments, which must be in order." & @CRLF & _
    "The first argument is country, which can either be deutschland or polen." & @CRLF & @CRLF & _
    "The second argument is optional, controlling encryption." & @CRLF & _
    "Passing noencrypt as the second argument will disable encryption")
    Exit
    Else
    Exit
    EndIf
    If $CmdLine[0] > 1 Then
    If StringInStr($CmdLine[2], "noencrypt") Then $Enable_Encryption = False
    EndIf
    Else
    Exit
    EndIf
    #region Configuration Settings
    Global Const $Blowfish_Password = 'passwort'
    Global Const $POP3Server = 'pop3.sender.com'
    Global Const $SMTPServer = 'smtp.sender.com'
    ;SendMail Configuration
    Global Const $SendMail = $Drive & '\scanner\sendmail'
    Global Const $PDF_Dir = $Drive & '\scanner\sendmail\Emails'
    ;GetMail Configuration
    Global Const $GetMail = $Drive & '\scanner\getmail'
    Global Const $source = $Drive & '\scanner\getmail\Emails' ; Location of encrypted PDF files
    Global Const $dest = $Drive & '\scanner\getmail\Emails\Archives' ; Location of decrypted PDF files
    Global Const $GSPrintDir = $Drive & '\scanner\Print\Ghostgum\gsview' ;Path to PDF Printer Program
    #endregion Configuration Settings
    #region Do Not Edit!!!!!
    #region GetMail Functions
    Func GetMail()
    Local $Files[1][1]
    If Not FileExists($source) Then DirCreate($source)
    If Not FileExists($dest) Then DirCreate($dest)
    FileChangeDir($GetMail)
    RunWait('getmail.exe -u ' & $MailUser & ' -pw ' & $MailPass & ' -s ' & $POP3Server & ' -xtract -delete', '', @SW_HIDE)
    ;FileDelete('*.txt')
    FileDelete('*.out')
    FileMove('*.pdf', $source & '\*.pdf', 1)
    FileMove('MSG*.txt', $source & '\MSG*.pdf', 1)
    Sleep(1000)
    Local $file = FileFindFirstFile($source & '\*.pdf')
    If $file = -1 Then Return 0
    While 1
    Local $pdffile = FileFindNextFile($file)
    If @error Then ExitLoop
    ReDim $Files[UBound($Files) + 1][2]
    $Files[UBound($Files) - 1][0] = $pdffile
    WEnd
    FileClose($file)
    Local $file = FileFindFirstFile($source & '\MSG*.txt')
    If $file = -1 Then Return 0
    While 1
    Local $txtfile = FileFindNextFile($file)
    If @error Then ExitLoop
    Local $fHandle, $fLine, $fMD5, $fName
    $fHandle = FileOpen($txtfile, 0)
    While 1
    $fLine = FileReadLine($fHandle)
    If @error = -1 Then ExitLoop
    If StringInStr($fLine, "Subject: ") Then
    $fMD5 = StringRight($fLine, StringLen($fLine) - 9)
    EndIf
    If StringInStr($fLine, "Content-Type: application/pdf;") Then
    $fLine = FileReadLine($fHandle)
    $fName = StringRight($fLine, StringLen($fLine) - 7)
    $fName = StringLeft($fLine, StringLen($fName) - 1)
    ExitLoop
    EndIf
    WEnd
    FileClose($fHandle)
    FileDelete($txtfile)
    For $iCurrentPos = 0 To UBound($Files) - 1
    If ($Files[$iCurrentPos][0] = $fName) Then $Files[$iCurrentPos][1] = $fMD5
    Next
    WEnd
    FileClose($file)
    For $x = 0 To UBound($Files) - 1
    If $Enable_Encryption Then
    RunWait('bfish.exe /I:"' & $source & '\' & $Files[$x][0] & '" /O:"' & $dest & '\' & $Files[$x][0] & '" /P:"' & $Blowfish_Password & '" /D /Q', "", @SW_HIDE)
    If FileExists($dest & '\' & $Files[$x][0]) Then
    ;File successfully decrypted, print it!
    ;If (FileMD5($dest & '\' $Files[$x][0]) = $Files[$x][1]) Then
    Local $WorkingDir = @WorkingDir
    FileChangeDir($GSPrintDir)
    RunWait('gsprint.exe "' & $dest & '\' & $Files[$x][0] & '"', $GSPrintDir, @SW_HIDE)
    FileChangeDir($WorkingDir)
    ;Else
    ;Send Error Log Entry
    ;EndIf
    EndIf
    Else
    FileMove($source & '\' & $Files[$x][0], $dest & '\')
    ;If (FileMD5($dest & '\' & $Files[$x][0]) = $Files[$x][1]) Then
    Local $WorkingDir = @WorkingDir
    FileChangeDir($GSPrintDir)
    RunWait('gsprint.exe "' & $dest & '\' & $Files[$x][0] & '"', $GSPrintDir, @SW_HIDE)
    FileChangeDir($WorkingDir)
    ;Else
    ;Send Error Log Entry
    ;EndIf
    EndIf
    FileDelete($source & '\' & $Files[$x][0]) ;delete the encrypted version
    Next
    Return 1
    EndFunc ;==>GetMail
    #endregion
    #region SendMail Functions
    Func SendMail()
    If Not FileExists($PDF_Dir) Then DirCreate($PDF_Dir)
    If Not FileExists($PDF_Dir & '\Encrypted\') Then DirCreate($PDF_Dir & '\Encrypted\')
    If Not FileExists($PDF_Dir & '\Archives\') Then DirCreate($PDF_Dir & '\Archives\')
    If Not FileExists($PDF_Dir & '\*.pdf') Then Return 0
    Local $PDFfiles[1][2]
    FileChangeDir($SendMail)
    Local $PDFHandle = FileFindFirstFile($PDF_Dir & '\*.pdf')
    While 1
    Local $file = FileFindNextFile($PDFHandle)
    If $file <> '' Then
    ReDim $PDFfiles[ (UBound($PDFfiles) + 1) ]
    $PDFfiles[0][0] += 1
    $PDFfiles[ (UBound($PDFfiles) - 1) ][0] = $file
    ;$PDFfiles[ (UBound($PDFfiles) - 1) ][1] = FileMD5($file)
    $PDFfiles[(UBound($PDFfiles) - 1 ][1] = ''
    Else
    ExitLoop
    EndIf
    WEnd
    FileClose($PDFHandle)
    For $x = 1 To $PDFfiles[0][0]
    If $Enable_Encryption = True Then
    RunWait('bfish.exe /I:"' & $PDF_Dir & '\' & $PDFfiles[$x][0] & '" /O:"' & $PDF_Dir & '\Encrypted\' & $PDFfiles[$x][0] & '" /P:"' & $Blowfish_Password & '" /E /Q', "", @SW_HIDE)
    FileSend($PDFfiles[$x][0], $PDFfiles[$x][1], $PDF_Dir & '\Encrypted\' & $PDFfiles[$x][0])
    Else
    FileSend($PDFfiles[$x][0], $PDFfiles[$x][1], $PDF_Dir & '\' & $PDFfiles[$x][0])
    EndIf
    FileMove($PDF_Dir & '\' & $PDFfiles[$x][0], $PDF_Dir & '\Archives\' & $PDFfiles[$x][0])
    FileDelete($PDF_Dir & '\Encrypted\' & $PDFfiles[$x][0])
    Next
    Return 1
    EndFunc ;==>SendMail
    Func FileSend($FileName, $MD5Val, $Attachment)
    Local $objMessage = ObjCreate('CDO.Message')
    With $objMessage
    .Subject = $MD5Val
    .Sender = $Sender
    .From = $Sender
    .To = $Recipient
    .TextBody = ''
    .AddAttachment ($Attachment)
    EndWith
    With $objMessage.Configuration.Fields
    .Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $SMTPServer
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    .Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $MailUser
    .Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $MailPass
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    .Update
    EndWith
    $objMessage.Send
    Return 1
    EndFunc ;==>FileSend
    #endregion
    Func ReduceMemoryUsage()
    Local $ai_GetCurrentProcessId = DllCall('kernel32.dll', 'int', 'GetCurrentProcessId')
    Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ai_GetCurrentProcessId[0])
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Return $ai_Return[0]
    EndFunc ;==>_ReduceMemoryUsage
    #endregion Do Not Edit
    ReduceMemoryUsage()
    While 1
    If ((@WDAY > 1) AND (@WDAY < 6)) Then
    If (@Hour >= 7) AND ((@HOUR & @MIN) <= 1630) Then
    GetMail()
    Sleep(1000 * 15) ;;Wait for 15 seconds
    SendMail()
    ReduceMemoryUsage()
    Sleep(1000 * 60 * 4.75) ;;Wait for 5 minutes
    EndIf
    Else
    Sleep(1000 * 60 * 60) ;Sleep for 1 hour if not
    EndIf
    WEnd

    [/autoit]

    Steigt da Jemand durch und kann mir sagen was falsch ist?

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™