2017-04-24 1 views
0

필자의 요구 사항은 Internet Explorer의 여러 탭을 자동으로 토글하는 것입니다. 웹 및 유래 찾고 후 나는 같은 솔루션 .VBS 파일과 함께 올 this을 언급 -특정 응용 프로그램에 SendKey 보내기

Set WshShell = WScript.CreateObject("WScript.Shell") 
while 1 
    WshShell.AppActivate "Internet Explorer" 
    WScript.Sleep 7000 
    WshShell.SendKeys("^{TAB}") 
wend 

그러나이 방법의 문제는 모든 활성 응용 프로그램에 키를 보낸다. Internet Explorer에만 키를 트리거해야합니다. 도와주세요. 미리 감사드립니다.

답변

0

문제 없습니다. 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); 
       } 

      } 
     } 
    } 
} 
관련 문제