Valhalla Legends Archive

Programming => General Programming => Topic started by: Mesiah / haiseM on February 07, 2003, 11:52 AM

Title: SendKeys VB Function
Post by: Mesiah / haiseM on February 07, 2003, 11:52 AM
Im using a command button to do the following:

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

but when it executes, it opens like 10 telnet windows, and all are blank except one, which says:
Quote127.0.0.1 6112o 127.0.0.1 6112o 127.0.0.1 6112o 127.0.0.1 6112o 127.0.0.1 6112
any ideas on what im doing wrong, or any other way to send keys to a program?
Title: Re: SendKeys VB Function
Post by: Grok on February 07, 2003, 02:22 PM
you're probably calling function that contains that code 10 times.
Title: Re: SendKeys VB Function
Post by: Banana fanna fo fanna on February 07, 2003, 02:29 PM
only shell once, on startup
also use appactivate
Title: Re: SendKeys VB Function
Post by: Mesiah / haiseM on February 07, 2003, 04:05 PM
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..
Title: Re: SendKeys VB Function
Post by: K on February 07, 2003, 04:11 PM
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.
Title: Re: SendKeys VB Function
Post by: Mesiah / haiseM on February 07, 2003, 04:26 PM
ooo good idea, silly me. thnx
Title: Re: SendKeys VB Function
Post by: iago on February 07, 2003, 10:50 PM
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)
Title: Re: SendKeys VB Function
Post by: ILurker on February 09, 2003, 05:12 AM
SendKeys, "keyshere"
Your forgot the ","
 ;)
Title: Re: SendKeys VB Function
Post by: Mesiah / haiseM on February 09, 2003, 01:29 PM
? why would i need that? and if thats alone in a line of code, that would probably be invalid syntax...
Title: Re: SendKeys VB Function
Post by: indulgence on February 12, 2003, 06:28 PM
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
Title: Re: SendKeys VB Function
Post by: Mesiah / haiseM on February 13, 2003, 10:42 AM
i changed my code, i no longer use sendkeys.