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!

Passing keyboard command to another application 2

Status
Not open for further replies.

LuigiG

Programmer
Jun 9, 2011
8
IT
I have an application that runs in an industrial computer without keyboard. The application performs a do while loop that stops if you click on the F5 key. The screen is small and you can not use the virtual keyboard of windows.
I created an app with a button that sends the command F5. This is the code but does not work ,the application passes in the foreground but the Keyboard command does nothing any ideas how to solve

Code:
DECLARE INTEGER FindWindow IN win32API STRING @ cClass, STRING @ cTitle
DECLARE LONG BringWindowToTop IN Win32API LONG
nhwnd=FindWindow(0,"Lettura sensori")
BringWindowToTop(nhwnd)
KEYBOARD "{F5}"

Thank you
Luigi
 
The KEYBOARD Command only sends keys to the current Foxpro Application, Bringing a Window to the top does not change that.

What you could try is using WSHShell:

Code:
o = CreateObject("WScript.Shell")
o.SendKeys('abc',0)

The WSHShell SendKeys() method sends keys to the active window.

Bye, Olaf.
 
Correct Mike, that code simply is the replacement code for the KEYBOARD "{F5}" Command. I'd first try with abc to a notepad window for example, and then go for {F5}. In regfard to the MSDN that is the correct syntax, as in Foxpro.

Bye, Olaf.
 
The comand works in my application if I use any keyboard letter for example o.SendKeys('x'),if I use o.SendKeys('{F5}') it works in notepad but not in my application I do not know why?

Thank you for your help

Luigi
 
No, we can't tell you why F5 doesn't work in your program. We don't know how your program is supposed to react to F5.

Ar you sure that your program is the active window when you issue F5?

Also, you don't need to use SendKeys within a FoxPro application. You can use KEYBOARD in that case.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top