Consulting

Results 1 to 6 of 6

Thread: Change Focus to non-office window.

  1. #1
    VBAX Regular
    Joined
    May 2007
    Posts
    87
    Location

    Change Focus to non-office window.

    Thanks for your help today,

    however I'm now stuck on sending a "<return>" ("~")
    to a quaternary application.

    I open SolidEdge2D from an Office Macro,

    I send keys <ctrl><p> to it, and send return,

    But that then opens CutePDF up, an application that saves to file a printer output from an application.

    This needs a return sending to it to save the file as the default.

    But the Window is not focused on.

    The window is called "Save As" and I wish to press "Save" (default option so a "~" <return> would do).

    Does anyone have an idea?

    Currently I'm here:

    [VBA]
    Sub SE2D()
    Shell "C:\SE2D\Program\Edge.exe C:\PE3\AR\DOOR_001.dft", vbMaximizedFocus
    Application.Wait Now() + TimeSerial(0, 0, 10)
    Application.SendKeys "^p", True
    Application.SendKeys "~", True
    Application.SendKeys "~", True
    Shell "C:\Reader\AcroRd32.exe C:\PE3\AR\DOOR_001.pdf", vbNormalFocus
    End Sub
    [VBA]

    Thanks,

    -Andy

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    This is guessing, but maybe
    %{TAB}
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    May 2007
    Posts
    87
    Location
    Is that "ALT-TAB"?

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Exactly that.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Regular
    Joined
    May 2007
    Posts
    87
    Location
    No way of doing by "Switch to window blah blah" method?

    -AS

  6. #6
    VBAX Regular fixo's Avatar
    Joined
    Jul 2006
    Location
    Sankt-Petersburg
    Posts
    99
    Location
    Not sure about if that will be helps,
    anyway you can to try to look at
    SetFocus API function:

    Declare Function SetFocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
    Parameters:
    ? hWnd
    Identifies the window that will receive the keyboard input. If this parameter is NULL, keystrokes are ignored.

    If the function succeeds, the return value is the handle of the window that previously had the keyboard focus. If the hWnd parameter is invalid or the window is not associated with the calling thread?s message queue, the return value is NULL.

    ~'J'~

Posting Permissions

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