Valhalla Legends Forums Archive | General Programming | SendKeys VB Function

AuthorMessageTime
MesiaH
Im using a command button to do the following:

[code]
shell "c:\windows\system32\telnet.exe", vbnormalfocus
sendkeys "o 127.0.0.1 6112"[/code]

but when it executes, it opens like 10 telnet windows, and all are blank except one, which says:
[quote] 127.0.0.1 6112o 127.0.0.1 6112o 127.0.0.1 6112o 127.0.0.1 6112o 127.0.0.1 6112[/quote]
any ideas on what im doing wrong, or any other way to send keys to a program?
February 7, 2003, 5:52 PM
Grok
you're probably calling function that contains that code 10 times.
February 7, 2003, 8:22 PM
St0rm.iD
only shell once, on startup
also use appactivate
February 7, 2003, 8:29 PM
MesiaH
sendkeys is a built in vb function, and the code you see there is inside a command button, no where else, thats all the code there is, yet still opens 10 windows and shit..
February 7, 2003, 10:05 PM
K
shell "c:\windows\system32\telnet.exe o 127.0.0.1 6112", vbnormalfocus

Sendkeys are really a bad idea. They never work how you want them to. If this opens 10 windows when called once, then you need to fix something greater.
February 7, 2003, 10:11 PM
MesiaH
ooo good idea, silly me. thnx
February 7, 2003, 10:26 PM
iago
Test it in a command button instead of in Activate, then you KNOW for absolutely certain it's only happening once (maybe generating a new window counts as an activate somehow)
February 8, 2003, 4:50 AM
ILurker
SendKeys, "keyshere"
Your forgot the ","
;)
February 9, 2003, 11:12 AM
MesiaH
? why would i need that? and if thats alone in a line of code, that would probably be invalid syntax...
February 9, 2003, 7:29 PM
indulgence
The better question is why you are using sendkeys instead of SendMessage...

SendKeys will send only to the window that is active... not necessarily the one you want it too... AppActivate will activate your window - however -- it will not necessarily keep focus
February 13, 2003, 12:28 AM
MesiaH
i changed my code, i no longer use sendkeys.
February 13, 2003, 4:42 PM

Search