Solved

sendkeys for other application (popup)

Posted on 2009-07-16
9
557 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
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 1

Expert Comment

by:ShallIStickABroom
Comment Utility
Can you post your code please?

Ta
0
 
LVL 10

Accepted Solution

by:
Alan_White earned 300 total points
Comment Utility
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
Comment Utility
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
 
LVL 10

Assisted Solution

by:Alan_White
Alan_White earned 300 total points
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 200 total points
Comment Utility
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
Comment Utility
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 85

Expert Comment

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

Author Comment

by:hikingexport
Comment Utility
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 85

Expert Comment

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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now