Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the FindWindow API

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I want to find Abobe acrobat running on my desktop and "Sendkeys" to save teh .pdf to another folder

the Hot key sequence to save is "Ctrl-Shift-S"

here is my code so far...
---------------
Dim AdobeName, DocumentName As String
DocumentName = "[" & "Drawing1 Model(1).pdf" & "]"
AdobeName = "Adobe Acrobat" ' - " & DocumentName
If FindWindow(vbNullString, AdobeName) = 1 Then
SendKeys

End If
--------------------------------------
the first problem is it does not find the Adobe program so it jumps over the IF statement

then what do I put in the Send Keys to make sure it Sends keys to the Adobe program and not something else.



DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Hi DougP,

your code is very close to working. The statement "FindWindow(vbNullString, AdobeName)" is returning a 'handle' to your target window. The 'handle' is normally a long integer, eg 2940, which could be different on each session. Try this ........

'********************************************************
Dim AdobeName, DocumentName As String, hWnd as Long

'***define target window title.
DocumentName = "[" & "Drawing1 Model(1).pdf" & "]"
AdobeName = "Adobe Acrobat" ' - " & DocumentName

'***find handle to target window.
hWnd = FindWindow(vbNullString, AdobeName)

If hWnd = 0 Then 'window not found returns zero.
'###target window not found routine....

Else
'###target window found routine....
AppActivate AdobeName 'switch to target window.
SendKeys ? 'send your keys.

End If
'********************************************************

I'm no expert, but this code should help. The sendkey command is not ideal for a production environment because of the user or system interacting at the same time can cause unpredictable results, unless catered for.

Good Luck, TopJack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top