PDA

View Full Version : Change Focus to non-office window.



andysuth
08-01-2007, 05:51 AM
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

Bob Phillips
08-01-2007, 05:56 AM
This is guessing, but maybe
%{TAB}

andysuth
08-01-2007, 06:02 AM
Is that "ALT-TAB"?

Bob Phillips
08-01-2007, 06:05 AM
Exactly that.

andysuth
08-01-2007, 06:19 AM
No way of doing by "Switch to window blah blah" method?

-AS

fixo
08-01-2007, 07:11 AM
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'~