Solved

sendkeys for other application (popup)

Posted on 2009-07-16
9
586 Views
Last Modified: 2013-12-26
i am writing a vb script to open another application (pcomm) using shell.
It works and pop up a child window for login with below 2 info:
UserID:  <textbox>
Password: <textbox>

but i am fail to pass the useid/password that I have in variable to the screen...
Application.sendkeys seems not work.
do I need to use some  API?
Thanks!!!


sample.JPG
0
Comment
Question by:hikingexport
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 1

Expert Comment

by:ShallIStickABroom
ID: 24867915
Can you post your code please?

Ta
0
 
LVL 10

Accepted Solution

by:
Alan_White earned 300 total points
ID: 24868002
You might want to look into AppActivate.  http://msdn.microsoft.com/en-us/library/wzcddbek(VS.85).aspx
The string for AppActivate would be "Signon to AS/400" in your case.  It is not always foolproof.
 
0
 

Author Comment

by:hikingexport
ID: 24870767
I can now send keys using sendkeys and AppActivate the return integer from Shell function
However, as there are 2 fields in my form, is that a better way to set/determine the current cursor position on the screen so that my sendkeys works exactly what I want?

or sendkeys to specific field in the 2 textbox I wish?

Thanks a lot!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Assisted Solution

by:Alan_White
Alan_White earned 300 total points
ID: 24870867
Unfortunately send keys is not a very good tool.  Other than appactivate, all you can do is send keys presses.  Have a play around with the keyboard only and see if there is any fullproof method of getting the data in that you want.  eg does pressing ESC clear the boxes?  does ALT+Space then ESC always take you to the first box?  
Basically you need to figure it out with your keyboard and then you are just mimicking those key presses with sendkeys.
Sorry to not be more upbeat but send keys has frustrated me in the past.
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 200 total points
ID: 24871457
If you can't find a RELIABLE way of making sure the keys go to the right field then you'll need a different language to automate the process.

Consider using the free VB.Net 2008 Express:
http://www.microsoft.com/express/vb/Default.aspx

Then you can use WinAPIs (FindWindow/FindWindowEx & SendMessage possibly) to get a handle to each window and send text directly them.

Let us know if you want to explore that route...
0
 

Author Comment

by:hikingexport
ID: 24875200
Alan_White:
Thanks for your comments. I think I just have the frustration you got in the past.
I have read lots of material online and know that sendkeys is not a reliable way, it MAY do what we want for some suitable cases.

Idle_Mind:
Thanks. Let me chk and figure out if I can use sendkeys or other ways in VB first, but just want to know if i can use VB scripts to call those WinAPIs?

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24875213
No...unfortunately you can't call WinAPIs from pure VBScript.
0
 

Author Comment

by:hikingexport
ID: 24875288
Actually I am writing the script in excel macro
I remember I used once to call from excel macro VB script to open a "Open document" dialog in windows for user to select desired file. (sorry I forget the code right now)
so isn't this WINAPI? correct me if I am wrong, thanks!
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24875303
That's completely different then!  Yes, you can use WinAPIs in Excel.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question