Sendkeys Problem

Posts 1–6 of 6 · Page 1 of 1
Sendkeys Problem
Okay, I know this seems simple enough but I just can't get anything to work. Might just by my ignorance..anyway..I have my application running and when I try to sendkeys.send("w") or ("^w") it will of course send the keys to itself. I tried AppActivate to activate the window I want the keys sent to and I get an error of "Process "xxxx" was not found." The x's are 4 numbers. I forget what else I tried but they have all failed for me. If anyone could give me some insight it would be much appreciated. It would also help if you added me on AIM. Gunplexityyy is my username.
Quote Originally Posted by AuXFire View Post
Okay, I know this seems simple enough but I just can't get anything to work. Might just by my ignorance..anyway..I have my application running and when I try to sendkeys.send("w") or ("^w") it will of course send the keys to itself. I tried AppActivate to activate the window I want the keys sent to and I get an error of "Process "xxxx" was not found." The x's are 4 numbers. I forget what else I tried but they have all failed for me. If anyone could give me some insight it would be much appreciated. It would also help if you added me on AIM. Gunplexityyy is my username.
Erm, AppActivate required a legit process ID. Try like this:

[highlight=vb.net]
Private Function getProcessID(ByVal procName as string) as integer
dim procs as process() = process.getprocessesbyname(procName)
if procs.length > 0
return procs(0).id
else
return -1
end if
End function
[/highlight]


[highlight=vb.net]
dim pid as integer = getProcessID("notepad") 'attempt to get the process ID for notepad.
if pid > -1 Then 'make sure we got a valid ID, -1 is returned if unable to find the process
AppActivate(pid)
SendKeys.SendWait("Hello World")
Else
MessageBox.Show("Unable to find process")
End If
[/highlight]
Where exactly would I add this? You wouldn't mind doing teamviewer so I could explain a little bit better would you?
Quote Originally Posted by AuXFire View Post
Where exactly would I add this? You wouldn't mind doing teamviewer so I could explain a little bit better would you?
Add the first code section anywhere (outside of any subs or functions, but inside your class) and add the second section wherever you want to do your sending
It didn't work. Maybe I should add that the window I am trying to send the keys to is a desktop flash game.
Any other ideas? If you would like I could show you what I have so far.
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us