-
AutoIt으로 열려있는 창 핸들 가져올 수 있어?프로그램(C# etc.) 2023. 1. 10. 21:47
물론입니다! 다음은 프로세스를 사용하는 방법에 대한 예입니다.C#에서 Start() 메서드를 사용하여 AutoIt 스크립트를 시작하고 현재 열려 있는 창의 핸들을 가져옵니다:
using System; using System.Diagnostics; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; class Example { static void Main(string[] args) { IWebDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl("http://www.example.com"); // Do something that causes a window to open, e.g. click a button IWebElement button = driver.FindElement(By.Id("button1")); button.Click(); // Start the AutoIt script that retrieves the window handle ProcessStartInfo startInfo = new ProcessStartInfo("path\\to\\autoit-script.exe"); startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.Arguments = "MyWindow"; Process.Start(startInfo); // Continue interacting with the browser // ... } }
이 예에서는 이 단추를 클릭한 후 스크립트가 숨겨진 창 스타일로 AutoIt 스크립트를 시작하고 창 제목을 인수로 전달합니다. 이 스크립트는 창 핸들 가져오기를 처리하는 스크립트입니다.
다음은 제목을 기준으로 창 핸들을 가져오고 스크립트 종료 코드에서 핸들을 반환하는 데 사용할 수 있는 AutoIt 스크립트의 예입니다.; retrieve the window handle $handle = WinGetHandle("MyWindow") ; return the handle as the script exit code Exit($handle)
C# 코드에서 Process를 사용할 수 있습니다.시작(StartInfo).자동 편집 스크립트에서 창 핸들을 반환하려면 코드를 종료하십시오.
그런 다음 자동 편집 스크립트 WinClose($handle)를 사용하여 창을 닫거나 ControlSend($handle)를 사용하여 창 컨트롤과 상호 작용하는 등 필요에 따라 핸들을 사용할 수 있습니다
이 코드가 실행 중인 시스템에 AutoIt가 설치되어 있어야 하며 경로는 \\to\autoit-script입니다.exe는 시스템의 AutoIt 스크립트에 대한 실제 경로로 대체해야 합니다.
다른 질문이 있거나 도움이 필요한 사항이 있으면 알려주세요.'프로그램(C# etc.)' 카테고리의 다른 글
ChromeDriver에서 띄운 파일선택창을 autoit으로 컨트롤하는 코드 (0) 2023.01.11 autoit 사용법 좀 자세히 알려줘 (0) 2023.01.11 Thread로 계산영역 빼기 (0) 2022.12.29 StreamReader 한줄씩 세지말고, 한번에 마지막 줄수 알수 있는 메서드? (0) 2022.12.29 sleep 사용법 알려줘 (0) 2022.12.29