Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


sendkeys for other application (popup)

Posted on 2009-07-16
Medium Priority
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?

Question by:hikingexport
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

Expert Comment

ID: 24867915
Can you post your code please?

LVL 10

Accepted Solution

Alan_White earned 900 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.

Author Comment

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!
Technology Partners: 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

Alan_White earned 900 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.
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 600 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:

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...

Author Comment

ID: 24875200
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.

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?

LVL 86

Expert Comment

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

Author Comment

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!
LVL 86

Expert Comment

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

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

609 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