×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Sendkeys Query

Sendkeys Query

Sendkeys Query

(OP)
Hi all,

Below the line is some code I've written with the purpose to go between excel and an old program called TRUST. It works up till the point which I've highlighted in yellow. The idea is to basically eradicate the manual process of doing this through a macro which can just input the letters and paste the next new number in one by one.

Anyway - any ideas for a better way to do it would also be appreciated (I've explored sendmessage using API and Spy+++ but I can't get Visual Studio on my pc).

Thanks in Advance for any help with this.
Andy

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sub switchbetweentrustandexcel()


' This is a test macro to switch between TRUST and excel


Dim IDTRUST As Variant
Dim Path As String
Dim IDEXCEL As Worksheet

'........................................................................................................................

' Set the Path variable equal to the path of your program's installation
Path = "C:\Program Files (x86)\WinVVTN\WinVVTN\WinVVTN.exe"

IDTRUST = Shell("C:\Program Files (x86)\WinVVTN\WinVVTN.exe", vbNormalFocus)

MsgBox "Please log in to WinVV and leave it on the blank input screen. This is to enable a TRJG search."

Dim IDnotepad As Double ' to identify application with AppActivate

Workbooks("Automated Incident Number Correction in TRUST Macro.xlsm").Sheets("1").Activate


Range("B2").Select
ActiveCell.Copy

AppActivate ("SCR1 - WinVV Session 1")


'''''''''' Text from excel to paste in after some letters
SendKeys "T"
Application.Wait Now + TimeValue("0:00:02")
SendKeys "R"
Application.Wait Now + TimeValue("0:00:02")
SendKeys "J"
Application.Wait Now + TimeValue("0:00:02")
SendKeys "G"
Application.Wait Now + TimeValue("0:00:02")
SendKeys " "
Wait Now + TimeValue("0:00:02")
SendKeys "^(V)"
Application.Wait Now + TimeValue("0:00:02")
SendKeys "{enter}"
Application.Wait Now + TimeValue("0:00:02")

Application.SendKeys "{TAB}"
Application.Wait Now + TimeValue("0:00:02")
Application.SendKeys "{TAB}"
Application.Wait Now + TimeValue("0:00:02")
Application.SendKeys "{TAB}"
Application.Wait Now + TimeValue("0:00:02")
Application.SendKeys "{TAB}"
Application.Wait Now + TimeValue("0:00:02")

Application.SendKeys "A"
Application.Wait Now + TimeValue("0:00:02")
Application.SendKeys "{Enter}"
Application.Wait Now + TimeValue("0:00:02")

Application.SendKeys "{F4}"

RE: Sendkeys Query

If you are interacting with a window, you might try to script it with AutoHotKey.

Simi

RE: Sendkeys Query

See if this helps:

http://vb.mvps.org/samples/SendInput/

(I'd repost the code but the has a comment in the header that forbids re-posting without permission.)

I use the MySendKeys procedure with no problems on 'later' OSes.

RE: Sendkeys Query

(OP)
Hi all,

Thanks for your help with this so far. It's working up to the point where I want to put in the 'enter' key (not return). I'm working on a laptop so the keyboard key doesn't exist, if that matters? I cannot use application.sendkeys "~" or application.sendkeys "{ENTER}". The application even has a alternate method to put in enter (F10 and ctrl+A) but the function key cannot be used in sendkeys as it's not a windows O/S controlled feature, and the ctrl+A just send's the 'A' (code: application.sendkeys "^(A)"), despite the same code working for ctrl+V for paste...

Does anyone know how to fix this new issue? I really do appreciate anyone taking the time looking into this, it's going to make the biggest difference if I can pull this off!

RE: Sendkeys Query

It's not clear what you've done so far to get past the highlighted line down to the Application.SendKeys "{ENTER}" line from your original post.

RE: Sendkeys Query

(OP)
Apologies DjangMan. The solution to my first issue was to run the macro without the code screen open. I was using F8 to run bit by bit through the code. The issue was, I was trying to say 'look at this app', but instead it was sending the key to the code screen it had to keep checking back in to. So the code remains the same, however it's falling down at another part. Sorry for not clarifying - I hope that does?

RE: Sendkeys Query

Andy,

I’d guess that you have a terminal emulator that interfaces a mainframe computer. Perhaps it is emulating a 3270 terminal interfacing an IBM mainframe.

I found this on railforums.co.uk

Quote:


TRUST and TOPS are old IBM mainframe systems, and only accessible through an emulator called WinVV created by British Rail for British Rail. It runs off a modified Telnet system which makes it difficult and rather cumbersome to use. Think of a more complicated version of Windows Command Line.

You might check out this:
http://www.delayattributionboard.co.uk/documents/T...

A principle to be aware of with terminal emulators.
When you SendKeys to the mainframe, it processes asynchronously. You need to establish a way to determine that the mainframe has responded. Simply waiting a fixed duration is inadequate. The mainframe may respond much sooner or longer than your fixed wait time.

You would never drive your car with the determinatin that at each stop sign, you will wait for 5 seconds before crossing the intersection, without evaluating the traffic on the street. Likewise, you need feedback from the mainframe to determine that it is safe to process the next statement in your program.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Sendkeys Query

(OP)
Skip,

Thanks for showing me that stuff, I have already looked into that. I'm aware this isn't going to be the best, and it's a work around. It would just save an awful lot of time if I managed to pull it off.

By the looks of things I'm going to have to just leave this as something which is simply not automatable due to the age of the system.

Thanks everyone for your time :).

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close