此示例使用 Shell 函数启动计算器应用程序,然后通过使用 SendKeys 类的 SendWait 方法发送击键来将两个数值相乘。
示例
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) SendKeys.SendWait("22") SendKeys.SendWait("*") SendKeys.SendWait("44") SendKeys.SendWait("=")
编译代码
此示例需要:
- 对 System.Windows.Forms 命名空间的引用。