Hi again,
I'm really trying to get VB 2005. I want to use sendkeys. The example given by Microsoft is:
VB Code:
Dim ProcID As Integer ' Start the Calculator application, and store the process id. ProcID = Shell("CALC.EXE", AppWinStyle.NormalFocus) ' Activate the Calculator application. AppActivate(ProcID) ' Send the keystrokes to the Calculator application. My.Computer.Keyboard.SendKeys("22", True) My.Computer.Keyboard.SendKeys("*", True) My.Computer.Keyboard.SendKeys("44", True) My.Computer.Keyboard.SendKeys("=", True) ' The result is 22 * 44 = 968.
The code works. If I modify this example to:VB Code:
Dim ProcID As Integer ' Start the Calculator application, and store the process id. ProcID = Shell("c:\windows\notepad.EXE", AppWinStyle.NormalFocus) ' Activate the Calculator application. AppActivate(ProcID) ' Send the keystrokes to the Calculator application. My.Computer.Keyboard.SendKeys("22", True) My.Computer.Keyboard.SendKeys("*", True) My.Computer.Keyboard.SendKeys("44", True) My.Computer.Keyboard.SendKeys("=", True) ' The result is 22 * 44 = 968.
(opening notepad instead of calc) it still works. however, If I try to do something that would actually have some real world use:
VB Code:
Dim ProcID As Integer ' Start the Calculator application, and store the process id. ProcID = Shell("C:\Program Files\Mozilla Firefox\firefox.exe", AppWinStyle.NormalFocus) ' Activate the Calculator application. AppActivate(ProcID) ' Send the keystrokes to the Calculator application. My.Computer.Keyboard.SendKeys("22", True) My.Computer.Keyboard.SendKeys("*", True) My.Computer.Keyboard.SendKeys("44", True) My.Computer.Keyboard.SendKeys("=", True) ' The result is 22 * 44 = 968.
The AppAtivate line halts the Program with:
System.ArgumentException was unhandled
Message="Process '3380' was not found."
Of course 3380 is the value returned from the shell call. I don't get it. Someone PLEASE exlain why this code doesn't work.




Reply With Quote