views:

96

answers:

4

I'm trying to make a program to open Acrobat files using Adobe Acrobat Reader and save them in a text file, automatically. What I want my program to do is:

  • open the pdf
  • send Alt + Tab //to move to the acrobat tab
  • send Alt + F //to open file
  • send Down Down Down Down (4 times) //to select 'save as text' option
  • send Enter // to save

I'm using Windows OS. can someone please help me on how to do this?

Well my finel goal is to save the title and author of about 2500 pdf files in a database automatically, what are the better ways you suggested ? this was what i came up with.

A: 

You're going to want to use Spy++ and watch the messages being passed to the window when you perform these actions (note that opening the PDF with Acrobat and grabbing the Window handle are different operations). From there, look into:

http://msdn.microsoft.com/en-us/library/ms644950(VS.85).aspx

Win32 messaging is difficult if you're not used to it and fragile, as mentioned by @Alf. I'd suggest you try another approach, but if you Google "win32 sendmessage" or "win32 sendkeys" that should get you started.

Stefan Mai
A: 

Couple of things,

1) Simulating keystrokes to interact with another application is a very very bad idea. You're better off finding API's that'll do the same thing.

If you still haven't changed your mind, read further...

2) For Saving, Why not use Ctrl+S to save, Ctrl+O to open. I'm Sure you'll find direct shortcuts for the others too.

Here's a Project that might help.

st0le
A: 

Try AutoIt. From it's website:

"AutoIt is a freeware Windows automation language. It can be used to script most simple Windows-based tasks."

Colin
Hey, i tried Autoit, thanx for the tip
SNBR
but still having a problem, well i can get autoit to run notepad by giving Run("notepad.exe") like that i tried to get Run("acroRD32.exe") but it doesnt work, any idea why ?
SNBR
It's probably not in your path. Did you try putting the complete path in there? For example: Run("C:/Program Files/Adobe/acroRD32.exe")
Colin
Thanx ill try that
SNBR
A: 

You can use SendMessage API to send mouse and keyboard messages to a window, or you can use sendinput which simulates actual hardware events. I will agree with another person, use AutoIT

Raindog