|
-
Sep 28th, 2010, 10:08 AM
#1
Thread Starter
New Member
Shell - then Send Keys
Please help!!
I have been trying for the past 4 days to open up an application (on a shared-Network Drive) using Access 2010 (VB7). I have copied code from forum after forum and post after post…but I am still encountering the same problem (unable to focus and execute send keys to this application once it opens using the shell command).
I am able to get the application to open just fine, but I am not able to send keys (or anything else for that matter) unless I click on the program in the task bar after it opens.
Since I was not sure if it was the application I am trying to open (called “GA – General Agency Management System) I copied code that is supposed to open Notebook and send it some text after it is opened. This too – opens up just fine, but when the “sendkeys” attempts to send notepad some data, nothing happens.
Below are a couple of snippets of code I have tried, but could not get to work:
Private Sub probwontwork()
x = Shell("notepad.exe", vbNormalFocus)
AppActivate x
SendKeys "This is a test"
End Sub
“””””””””””””””””””””””””””””””””� ��”””””””””””””””””””””””””””””””
Private Sub probnotgonnawork()
AppActivate
MyAppID = Shell("\\fwa-app\ga agency")
AppActivate MyAppID End Sub
“””””””””””””””””””””””””””””””””� ��”””””””””””””””””””””””””””””””
Private Sub havingnoluck ()
x = Shell("GA – General Agency Management System", vbNormalFocus)
MyAppID = Shell("\\fwa-app\ga\Ga.exe Agency exe", ", vbNormalFocus)
AppActivate MyAppID
Dim instance As Control
Dim returnvalue As Boolean
returnvalue = instance.Focus
SendKeys "this is totally not gonna work'"
End Sub
“””””””””””””””””””””””””””””””””� ��”””””””””””””””””””””””””””””””
And many many more!!!
Basically, I just need to open up an application on a shared drive and then “sendkeys” based upon data calculated/created in my Access Database (2010- -VB7) using Win XP with sp3
-
Sep 28th, 2010, 11:05 AM
#2
Re: Shell - then Send Keys
Welcome to the forums 
SendKeys was created to do just was it says...Send Keys, or more accurately, Keystrokes.
You are trying to send data...text...whole sentences, and that ain't gonna work.
If you want to send a Tab key, or one of the Function Keys, or something along those lines, then you are in SendKeys' baliwick.
Perhaps this might shed more light.
-
Sep 28th, 2010, 01:04 PM
#3
Thread Starter
New Member
Re: Shell - then Send Keys
BTW - not trying to send data, text, whole sentences - need to be able to automatically navigate through a series or windows and prompts in my "outside" application...based upon the results calculated in my access db.
-
Sep 28th, 2010, 01:07 PM
#4
Thread Starter
New Member
Re: Shell - then Send Keys
Maybe I mis-titled the thread -
It is not the actual send keys function I am having problems with (as I have done this before on a pcomm type application and it works great).
I am having problems setting the focus on the window of the application VB has just opened - if i can get that to work - the rest of this project would be fairly easy. Any Ideas?
-
Sep 28th, 2010, 04:19 PM
#5
Re: Shell - then Send Keys
i use appactivate, with inline error handling, to make sure the shelled window is open and has focus before trying to sendkeys
i do not have problem sending text strings to other windows
as i use vb6 the code may need modifying slightly
vb Code:
apptitle = "Untitled - Notepad" r = shell("notepad.exe") on error resume next do err.clear appactivate apptitle do events loop while not err.number = 0 on error goto 0 ' return to previous error handling sendkeys vbnewline
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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
|