Results 1 to 20 of 20

Thread: ShellExecute and wait

Hybrid View

  1. #1
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    126

    Re: ShellExecute and wait

    Thx a lot, but still the script, that should be run when the file is opened, doesn't catch up. The script uses menu functions that are in the program (like for example: File -> Print...) and therefore I think the program must wait until the file is completely opened. The link you provided seems to just wait until it recognizes the process, but after that it continues executing my script and the script then generates an error because the application isn't fully opened. So probably what I have to do is to wait for the window to open (With FindWindow API function). But now I wonder, must I supply the exact name of the window that opens, or is there some other API function that can just find a window that is opened with that application?

    Thanks in advance.

  3. #3
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: ShellExecute and wait

    That could be slightly tricky. I doubt FindWindow would be of any use, as the problem lies with the loading time of the file the script is processing. Do you have full control over when to run the script ? ie WRT vbaccelerator's code, could you do something like "ShellAndWaitForTermination", -> "Sleep(n)" (to make sure the document is loaded), -> "Script". ?

    Also does the script auto close the app when it's done ?

    EDIT:- As regards FindWindow, even if the app displays the document name in the caption, your script may fail depending on whether the app changes its caption before or after the doc is read from the HDD.
    Last edited by schoolbusdriver; Aug 1st, 2006 at 09:04 AM.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    126

    Re: ShellExecute and wait

    Hi,

    Thanks for your reply. I can start the script whenever I want and the script doesn't close the application after it's done.
    The problem is that on some machines the program might run faster or slower, so waiting a specified time would maybe not be enough on some other machine, don't you think?

    This is indeed tricky...I also can't have this application as a reference to my project (like for example Word) so that I could use it as an object in the code What do you think is the best thing to do?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    126

    Re: ShellExecute and wait

    I tried with the FindWindow function and it works. But the problem now might be if the user has several applications open, so FindWindow maybe gives me the wrong one. Any way to find the handle of the latest opened application?

    Thanks in advance.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    126

    Re: ShellExecute and wait

    I take it back. It doesn't work
    I had a MsgBox that was run earlier than I thought, and that delayed the program and made it work. So even if I use the FindWindow API, it finds the window before it has even loaded :S

    I know thought why the script can't run. It complains about the GetObject method that it uses:

    Dim app
    Set app = GetObject(, "MGCPCB.Application")
    Call Execute_GerberOut

    Is it somehow possible to loop as long as GetObject doesn't work?
    Thanks in advance!

    Btw, it gives me the following error:
    Run-time error 429: Active-X component can't create object
    Last edited by Striver; Aug 1st, 2006 at 10:31 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width