sendkeys and Shell problem

G

GeorgeMar

I am trying to get a HP scanner software to accept keystrokes from my access
application and am having some trouble. The problem is that the HP software
launches an number of windows in the process and the SendKeys is not directed
to the right window.

For example, the HP Director, a HP software, has a button to do Document
Scanning. when you click that button, another window is opened to scan the
document and then another window is opened to save the document. the
Sendkeys only works for the first window opened by the HP Director.

Any suggestions on how to force Sendkeys to recognise the latest window
opened.

many thanks
george
 
G

GeorgeMar

Thank You for your response Alex.

I have read the threads. However, I could not find a reference to timing.

Since posting this, I have found some more information about FindWindow and
SetFocus. Here is the scenario. A button on my form opens a HP exe. Even
though I have VBHide in the Shell command, it still opens as VBNormal. When
I open the EXE, I trap the Windows handle of that Window through FindWindow.
When the form closes, I SetFocus to the handle and SendKeys "%{F4}" to close
it.

What is hapenning is that the focus is still on the form with the button and
not the HP exe. What is the best way to make the window get focus, so that I
can close it.

regards
george
 
A

Alex White MCDBA MCSE

Hi George,

Yes there was not reference to timing in that post, that post was about
finding the correct window via the API and trying to get it to the
foreground (code below), the timing issues are a problem as they are
different from machine to machine, and how much the user is typing on the
keyboard at the time could play a part in it working or not.

An API call

SetForegroundWindow Me.Hwnd

to make sure the correct window is being passed the SendKeys keystrokes.

Personally I have had a lot of problems in the past with SendKeys.

One thing I would check that may work, once you have installed your scanning
software check your references within a code module Menu Tools/References

see if any typelib or objects are being exposed from that application
because this could be your solution e.g.

*** Air Code ***

dim myScan as new HPScanner
myScan.ScanDocument

the above code is an example, but a lot of well written code/applications
expose API's and if this is the case for your scanner software, then this is
the answer.

Another answer could be are you using a twain compatible scanner as there is
lots of ways to control twain scanners via code, or is there something
specific with the HP software you need beyond scanning a document and saving
it to a file.

Good luck....
 
G

GeorgeMar

Thank you again Alex.

I have had to resort to Sendkeys because I have been unable to get proper
OCR and Automatic Document Feeder software . I have been speaking to HP for
the last 2 weeks to no avail. I already have a TWAIN module in my software
that can capture and save to a JPEG. But I can't save to a PDF. The
sendkeys is an interim measure until a proper OCX or a lib or object as you
suggest.

I will try to check the references.

many thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top