shell.exec verstecken

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

User avatar
LuckyJoe
Posts: 341
Joined: 02 Oct 2013, 09:52

shell.exec verstecken

25 Nov 2018, 09:28

Hallo zusammen,

ich bastel gerade an einem Script, mit dem ich die Metadaten aus einer PDF-Datei auslesen möchte. Dazu verwende ich das externe Tool "ExifTool". Das klappt auch schon ganz gut:

Code: Select all

#NoEnv
#SingleInstance force

ExifTool  = "c:\Program Files (x86)\!Grafik\ExifTool\exiftool.exe"
PDFCD     = -createdate
PDFMD     = -modifydate
FileCD    = -filecreatedate
FileMD    = -filemodifydate
MyTest    = -s -createdate -modifydate -filecreatedate -filemodifydate
PDFDatei   = "d:\xxx\Test3.pdf"

ProgrammMitParameter = % ExifTool " " MyTest " " PDFDatei

shell := ComObjCreate("WScript.Shell")
exec := shell.exec(ProgrammMitParameter)
Ergebnis := exec.StdOut.ReadAll()
MsgBox, % Ergebnis
... allerdings stört mich, dass das Shell-Fenster kurz aufflackert. Wie kann ich das unterdrücken?
Danke im Voraus für eure Hilfe

HG - Lucky Joe
Herzliche Grüße aus dem Rheinland
Lucky Joe
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: shell.exec verstecken

25 Nov 2018, 11:53

Code: Select all

#NoEnv
#SingleInstance Force

ExifTool  = "c:\Program Files (x86)\!Grafik\ExifTool\exiftool.exe"
PDFCD     = -createdate
PDFMD     = -modifydate
FileCD    = -filecreatedate
FileMD    = -filemodifydate
MyTest    = -s -createdate -modifydate -filecreatedate -filemodifydate
PDFDatei   = "d:\xxx\Test3.pdf"

ProgrammMitParameter := Format("cmd /c ""{} {}"" ""{}"" | clip", ExifTool, MyTest, PDFDatei) ; /C run->exit

shell := ComObjCreate("WScript.Shell")

clipSaved := ClipboardAll
Clipboard := ""

shell.Run(ProgrammMitParameter, 0, true) ; hidden, synchronous
ClipWait 1
Ergebnis := Clipboard
Clipboard := clipSaved

MsgBox, % Ergebnis
User avatar
LuckyJoe
Posts: 341
Joined: 02 Oct 2013, 09:52

Re: shell.exec verstecken

25 Nov 2018, 12:26

Hi swagfag,

Danke ersteinmal für deine Unterstützung; das CMD-Fenster poppt zwar nicht auf, ich bekomme aber nur eine leere Msgbox.

HG - Lucky Joe
Herzliche Grüße aus dem Rheinland
Lucky Joe
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: shell.exec verstecken

25 Nov 2018, 13:22

try this one. note the use of := (expressions) instead of = (traditional)

Code: Select all

exiftool := "D:\Downloads\exiftool-11.20\exiftool.exe"
args := "-s -createdate -modifydate -filecreatedate -filemodifydate"
pdf := "D:\Downloads\exiftool-11.20\test.pdf"

shell := ComObjCreate("WScript.Shell")

clipSaved := ClipboardAll
Clipboard := ""

SplitPath exiftool, exe, dir
cmd := Format("cmd /c cd /d ""{}"" & ""{}"" {} ""{}"" | clip", dir, exe, args, pdf)
shell.Run(cmd, 0, true) ; hidden, synchronous

ClipWait 1
Ergebnis := Clipboard
Clipboard := clipSaved

MsgBox, % Ergebnis
User avatar
LuckyJoe
Posts: 341
Joined: 02 Oct 2013, 09:52

Re: shell.exec verstecken

25 Nov 2018, 14:02

... yeah! ... That works fine - thanky you!
Herzliche Grüße aus dem Rheinland
Lucky Joe

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 62 guests