Link to home
Start Free TrialLog in
Avatar of planetiowa
planetiowa

asked on

Using SendMessage to execute a command in another app.

I am using an app which has a window where if you type "@my.hcl <cr>",  it goes off and executes that file.  Using FindWindow and FindWindowEx, I am able to find the window's handle and using SendMessageBy String, I am able to write the "@my.vcl" into the window.  I am not able to get it to execute the command as if I typed it into the window directly though.  This is the command line I use to send the message:

slength = SendMessageByString(lhwnd6, WM_SETTEXT, -1, "VCL>@my.vcl" & Chr(13) & Chr(10))

The text "@my.vcl" and a cariiage return appear in the window but it doesn't do anything.  What am I missing?  Also, I'd like be able to append text to the window, not replace it.

Thanks!
Avatar of BrianGEFF719
BrianGEFF719
Flag of United States of America image

I hate to say this, but you could always use send keys.

AppActivate("OtherAPplicationTitleWindow")
SendKeys("VCL>@my.vcl" & vbcrlf)


Try that.
Avatar of planetiowa
planetiowa

ASKER

I tried that, but it only seemd to work very infrequently.  Most of the time the text is writeen into the current window (the VB project editor).  

I did some internet searchs and ran across a keybd_event api that seems to work a lot more consistently, however, I can't get the "@" to appear.  For example, if I use:

call keybd_event(64,0,0,0) '@
call keybd_event(86,0,0,0) 'V
call keybd_event(67,0,0,0) 'C
call keybd_event(76,0,0,0) 'L

I get:  vcl

without the "@" appearing.  Also, the vcl is lowercase, not uppercase for some reason??
Any ideas?

ASKER CERTIFIED SOLUTION
Avatar of BrianGEFF719
BrianGEFF719
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial