Announcement

Collapse
No announcement yet.

Close adobe

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Michael Mattias
    replied
    You could try...
    • Find the executable which opens files of extension 'PDF' (use FindExecutable() WInAPI function)
    • Execute with ShellExecuteEx or CreateProcess (print parameters) gives you process and thread handles
    • EnumThreadWindows on that process; if no parent it must be main window
    • Post a WM_CLOSE to that window.

    No promises, but it is worth a try to someone who "needs" to do this.

    Leave a comment:


  • Paul Franks
    replied
    FindWindowByTitle() is the wrong approach for this, since the title can change based on metadata in the PDF. Here's the correct approach, though you'll need to check for class "AcrobatSDIWindow" in addition to "AdobeAcrobat" for version 8 of Reader/Acrobat. Who knows if they will change the classname again in the upcoming version 9.

    http://www.powerbasic.com/support/pb...4&postcount=25

    Leave a comment:


  • Katherine Lepley
    replied
    Chris,

    Thank you for the code. I will look at it and see what I can do with it. I am still learning, but I enjoy the challenges! I'll let you know what I come up with!

    Leave a comment:


  • Chris Holbrook
    replied
    source code for app which kills Adobe Reader included

    OK. Here's some code by Ryan Mott which uses code by Eros Olmi which.. oh, never mind! The main thing is, it now compiles under PBWin 8.04 and kills one process whose title inlcudes "Adobe Reader". I'm sure you can adapt it.

    Code:
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "win32api.inc"
    
    ' The following functions were adapted from a post by
    ' Eros Olmi on the PowerBasic Forum (11/08/02)
    TYPE WinInfoType
        WinTitle AS STRING * 256
        WinHandle AS LONG
    END TYPE
    
    GLOBAL gWinList() AS WinInfoType
    GLOBAL gWinListPos AS LONG
    
    FUNCTION FindWindowByTitle(BYVAL lMethod AS STRING, BYVAL lTitle AS STRING) AS LONG
        DIM Count AS LONG
    
        gWinListPos = 0
        EnumWindows CODEPTR(EnumWindowsProc), 0
    
        lMethod = UCASE$(lMethod)
        lTitle = UCASE$(lTitle)
    
        FOR Count = 1 TO gWinListPos
            IF IsWindowVisible(gWinList(Count).WinHandle) = 1 THEN
                 IF INSTR(lMethod, "START WITH") THEN
                    IF UCASE$(LEFT$(gWinList(Count).WinTitle, LEN(lTitle))) = lTitle THEN
                        FUNCTION = gWinList(Count).WinHandle
                        EXIT FOR
                    END IF
                END IF
                 IF INSTR(lMethod, "CONTAIN") THEN
                    IF INSTR(UCASE$(gWinList(Count).WinTitle), lTitle) THEN
                        FUNCTION = gWinList(Count).WinHandle
                        EXIT FOR
                    END IF
                END IF
                 IF INSTR(lMethod, "END WITH") THEN
                    IF UCASE$(RIGHT$(gWinList(Count).WinTitle, LEN(lTitle))) = lTitle THEN
                        FUNCTION = gWinList(Count).WinHandle
                        EXIT FOR
                    END IF
                END IF
             END IF
        NEXT Count
    END FUNCTION
    
    FUNCTION EnumWindowsProc(BYVAL lHandle AS LONG, BYVAL lNotUsed AS LONG) AS LONG
        DIM wTitle AS STRING
        DIM lPos AS LONG
    
        wTitle = STRING$(256,0)
        GetWindowText lHandle, BYVAL STRPTR(wTitle), 256
        wTitle = EXTRACT$(wTitle, CHR$(0))
    
        IF LEN(wTitle) THEN
            INCR gWinListPos
            REDIM PRESERVE gWinList(gWinListPos)
            gWinList(gWinListPos).WinTitle = wTitle
            gWinList(gWinListPos).WinHandle = lHandle
        END IF
    
        FUNCTION = 1
    END FUNCTION
    
    
    FUNCTION PBMAIN () AS LONG
        LOCAL winTitle AS LONG
        winTitle = FindWindowByTitle("CONTAIN", "Adobe Reader")
    
        IF winTitle = 0 THEN
            ? "Window not found."
        ELSE
            SendMessage winTitle, %WM_SYSCOMMAND, %SC_CLOSE, 0
            ? "Window closed."
        END IF
    
        ? "Finished."
    END FUNCTION
    '-----------------

    Leave a comment:


  • Chris Holbrook
    replied
    Originally posted by Katherine Lepley View Post
    Thank you! I will check out the link!
    Oh dear. I just followed the link from Skyter's post to his source code and it 404'd. Sorry! Looking on the bright side, a) it's a handy forum for PDF problems, and b) Skyter did at least identify an approach, which should be testable using PB.

    Leave a comment:


  • Katherine Lepley
    replied
    Thank you! I will check out the link!

    Leave a comment:


  • Chris Holbrook
    replied
    Originally posted by Katherine Lepley View Post
    I didn't see the link available?
    Ah, just testing... link inserted!

    Leave a comment:


  • Katherine Lepley
    replied
    I didn't see the link available?

    Leave a comment:


  • Chris Holbrook
    replied
    Originally posted by Katherine Lepley View Post
    That closed the document
    /t used to do the trick until Acrobat Reader 8. The short answer is I don't know, but here's a fascinating link - look for the post by Skyter, who includes C source code. His (male gender imputing all others) approach is to send the application a WM_CLOSE message.

    I should have added - the C code could no doubt be translated to PB.
    Last edited by Chris Holbrook; 21 May 2008, 03:32 PM. Reason: add link

    Leave a comment:


  • Katherine Lepley
    replied
    That closed the document, but Adobe still stays open. Half way there! Thank you for that advice!

    Leave a comment:


  • Kev Peel
    replied
    How about this:

    Code:
    ShellExecute %HWND_DESKTOP, "print", BYCOPY lOpenFile, BYVAL %NULL, BYVAL %NULL, %SW_SHOWNORMAL
    If Acrobat is installed, it should print the document in lOpenFile (just like in Explorer - right click on PDF > Print)

    Leave a comment:


  • Katherine Lepley
    started a topic Close adobe

    Close adobe

    I am using

    SHELL("C:\Reader\AcroRD32.exe /t" +lOpenFile,6)

    which works great to open and print a pdf. How do I get it to close the pdf? Can anyone offer insight?
Working...
X