Solved

Tough One: VBScript for keystroke emulation on a Java applet

Posted on 2001-07-05
7
581 Views
Last Modified: 2012-05-04
Hi all,

I've got a doozy here: I have a customer who uses a Java applet that connects to a remote AS400 terminal, and provides a full emulation of that terminal to the viewer. (it's called OC://WebConnect). The thing they are hoping I can do is create some scripts that will automate certain activities in that terminal. I am not able to contact the actual AS400 terminal directly. The Java applet handles that through an encrypted TCP/IP session. All I want to do is find a way to control the Java applet through client-side VBScript, or whatever means possible. I know that VBScript is sometimes used to open windows and make things happen through WSH, but I don't have any real experience with that. (I understand there is a "SendKeys" behavior, or something like that.)

The AS400 system itself is on a server owned by another, much bigger company, and there is no way at present to ask them to provide any server-side modification and assistance, so I am left trying to solve this client-side.

The Java window is spawned from an Internet Explorer session, but it instantly pops up a separate Java window which only contains the terminal, and some standard application controls, such as File, Edit, etc... I am hoping, through some combination of WSH/COM/VBscript, to come up with a way to control that terminal, and handle the range of keystroke activities the user would normally do by hand.

Is this at all possible? Can anyone at least point me in the right direction for this? Any simple examples of controlling windows and menus from .VBS files, etc... Any keystroke emulation routines? All I want is to emulate what the user would do on the actual desktop.
0
Comment
Question by:rycamor
7 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6258150
Hearing...
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6258743
rycamor, In principle what you want is achievable. Without having the appropriate software it is impossible for me to give you precise code (and test it) however the following ideas should help.

1) Create a VB activex dll which contains a class which allows you to use the findwindow API to obtain the window handle of the appropriate window in order to be able to give it the focus to receive the keyboard events.

2) Use sendkeys either in the vb dll or in the VBS to send the appropriate keystrokes.

Some additional considerations:

1) You may want to look at using the keybd_event api call to simulate more complex keystrokes than sendkeys does.

2) You should also consider use api calls in the class to sleep the process for a specific time to allow the keystrokes to be processed and the window to update before sending the subsequent instructions.

3) You may also consider using api calls to determine the state of the window's display at any time again to ensure that it is reacting appropriately to the keystrokes that are sent.

Hope this helps (a little).
0
 
LVL 17

Expert Comment

by:inthedark
ID: 6259511
As TimCottee has suggested you may get timing problems as the sendkeys App. may not get the usual responses and so problems may occur.

If its a JavaApplet you may find that it has some methods and properties that can be used.  You may be able to launch the applet from within vbscript and directly talk to the Applet.

Do you have the Applet source code?  You may even find the name of the programmer who you can all and ask how to automate his code.

Why not ask IBM if they have a VB ActiveX that will do the same thing.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 22

Expert Comment

by:rspahitz
ID: 6260557
Since Java Applets are really just class components, it may be possible to embed this class inside a VB (not VBS) app and get better control over it.  I've never tried it, so it may require an additional interface to convert the .class into a .dll for use.
0
 
LVL 3

Author Comment

by:rycamor
ID: 6261538
TimCoffee, I appreciate you thoughts here, but, I have a feeling that I really should take a different tactic to all this, because I'm not about to get into actually developing a VB app for this.

I have taken the time in the past day or so to download a variety of "macro recording" demos, and I am going to see if any of these can be controlled finely enough to do the job. any thoughts or experiences with any of these? So far, WinTask ( www.wintask.com ) looks like it has the most complete keyboard/mouse macro environment.

Your answers have been helpful, in any event, so I will give you some points, after you think about the feasibility of the macro recording approach, and give me a little more input. Thanks

To inthedark and rspahitz: no, I don't have the applet source code, or I would be asking questions in the Java forum. And again, it's not a question of IBM, because I am not allowed *any* access to the AS400, except through this particular applet.
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 250 total points
ID: 6264318
We have used wintask only once in my company, to automate the changing of radio stations on a pc with a radio card installed. It does seem to work reasonably well but as with all macro recording applications it does require that you are very precise with your keystrokes/mouse movements and that you ensure that all movement is relative to the window and not to the screen. Otherwise you have to ensure that the window that is opened is ALWAYS in exactly the same place otherwise you will get strange results.

All that these applications do is pretty much what I was suggesting earlier. The process I described would have allowed you to create a focused keystroke/mouse faking application to automate the process. WinTask or similar do exactly the same and will (at least within the bounds of normal activity) work just as well I am sure.

Good luck with it.
0
 
LVL 3

Author Comment

by:rycamor
ID: 6266282
Thanks, Tim. I guess this is the way to go, then. I was hoping for some sort of shortcut, but I see from your responses that there is none. Somehow, I will make this work, at least until I get someone at the larger organization to allow me better access.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

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