Dave
What can I say ... ? Many thanks
Or as (Somebody) would write ... maNy thAnKs
Reading his code is *painful* ...
Paul
Dave Crozier wrote:
> Paul,
> Also here is a program to take an open window opened with notepad and send
> keystrokes to it.
>
> 1. Open a new Notepad File (right click in folder - new text document
>
> 2. Run the program below
>
> Notice it sends keystrokes to the Notepad document and as an aside opens up
> the Font menu.
>
> Hope it helps
> Dave
>
> *******************
> * Start of Code
> *
> cWindow_Name="New Plain Text File.txt - Notepad"
>
> lnMainWind = GetActiveWind()
> lnHandle = FindWind(cWindow_Name)
> SetForeWind(lnHandle)
> If lnHandle # 0
> * Start scanning and wait 2 seconds
> cMessage="Hello There This has been created by VFP"
> For I=1 to Len(cMessage)
> ? SendKey(Substr(cMessage,I,1))
> Endfor
>
> Do While FindWind(cWindow_Name) # 0
> * Attempt to close the MODI Application
> SendKey('ALT O')
> SendKey('F')
> SendKey('T')
> Exit
> *
> Enddo
> Endif
>
> * Reactivate the calling window
> SetForeWind(lnMainWind)
> Return
>
>
> *******************************
> * Function to send keystrokes
> * Eg Sendkey("ALT T") - send Alt/T
> *
> Function SendKey (tcChar)
> Declare keybd_event In user32 ;
> SHORT bVk, SHORT bScan, ;
> INTEGER dwFlags, Integer dwExtraInfo
> Declare SHORT VkKeyScan In user32 Integer ch
> Local lcChar
> lcChar = Right(tcChar, 1)
> Do Case
> Case 'SHIFT' $ Upper(tcChar)
> * Shift key
> keybd_event(0x10, 0, 0, 0)
> Case 'CTRL' $ Upper(tcChar)
> * Ctrl key
> keybd_event(0x11, 0, 0, 0)
> Case 'ALT' $ Upper(tcChar)
> * Alt key
> keybd_event(0x12, 0, 0, 0)
> Endcase
>
> keybd_event(VkKeyScan(Asc(lcChar)), 0, 0, 0)
>
> Do Case
> Case 'SHIFT' $ Upper(tcChar)
> * Shift key
> keybd_event(0x10, 0, 2, 0)
> Case 'CTRL' $ Upper(tcChar)
> * Ctrl key
> keybd_event(0x11, 0, 2, 0)
> Case 'ALT' $ Upper(tcChar)
> * Alt key
> keybd_event(0x12, 0, 2, 0)
> *
> EndCase
>
> * Wait for response
> Inkey(.01)
> Return
> *
> EndFunc
>
> * Establish the foreground window
> Function SetForeWind(tnHandle)
> Declare Integer SetForegroundWindow ;
> IN user32 Integer hWindow
> Declare Integer FindWindow In user32 ;
> STRING lpClassName, String lpWindowName
> SetForegroundWindow(tnHandle)
> Return
> EndFunc
>
> * Get a specific window reference
> Function FindWind(tcWindow)
> Declare Integer FindWindow In user32 ;
> STRING lpClassName, String lpWindowName
> Local lnHandle
> lnHandle = FindWindow(Null, tcWindow)
> Return (lnHandle)
> EndFunc
>
> * Get reference to the active window
> Function GetActiveWind
> Declare Integer GetActiveWindow In user32
> Return (GetActiveWindow())
> *
> EndFunc
>
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.