How to get the hwnd to sendkeys to an app?

I have a file with a WS extension.
Under properties it says..DosName = s390.WS

I have tried to shell this file and I have tried to shell the lnk file pertaining to it but it won't shell

If I use shelldef it will open.

Using shelldef, is there a way to get the hwnd so I can send keys to it...

the file is s390.ws and I need to talk to it so I can sign on to workstation.

Wayne
LVL 4
JuiletteAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead of Software ServicesCommented:
can you not use FindWindow() if you know it's caption?
0
JuiletteAuthor Commented:
I could if I knew how...maybe...
You have the code?
0
JuiletteAuthor Commented:
Never mind I have the API...I'll give it a shot.
Wayne
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

JuiletteAuthor Commented:

This will not work to execute the pgm s390
 
 Shell "c:\Program Files \Personal communications\private\s390.ws"

or

dim retVal
retVal = Shell("C:\Program Files\Personal Communications\private\390.ws")

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
<<<<THIS WORKS >>>>>>>>

ShellDef ("C:\Program Files\Personal Communications\private\s390.ws")

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


''' this doesn't work

I have tried this to get the handle using this.

'this is in a bas module

Public Declare Function FindWindow Lib _
"user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

This is in the form event of caller

Dim h
 h = FindWindow("s390", vbNullString)

No success...
0
TimCotteeHead of Software ServicesCommented:
I assume that the s390.ws is a file used to gain access to a mainframe or as/400 using the personal communications terminal emulation. I am using the pc5250 emulation to access an as/400 in a similar way in fact. In order to do the login from vb all I have to do is

AppActivate "Session A - [24 x 80]"
Sendkeys "username{TAB}password{ENTER}"

where "Session A - [24 x 80]" is the caption of the terminal emulation window.

Hope this helps.
0
JuiletteAuthor Commented:
Tim, you are correct...it is a terminal emulation window...however when I try your suggestion (as below) I get an error (as below).
Since days are passing and I now have a whole of 30 some odd points..I will give what I have for an answer that works.

Wayne

Ps...where are the big guys...the top 15...someone must be able to lend a hand! I'm sure anyone with exposure to such things can walk me through the sign on.

'execute the ibm sign on

   ShellDef ("C:\Program Files\Personal Communications\private\s390.ws")

   DoEvents

   Dim session, username, password As String
   session = "CICS"
   username = "userme"
   password = "mypassword"

'activatge the app as per caption on the sign on screen (ibm emulator)
 
   AppActivate "Session A - {24 x 80]"
 
  SendKeys "session {TAB} username {TAB} password {ENTER}"
   
      DoEvents
',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

'gives run time error 5 on AppActivate "Session A - [24 x 80]"
'[invalid procedure call or argument]

The capiton of the emulator  is Session A - [24 x 80]



0
TimCotteeHead of Software ServicesCommented:
Wayne:

OK I have looked at what I have here, you can start the session using the shell command,

Shell("C:\Program Files\Personal Communications\pcsws.exe private\s390.ws")

The reason for the error is that the command has not yet finished executing.

I would suggest that you add a timer to your form allowing say 5 seconds for the emulator to run up. Then issue the sendkey statement which should be in the form:

  SendKeys session & "{TAB}" & username & "{TAB}" & password & "{ENTER}"      

Oh and just check your brackets in the appactivate line { should be [.

Here is an example that seems to work for me, change the paths etc though.

Private Sub Command1_Click()
'execute the ibm sign on
   Shell "c:\program files\ibm\Client Access\Emulator\pcsws.exe private\as400.ws"
   Timer1.Interval = 5000
   DoEvents
End Sub

Private Sub Timer1_Timer()
   Dim session, username, password As String
   session = "CICS"
   username = "Username"
   password = "Password"

'activatge the app as per caption on the sign on screen (ibm emulator)
 
   AppActivate "Session A - [24 x 80]"
 
  SendKeys username & "{TAB}" & password & "{ENTER}"
     
  DoEvents
    Timer1.Interval = 0
End Sub



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JuiletteAuthor Commented:

Tim, thanks...
gone to test...
Wayne
0
JuiletteAuthor Commented:
Tim:
Thanks a million...now on to the next step....I used your shell funciton and it worked fine...seems out system admin didn't include the full path when he set out the properties for the sc390...and the second problem was the ctrl key is the enter key...haven't tried it yet but I assume instead of ener I use Ctrl

Thanks for your patience.
Wayne
0
JuiletteAuthor Commented:
Tim, I tried to change the points and it didn't take effect...the balance are as new Question...TimCottee Only.
0
JuiletteAuthor Commented:
Tim:
Are you still on the thread..I'm having a little difficulty with this last part of your code.

SendKeys username & "{TAB}" & password & "{ENTER}"
sendkeys
sendkeys
etc.      
  DoEvents
    Timer1.Interval = 0


When I leave the timer.interval = o, I can't get past the second sendkeys..if I take it out I do all my sendkeys but of course it keeps sending keys...tried larger and smaller increments and anything else I can tink of...

How do I turn off the timer but only after the last sendkeys..and I have about 15 or so...

even tried putting a doevents after each send and then a disable after the last sendkeys but it still keeps sending.
Wayne
0
TimCotteeHead of Software ServicesCommented:
OK I think I understand, you need to set a wait period between each sendkeys in order to allow the emulator to process the commands and be ready to receive the next message.

Change the code to something like:

Private strSendKeys() as String
Private intMessage As Integer

Private Sub Command1_Click()
'execute the ibm sign on
   Shell "c:\program files\ibm\Client Access\Emulator\pcsws.exe private\as400.ws"
   Dim session, username, password As String
   session = "CICS"
   username = "Username"
   password = "Password"

'activatge the app as per caption on the sign on screen (ibm emulator)
   redim preserve strSendKeys(15) ' where 15 is number of messages to send
   strSendKeys(0) = username & "{TAB}" & password & "{ENTER}"
   strSendKeys(1) = "Message 1"
   strSendKeys(2) = "Message 2"
   '.... and so on
   intMessage = 0
   Timer1.Interval = 5000
   DoEvents
End Sub

Private Sub Timer1_Timer()
  AppActivate "Session A - [24 x 80]"
  Sendkeys strSendKeys(intMessage)
  intMessage = intMessage + 1
  IF intMessage > 15 Then ' or your max no of messages
    Timer1.Interval = 0
  End If
End Sub


I haven't tested this, just typed it from the top of my head so you may want to check it through and I cannot guarantee that it will work first time but the theory is ok.


0
JuiletteAuthor Commented:
Thanks,
Wayne

Theory is fine...I'll work out the rest.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.