?
Solved

sendkeys for other application (popup)

Posted on 2009-07-16
9
Medium Priority
?
597 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 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.
 
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
Industry Leaders: 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 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.
0
 
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:
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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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
Course of the Month13 days, 2 hours left to enroll

777 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