Windows 发送特定应用程序的密钥
我的要求是自动切换Internet Explorer的多个选项卡。在浏览了web和stackoverflow之后,我将附带的解决方案.vbs文件称为-Windows 发送特定应用程序的密钥,windows,batch-file,browser,scheduled-tasks,monitoring,Windows,Batch File,Browser,Scheduled Tasks,Monitoring,我的要求是自动切换Internet Explorer的多个选项卡。在浏览了web和stackoverflow之后,我将附带的解决方案.vbs文件称为- Set WshShell = WScript.CreateObject("WScript.Shell") while 1 WshShell.AppActivate "Internet Explorer" WScript.Sleep 7000 WshShell.SendKeys("^{TAB}") wend 但是这种方法的
Set WshShell = WScript.CreateObject("WScript.Shell")
while 1
WshShell.AppActivate "Internet Explorer"
WScript.Sleep 7000
WshShell.SendKeys("^{TAB}")
wend
但是这种方法的问题是它将密钥发送给所有活动的应用程序。
我需要它来触发Internet Explorer的密钥。
请帮忙。
提前谢谢。没问题。
我可以使用C#脚本实现这一点-
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace SendKeyAppDemo
{
class Program
{
[DllImport("User32.dll")]
private static extern int SetForegroundWindow(IntPtr ptr);
static void Main(string[] args)
{
Process p = Process.GetProcessesByName("iexplore").FirstOrDefault();
if (p.ProcessName == "iexplore")
{
while (true)
{
IntPtr h = p.MainWindowHandle;
SetForegroundWindow(h);
SendKeys.SendWait("^{TAB}");
Thread.Sleep(5000);
}
}
}
}
}