|
-
Jun 1st, 2000, 06:25 AM
#1
Thread Starter
Lively Member
I'm trying to automate another app thru my app, but i've ran into some problems. For some reason, my app wont get the text its suppose to.
Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As String) As Long
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Dim lCalc As Long
Dim lTextbox As Long
Dim lLen As Long
Dim strBuffer As String
-----------------------------------------------------
On Error Resume Next
DoEvents
RetVal = Shell("C:\SomeApp.exe", vbNormalFocus) 'opens app
AppActivate RetVal
SendKeys Text2.Text 'sends first string to other apps first textbox
SendKeys vbTab 'sends tab to goto next textbox
SendKeys "(16)" 'sends second string to other apps second textbox
SendKeys vbTab 'sends tab
SendKeys "(1231231231231231)" 'sends third string to other apps third textbox
SendKeys vbTab 'sends tab
SendKeys Chr(13) 'sends enter to press a command button
'#after button is pressed, other app auto puts cursor in the correct textbox
'#grabs text from textbox on other app
lCalc = FindWindowEx(0, 0, "ThunderRT5Form", vbNullString)
lTextbox = FindWindowEx(lCalc, 0, "ThunderRT5TextBox", vbNullString)
lLen = SendMessage(lTextbox, WM_GETTEXTLENGTH, 0, 0) + 1
strBuffer = Space(lLen)
Call SendMessageStr(lTextbox, WM_GETTEXT, lLen, ByVal strBuffer)
Text1.Text = Text1.Text & strBuffer & Chr(13) & "1"
SendKeys "%" 'sends alt to the app
SendKeys "{DOWN}" 'sends down on menu
SendKeys "{DOWN}" '""
SendKeys "{ENTER}" 'sends enter to exit out of program
Does anyone know why this doesn't work, or know a better way to do this?
Thanks,
Ryan
-
Jun 2nd, 2000, 12:46 AM
#2
Lively Member
Try putting "True" after the sendkeys function.
Sendkeys "A", True
Also, you may want to put a FindWindow API just after your Shell function to make sure the application is loaded before you start sending it information. Chris gives and example of this in the link below.
http://www.vbforums.com/showthread.php?threadid=18327
-
Jun 2nd, 2000, 03:04 AM
#3
Try removing the On Error Resume Next and see if you get an error. If you do, you can pin point the problem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|