I had the code before, and it was 2 lines long, one line to open the command prompt, the second line hid the command prompt. That hidden command prompt would be used whenever the script needed a command prompt. I think DLL call or COM was involved.
Here is a test script (I know the loop is illogical, but it demonstrates the command window blip I'm trying to eliminate)
Code: Select all
#p::
{
FileSelectFile, MyFile ; Select a pdf file
loop, 5
{
clipboard := PdfToText(MyFile)
sleep, 2000
}
return
}
PdfToText(PdfPath) {
static XpdfPath := """" A_ScriptDir "\pdftotext.exe"""
objShell := ComObjCreate("WScript.Shell")
;--------- Building CmdString (look in the .txt docs incuded with xpdf):
; From the xpdf docs in [ScriptDir]\xpdfbin-win-3.04\doc\pdftotext.txt:
; SYNOPSIS
; pdftotext [options] [PDF-file [text-file]]
; ...
; If text-file is '-', the text is sent to stdout.
; Options (Example option. Look in the xpdf docs for more):
; -nopgbrk Don't insert page breaks (form feed characters) between pages.
;---------
CmdString := XpdfPath " -nopgbrk """ PdfPath """ -"
objExec := objShell.Exec(CmdString)
while, !objExec.StdOut.AtEndOfStream ; Wait for the program to finish
strStdOut := objExec.StdOut.ReadAll()
return strStdOut
}