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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can anyone show me an example of se

Status
Not open for further replies.

mpastore

Programmer
Mar 12, 2003
568
US
Can anyone show me an example of sending text from VFP to another application like notepad? Assume that notepad is open and I have a window handle to it. Using the API I am able to bring notepad to the foreground:

= SetForegroundWindow (hwnd)

However, keyboard command does not send my text to notpad. How do I do this? Thanks Mike

Mike Pastore

Hats off to (Roy) Harper
 
HI

cText = "This is my First NotePad Text"
cFile = "C:\Test.txt"

= STRTOFILE(cText,cFile)

DECLARE INTEGER ShellExecute IN shell32.dll ;
INTEGER hndWin, STRING cAction, STRING cFileName, ;
STRING cParams, STRING cDir, INTEGER nShowWin

=ShellExecute(0,"OPEN",cFile,"","",1)

:)



____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Ramani,

Thanks but I need to assume the notepad application is already open and I have to actually send the keystrokes over to the notepad window.




Mike Pastore

Hats off to (Roy) Harper
 
Would Word Automation be useful ?

something like ...

oWord = createObject("Word.Application")
oDoc = oWord.Documents.Add()
oRange = oDoc.Range()

oRange.insertAfter(cKeystrokes)



Don


 
Thanks for all the input from everyone...however I ended up using winbatch.exe via VFP winexec(). All set now

Mike Pastore

Hats off to (Roy) Harper
 
mpastore,

Here is my example from thread184-675750 (I am reposting it here because it is relatively short and will save you a hop)

Cut-N-Paste the code below into a prg file and run it from within VFP.

Declare Sleep IN WIN32API INTEGER
oWshShell=CreateObject("WScript.Shell")
oWshShell.Run("notepad.exe")
=Sleep(1000)
TypeStuff("Tek-Tips is the ")
TypeStuff("G")
TypeStuff("R")
TypeStuff("E")
TypeStuff("A")
TypeStuff("T")
TypeStuff("E")
TypeStuff("S")
TypeStuff("T")
TypeStuff("!{ENTER}")
TypeStuff("{TAB}")
TypeStuff("I hope that ")
TypeStuff("you agree{ENTER}")
TypeStuff("{TAB}{TAB}Goodbye for now!")
FOR nCount = 1 TO 9
TypeStuff("{BACKSPACE}")
ENDFOR
TypeStuff("!")

PROCEDURE TypeStuff(cKey)
=Sleep(500)
oWshShell.SendKeys(cKey)
ENDPROC

Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top