static void Main(string[] args) { //IWebDriver driver = new FirefoxDriver(); //driver.Navigate().GoToUrl("http://www.google.com"); // AutoItX.Run("calc.exe", ""); //AutoItX.Sleep(5000); // AutoItX.("Calculator", "", "[CLASS:Button; INSTANCE:14]"); //AutoItX.ControlClick("Calculator", "", "139", "Left"); //AutoItX.ControlClick("Calculator", "", "135", "Left"); //AutoItX.ControlClick("Calculator", "", "94", "Left"); //AutoItX.ControlClick("Calculator", "", "132", "Left"); //AutoItX.ControlClick("Calculator", "", "121", "Left"); // Thread.Sleep(5000); //driver.Manage().Window.Maximize(); //driver.Navigate().GoToUrl("http://spreadsheetpage.com/index.php/file/C35/P10/"); //driver.FindElement(By.LinkText("smilechart.xls")).Click(); //AutoItX.WinWaitActive("Opening smilechart.xls"); //AutoItX.WinKill(); AutoItX.Run("explorer.exe d:\\", "", 1); AutoItX.WinWaitActive("Untitled"); AutoItX.Send("I'm in notepad I'm in notepad I'm in notepad I'm in notepad I'm in notepad"); AutoItX.WinClose(); Thread.Sleep(3000); AutoItX.WinWaitActive("Notepad"); AutoItX.ControlClick("Notepad", "&Save", "Button1"); }
static void Run(string exePath, string account, string password) { bool existsMainWindow = ExistsMainWindow(); int processId = 0; if (!existsMainWindow) { processId = AutoItX.Run(exePath, Path.GetDirectoryName(exePath)); if (processId == 0) { throw new InvalidOperationException( string.Format("Failed to run {0}", exePath)); } } try { if (!existsMainWindow) { Login(account, password); } ExportData(); } finally { if (processId != 0) { AutoItX.ProcessClose(processId.ToString()); } } }
public static void LogIN() { Process[] isClud = Process.GetProcessesByName("THCludSuit"); // 主目錄 // 測試"看診清單"是否有打開 if (isClud.Length == 0) { AutoItX.Run(@"C:\Program Files (x86)\THESE\杏雲醫療資訊系統\THCloudStarter.exe", @"C:\Program Files (x86)\THESE\杏雲醫療資訊系統\"); //; Wait for the Notepad to become active. The classname "Notepad" Is monitored instead of the window title AutoItX.WinWaitActive("登入畫面"); //; Now that the Notepad window Is active type some text if (AutoItX.ControlGetText("登入畫面", "", "[NAME:txtHospitalExtensionCode]") != "A") { AutoItX.ControlClick("登入畫面", "", "[NAME:txtHospitalExtensionCode]", "LEFT", 2); AutoItX.ControlSend("登入畫面", "", "[NAME:txtHospitalExtensionCode]", "A"); } AutoItX.ControlSend("登入畫面", "", "[NAME:txtPassword]", "IlovePierce4926"); AutoItX.Sleep(500); // [NAME:btnLogin] //AutoItX.ControlClick("登入畫面", "", "[NAME:picLogin]"); AutoItX.ControlClick("登入畫面", "", "[NAME:btnLogin]"); AutoItX.WinActivate("杏雲雲端醫療服務"); AutoItX.WinWaitActive("杏雲雲端醫療服務"); AutoItX.Sleep(2000); } else { AutoItX.WinActivate("杏雲雲端醫療服務"); } }
private RobotResult DoOpenClientApp(RobotContext context) { try { int processExists = AutoItX.ProcessExists(ProcessName); if (processExists != 0) { int processClose = AutoItX.ProcessClose(ProcessName); if (processClose == AutoItXSuccess) { LOG.Log(LogLevel.Debug, "TransactionId<{0}>, Kill old process<{1}> done", context.MidasTransactionId, processExists); } } if (AutoItX.WinExists(LoginFormTitle) != AutoItXSuccess) { AutoItX.Run(ProgramFullPath, ""); int errorHappen1 = AutoItX.WinWaitActive(LoginFormTitle, "", 5); if (errorHappen1 == AutoItXSuccess) { Thread.Sleep(TimeSpan.FromSeconds(3)); } else { LOG.Error("TransactionId<{0}>, App<{1}> not found", context.MidasTransactionId, ProgramFullPath); throw new Exception("Open App Failed, Error<App Location Not Found>"); } } return(RobotResult.Build(context, RobotStatus.SUCCESS, "Open Client App Success!")); } catch (Exception e) { return(RobotResult.Build(context, RobotStatus.ERROR, e.Message)); } }
public void EditInNotepad() { logger.Info("Executing keyword 'EditInNotepad'"); IntPtr winHandle; int pid = AutoItX.Run("notepad.exe", "."); winHandle = GetProcessHandel(pid); if (AutoItX.WinWaitActive(winHandle, timeout: 10) != 1) { output.SetError("Error waiting for the Notepad window ."); return; } AutoItX.Send("This is an AutoIt test using step"); if (AutoItX.WinKill(winHandle) != 1) { output.SetError("Error closing the Notepad window"); return; } if (AutoItX.WinWaitClose(winHandle, timeout: 10) != 1) { output.SetError("Error waiting for the Notepad window to close"); return; } }
public void Run(string program, string dir) { if (wait_time > 0) { AutoItX.Sleep(wait_time); } AutoItX.Run(program, dir); }
public void OpenAndLogin(string username, string password) { //AutoItX.Run("calc.exe", "", 1); AutoItX.Run("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe http://my-lab-drop2.telecomputing.com", "", 1); AutoItX.WinActivate("Authentication required", ""); SendKeys.SendWait(username); }
public void OpenAndWrite(string text) { AutoItX.Run("notepad.exe", "", 1); AutoItX.WinWaitActive("Untitled"); AutoItX.Send(text); IntPtr winHandle = AutoItX.WinGetHandle("Untitled"); AutoItX.WinKill(winHandle); }
static void TestNotepad() { AutoItX.Run("notepad.exe", "D:/MIDAS/CMB2"); AutoItX.WinWaitActive("Untitled - Notepad"); AutoItX.Send("This is some text."); AutoItX.WinClose("Untitled - Notepad"); AutoItX.WinWaitActive("Notepad", "Cancel"); //AutoItX.Send("!n"); }
public ApplicationManager() { AutoItX.Run(@"D:\FreeAddressBookPortable\AddressBook.exe", "", 1); AutoItX.WinWait(PROGRAM_TITLE); AutoItX.WinActivate(PROGRAM_TITLE); AutoItX.WinWaitActive(PROGRAM_TITLE); GroupHelper = new GroupHelper(this); }
static void Main(string[] args) { AutoItX.Run("notepad.exe", ""); AutoItX.WinWaitActive("Untitled"); AutoItX.Send("I'm in notepad"); AutoItX.Sleep(10000); IntPtr winHandle = AutoItX.WinGetHandle("Untitled"); AutoItX.WinKill(winHandle); }
public static int Run(string strRun, string strDir = "", int nShowFlags = 1) { var result = AutoItX.Run(strRun, strDir, nShowFlags); if (result == 0) { throw new AutoItException("Failed to run process", AutoItX.ErrorCode()); } return(result); }
public void OpenAndParseVk() { HttpWebRequest request = WebRequest.CreateHttp(VkId); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader streamReader = new StreamReader(response.GetResponseStream()); string html = streamReader.ReadToEnd(); Match match = regex.Match(html); Status = match.Groups[1].Value; var bbb = AutoItX.Run("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe " + VkId, ""); }
private void MySerialReceived(object s, EventArgs e) //여기에서 수신 데이타를 사용자의 용도에 따라 처리한다. { if (serialPort1.BytesToRead > 0) { try { string ReceiveData = serialPort1.ReadExisting(); //시리얼 버터에 수신된 데이타를 ReceiveData 읽어오기 richTextBox_received.Text = richTextBox_received.Text + ReceiveData; String RCVData = ReceiveData; //String RCVData; //RCVData = serialPort1.ReadExisting(); //SendKeys.Send(RCVData.ToString()); String[] Preset_Data = System.IO.File.ReadAllLines(savePath); string data = Preset_Data[comboBox_preset.SelectedIndex]; String[] Event_lisr_handle = (Event_list[Convert.ToInt32(RCVData)].Split('_')); if (Event_lisr_handle[0] == "Send") { try { AutoItX.Send(Event_list[Convert.ToInt32(RCVData)].Replace("Send_", "")); //richTextBox_received.Text+=Event_list[Convert.ToInt32(RCVData)].Replace("Send_", ""); } catch { } } else if (Event_lisr_handle[0] == "Run") { try { AutoItX.Run(Event_list[Convert.ToInt32(RCVData)].Replace("Run_", ""), ""); } catch { } } else { try { AutoItX.Send(Event_list[Convert.ToInt32(RCVData)], 1); } catch { } } } catch { } } }
private void OpenCiscoVPN() { if (File.Exists(ciscoExePath)) { AutoItX.Run(ciscoExePath, "", 1); } else { ShowErrorPopup("'INSTALL CiscoVPN' or 'Enter the correct path in CONFIG file'."); } }
delegate void d_Call_Au3_Run(string program, string dir);//创建一个代理 public void Au3_Run(string program, string dir) { if (!this.InvokeRequired) { AutoItX.Run(program, dir); } else { d_Call_Au3_Run a1 = new d_Call_Au3_Run(Call_Notifiction); Invoke(a1, new object[] { program, dir }); } }
/// <summary> /// /// </summary> /// <param name="path">Ścieżka do przeglądarki FireFox</param> /// <param name="param">Strona do uruchomienia</param> public int startFF(string dir, string param) { var iPID = AutoItX.Run("firefox.exe https://przegladarka-ekw.ms.gov.pl/eukw_prz/KsiegiWieczyste/wyszukiwanieKW", dir); if (AutoItX.WinWaitActive("EUKW - Prezentacja Księgi Wieczystej - Mozilla Firefox", "30") == 1) { return(1); } else { throw new System.ArgumentException("Przekroczony limit czasu oczekiwania"); } }
/// <summary> /// Powers On the Video Recorder. /// </summary> public void PowerOn() { lock (_syncObj) { _isRecording = false; AutoItX.AutoItSetOption("WinTitleMatchMode", 2); if (0 == AutoItX.WinExists(ObsWindowTitle)) { AutoItX.Run(GameShareRootDirectory + @"\obsRun.bat", GameShareRootDirectory); } AutoItX.WinActivate(ObsWindowTitle); } }
private void btnEditScript_Click(object sender, EventArgs e) { if (File.Exists(SCRIPT_FILE)) { #if DEBUG var ret = AutoItX.Run($"notepad2 /s cs {SCRIPT_FILE}", APPFOLDER); //var ret = AutoItX.RunWait($"notepad2 /s cs {sf}", APPFOLDER); //if (ret == 0 && engine is ScriptEngine) engine.ScriptContext = File.ReadAllText(sf); //else MessageBox.Show("notepad2 run failed!"); #else AutoItX.Run($"notepad2 /s cs {SCRIPT_FILE}", APPFOLDER); #endif } }
public void StartRELYApp() { try { AutoItX.Run("D:\\TCS\\NBW64.exe", "D:\\", AutoItX.SW_SHOW); //NBW64_7.exe AutoItX.Sleep(2000); AutoItX.Send("{Enter}"); AutoItX.Sleep(2000); AutoItX.Send("KB"); AutoItX.Sleep(2000); AutoItX.Send("{Enter}"); AutoItX.Sleep(2000); /*Enter Company Code and Press ENTER Key for LOGIN to Company Menu*/ AutoItX.Send("AUT19"); AutoItX.Send("{Enter}"); AutoItX.Sleep(2000); Console.WriteLine("LOGIN Successfully to AUT19"); AutoItX.Send("{Enter}"); AutoItX.Sleep(2000); AutoItX.Send("{Enter} {Enter}"); AutoItX.Sleep(2000); AutoItX.Send("SUPER"); AutoItX.Sleep(2000); AutoItX.Send("{ENTER} {Enter}"); AutoItX.Sleep(2000); AutoItX.Send("{ESC}"); AutoItX.Sleep(1000); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(ex.StackTrace); Console.WriteLine(); MessageBox.Show("Error occured in RELY.." + " " + AutoItX.ErrorCode()); } }
private void button1_Click(object sender, EventArgs e) { if (AutoItX.WinActivate("EUKW - Prezentacja Księgi Wieczystej - Mozilla Firefox", "") == 1) { MessageBox.Show("okno aktywne"); } else { DialogResult dialogResult = MessageBox.Show("Czy uruchomić stronę EKW?", "Komunikat", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { var iPID = AutoItX.Run(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe https://przegladarka-ekw.ms.gov.pl/eukw_prz/KsiegiWieczyste/wyszukiwanieKW?komunikaty=true&kontakt=true&okienkoSerwisowe=false", "", 1); } } }
public void MyMethod() { // Wow, this is C#! AutoItX.Run("notepad.exe", "", AutoItX.SW_SHOW); AutoItX.WinWaitActive("Untitled"); AutoItX.Send("I'm in notepad{Enter}{Enter}"); AutoItX.Send("From AutoItX in C{#}{Enter}{Enter}"); AutoItX.Send("From C{#} in AutoIt through .NET Framework{Enter}"); //MessageBox.Show("" + AutoItX.WinGetHandleAsText()); MessageBox.Show("All windows class are : " + AutoItX.WinGetClassList()); Thread.Sleep(5000); IntPtr winHandle = AutoItX.WinGetHandle("Untitled"); AutoItX.WinKill(winHandle); }
private AppManager() { AutoItX.Run("mspaint.exe", "C:\\WINDOWS\\system32"); AutoItX.WinWaitActive("Безымянный"); winHandle = AutoItX.WinGetHandle("Безымянный"); /* * Code for a greater good. Amen * */ if (AutoItX.WinGetState(winHandle) < 32) // 32 - флаг неполностью развернутого окна { AutoItX.WinSetState(winHandle, AutoItX.SW_MAXIMIZE); } propX = AutoItX.WinGetClientSize(winHandle).Width / 1920f; // пропорции относительно экрана разработчика propY = AutoItX.WinGetClientSize(winHandle).Height / 875f; colourHelper = new ColourHelper(this); drawHelper = new DrawHelper(this); functionsHelper = new FunctionsHelper(this); }
/// <summary> /// 启动游戏进程 /// </summary> /// <returns></returns> internal static bool StartProcess() { AutoItX.AutoItSetOption("WinTitleMatchMode", 3); // 1971477531 国际服 1781625612 国服 // 程序路径 var programPath = Registry.GetValue( @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\GOG.com\Games\1971477531", "exe", null); // 工作目录 var workingDir = Registry.GetValue( @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\GOG.com\Games\1971477531", "workingDir", null); if (programPath.ToString() == string.Empty) { programPath = ConfigurationManager.AppSettings.Get("GamePath"); } do { CloseCrashReport(); AutoItX.Run(programPath.ToString(), workingDir.ToString()); // 等待窗口出现 AutoItX.WinWait("Gwent"); CloseCrashReport(); // 等待窗口被激活 AutoItX.WinActivate("Gwent"); } while (!WindowExists()); // 重置最新页面创建时间差(间隔) PageObject.ResetLastCreationTimePage(); return(WindowExists()); }
public int Run(string program, string dir, int showFlag = 1) { return(AutoItX.Run(program, dir, showFlag)); }
private void button1_Click(object sender, EventArgs e) { AutoItX.Send("{VOLUME_DOWN}"); AutoItX.Run("Notepad.exe", ""); }
public async void Convert() { // 20190608 created, 現在要匯入批價檔 #region Environment try { // 營造環境 Process[] isAdvn = Process.GetProcessesByName("THCAdvancedBillingReport"); if (isAdvn.Length == 0) // 測試"日報表清單"是否有打開 { // 有無登入系統? Thesis.LogIN(); // 如果沒有打開就打開"日報表清單" AutoItX.Run(@"C:\Program Files (x86)\THESE\杏雲醫療資訊系統\THCAdvancedBillingReport.exe", @"C:\Program Files (x86)\THESE\杏雲醫療資訊系統\"); System.Threading.Thread.Sleep(300); } // [FrmMain] v1.0.0.67 AutoItX.WinWaitActive("[FrmMain] v"); // [NAME:btnDailyIncome] // 按下去 AutoItX.ControlClick("[FrmMain] v", "", "[NAME:btnDailyIncome]"); AutoItX.WinWaitActive("日收入報表A"); // 日收入報表A // [NAME:chk允許完整筆數呈現] AutoItX.ControlClick("日收入報表A", "", "[NAME:chk允許完整筆數呈現]"); // [NAME:chkIncludeInvalid] AutoItX.ControlClick("日收入報表A", "", "[NAME:chkIncludeInvalid]"); BeginDate = $"{_begindate.Year}{(_begindate.Month + 100).ToString().Substring(1)}{(_begindate.Day + 100).ToString().Substring(1)}"; EndDate = $"{_enddate.Year}{(_enddate.Month + 100).ToString().Substring(1)}{(_enddate.Day + 100).ToString().Substring(1)}"; string Execution = $"C:\\vpn\\exe\\changeBillDTP.exe {BeginDate}{EndDate}"; AutoItX.Run(Execution, @"C:\vpn\exe\"); log.Info($"執行changeBillDTP "); } catch (Exception ex) { Logging.Record_error(ex.Message); log.Error(ex.Message); } #endregion Environment // 資料都從excel檔讀進記憶體, 也寫入csv檔 Dictionary <string, object[, ]> data = RetrievePIJIA(); // 空值就結束, 沒有後面什麼事 if (data is null) { return; } string strYM = $"{_begindate.Year - 1911}{(_begindate.Month + 100).ToString().Substring(1)}"; List <Task <PIJIAresult> > tasks = new List <Task <PIJIAresult> >(); #region 進行讀取資料 // 20190609 created // 模仿匯入opd // add及update, update要清空CASENO, G // 20190612 重大修改,key值改為三個YM, bid, uid, 原因是bid在同一個月內重複太多了 // 用varchar, 不要用varchar,不然比較時會出錯, VDATE空值仍會有8個空白 try { // 開始回圈 // 讀取每一筆檔案 log.Info($"begin async process."); foreach (var d in data) { // 20200519 程式碼移出, 程式不那麼臃腫, 較好維護 tasks.Add(WriteIntoSQL_async(d.Value, strYM)); } PIJIAresult[] result = await Task.WhenAll(tasks); int total_NewPIJIA = (from p in result select p.NewPIJIA).Sum(); int total_ChangePIJIA = (from p in result select p.ChangePIJIA).Sum(); int total_AllPIJIA = (from p in result select p.AllPIJIA).Sum(); log.Info($"end async process."); string output = $"共處理{total_AllPIJIA}筆資料, 其中{total_NewPIJIA}筆新批價, 修改{total_ChangePIJIA}筆批價."; log.Info(output); tb.ShowBalloonTip("完成", output, BalloonIcon.Info); Logging.Record_admin("PIJIA add/change", output); // 20200522 為何這裡有個return? 除掉就可以用後面的matching了 //return; } catch (Exception ex) { Logging.Record_error(ex.Message); } #endregion 進行讀取資料 // 20200519 移出程式碼, 不要顯得太臃腫 Matching(); }
public void Convert() { log.Info(" Begin Convert."); string output; #region Environment try { // 營造環境 log.Info(" Check 處方清單."); if (AutoItX.WinExists("處方清單") == 1) //如果直接存在就直接叫用 { AutoItX.WinActivate("處方清單"); log.Info(" 處方清單 exists."); } else { log.Info(" 處方清單 doesn't exist."); Thesis.LogIN(); // 打開"處方清單", 找不到control,只好用mouse去按 AutoItX.WinActivate("杏雲雲端醫療服務"); // 先maximize AutoItX.WinSetState("杏雲雲端醫療服務", "", 3); //0 close; 1 @SW_RESTORE; 2 @SW_MINIMIZE; 3 @SW_MAXIMIZE AutoItX.MouseMove(280, 280); AutoItX.MouseClick(); AutoItX.Sleep(500); AutoItX.ControlClick("杏雲雲端醫療服務", "", "[NAME:btnPrescription]"); log.Info(" 處方清單 opened."); Thread.Sleep(10000); } // 打開備份 AutoItX.WinWaitActive("處方清單"); AutoItX.ControlClick("處方清單", "", "[NAME:btnBackup]"); log.Info(" 處方清單 exists."); AutoItX.WinActivate("處方清單備份選項"); AutoItX.WinWaitActive("處方清單備份選項"); AutoItX.ControlClick("處方清單備份選項", "", "[NAME:txbBackupPath]", "LEFT", 2); AutoItX.Send("{Tab}"); AutoItX.Send("{Tab}"); AutoItX.Send("{Enter}"); // first choice Desktop // 這裡的等待很重要, 太短來不及讀, 500可以, 100 不行, 200 一半一半, 250 100% AutoItX.Sleep(300); // 尋找XML, 若有就刪除 output = AutoItX.ControlGetText("處方清單備份選項", "", "[NAME:txbBackupPath]"); output += $"\\{_begindate.Year}\\{_begindate.Year}{(_begindate.Month + 100).ToString().Substring(1)}.xml"; if (System.IO.File.Exists(output)) { System.IO.File.Delete(output); } log.Info(" Kill xml files."); // AutoItX.ControlSend("處方清單備份選項", "", "[NAME:txbBackupPath]", "C:\vpn") } catch (Exception ex) { output = string.Empty; log.Error($" Error. {ex.Message}"); Logging.Record_error(ex.Message); } #endregion Environment #region Producing XML string BeginDate = $"{_begindate.Year}{(_begindate.Month + 100).ToString().Substring(1)}{(_begindate.Day + 100).ToString().Substring(1)}"; string EndDate = $"{_enddate.Year}{(_enddate.Month + 100).ToString().Substring(1)}{(_enddate.Day + 100).ToString().Substring(1)}"; // changePresDTP 是用AutoIT VB寫成的, 功能專一是針對「處方清單備份選項」的起迄日 [NAME:dtpSDate], [NAME:dtpEDate] // 只有一個參數, 格式為YYYYMMDDYYYYMMDD, 前面8碼是起始日, 後面8碼是結束日 string Execution = $"C:\\vpn\\exe\\changePresDTP.exe {BeginDate}{EndDate}"; AutoItX.Run(Execution, @"C:\vpn\exe\"); // 檢查XML做好了嗎? do { // log.Info(" Wait for xml to build."); // 好多紀錄啊, 大約4.9 秒 Thread.Sleep(100); } while (!System.IO.File.Exists(output)); // XML好了就把頁面關掉 AutoItX.Sleep(500); AutoItX.ControlClick("處方清單備份選項", "", "[NAME:Cancel_Button]"); AutoItX.Sleep(100); AutoItX.ControlClick("處方清單", "", "[NAME:BtnEXIT]"); #endregion Producing XML OPDconvert o = new OPDconvert(output); o.Transform(); log.Info(" End Convert."); }
private void wyszukajKsiege(string _kw) { string[] separator = { @"/" }; string[] result = _kw.Split(separator, StringSplitOptions.RemoveEmptyEntries); try { if (AutoItX.WinActivate("EUKW - Prezentacja Księgi Wieczystej - Mozilla Firefox", "") == 1) { string numer_ksiegi = result[1]; string cyfra_kontrolna = result[2]; var notification = new System.Windows.Forms.NotifyIcon() { Visible = true, Icon = System.Drawing.SystemIcons.Information, BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info, BalloonTipTitle = "AutoIT - Ksiei Wieczyste", BalloonTipText = "Trwa pobieranie danych z księgi wieczystej: SR2W/" + numer_ksiegi + '/' + cyfra_kontrolna, }; notification.ShowBalloonTip(5000); //Przesuń i wpisz sąd AutoItX.MouseMove(2433, 464, 1); AutoItX.Sleep(500); AutoItX.MouseClick(); AutoItX.Send("SR2W"); AutoItX.Send("{TAB}"); AutoItX.Sleep(500); //Wpisz numer księgi AutoItX.Send(numer_ksiegi); AutoItX.Send("{TAB}"); AutoItX.Sleep(500); //Wpisz cyfrę kontrolną AutoItX.Send(cyfra_kontrolna); AutoItX.Sleep(500); //przesuń nad google captcha AutoItX.MouseMove(2433, 546); AutoItX.Sleep(500); AutoItX.MouseClick(); AutoItX.Sleep(4000); //wyszukaj księge AutoItX.MouseMove(2933, 685); AutoItX.Sleep(500); AutoItX.MouseClick(); AutoItX.Sleep(6000); //Przeglądanie aktualnej treści KW AutoItX.MouseMove(2229, 797); AutoItX.Sleep(500); AutoItX.MouseClick(); AutoItX.Sleep(5000); //Dzial III AutoItX.MouseMove(2512, 219); AutoItX.MouseClick(); AutoItX.Sleep(600); AutoItX.Send("^u"); AutoItX.Sleep(600); AutoItX.Send("^a"); AutoItX.Sleep(500); AutoItX.Send("^c"); AutoItX.Send("^{F4}"); AutoItX.Sleep(1000); dzial_III = Clipboard.GetText(); AutoItX.Sleep(500); //DZIAL II AutoItX.MouseMove(2349, 219); AutoItX.Sleep(500); AutoItX.MouseClick(); AutoItX.Sleep(500); AutoItX.Send("^u"); AutoItX.Sleep(600); AutoItX.Send("^a"); AutoItX.Sleep(500); AutoItX.Send("^c"); AutoItX.Send("^{F4}"); AutoItX.Sleep(1000); dzial_II = Clipboard.GetText(); AutoItX.Sleep(500); //DZIAL I-sp AutoItX.MouseMove(2176, 219); AutoItX.Sleep(500); AutoItX.MouseClick(); AutoItX.Sleep(500); AutoItX.Send("^u"); AutoItX.Sleep(600); AutoItX.Send("^a"); AutoItX.Sleep(500); AutoItX.Send("^c"); AutoItX.Send("^{F4}"); AutoItX.Sleep(1000); dzial_Isp = Clipboard.GetText(); AutoItX.Sleep(500); //DZIAL I-O AutoItX.MouseMove(1970, 219); AutoItX.Sleep(500); AutoItX.MouseClick(); AutoItX.Sleep(500); AutoItX.Send("^u"); AutoItX.Sleep(600); AutoItX.Send("^a"); AutoItX.Sleep(500); AutoItX.Send("^c"); AutoItX.Send("^{F4}"); AutoItX.Sleep(1000); dzial_Io = Clipboard.GetText(); AutoItX.Sleep(500); //Powrót do początku AutoItX.Send("{END}"); AutoItX.MouseMove(1970, 946); AutoItX.Sleep(500); AutoItX.MouseClick(); AutoItX.Sleep(1500); AutoItX.Send("{END}"); AutoItX.Sleep(500); AutoItX.MouseMove(2662, 748); AutoItX.Sleep(500); AutoItX.MouseClick(); richTextBox1.AppendText(dzial_III); richTextBox2.AppendText(dzial_II); richTextBox3.AppendText(dzial_Isp); richTextBox4.AppendText(dzial_Io); StringBuilder numerKsiegi = new StringBuilder(); numerKsiegi.Append("SR2W/"); numerKsiegi.Append(numer_ksiegi); numerKsiegi.Append("/"); numerKsiegi.Append(cyfra_kontrolna); dodajKsiegeDoBazy(numerKsiegi.ToString(), dzial_III, dzial_II, dzial_Isp, dzial_Io); } else { DialogResult dialogResult = MessageBox.Show("Czy uruchomić stronę EKW?", "Komunikat", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { var iPID = AutoItX.Run(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe https://przegladarka-ekw.ms.gov.pl/eukw_prz/KsiegiWieczyste/wyszukiwanieKW?komunikaty=true&kontakt=true&okienkoSerwisowe=false", "", 1); } } } catch (Exception x) { MessageBox.Show(x.ToString()); throw; } }
public void Change() { // Dim output As DEP_return = Change_DEP(strYM) // MessageBox.Show("修改了" + output.m.ToString + "筆, 請匯入門診資料") string savepath = @"C:\vpn\change_dep"; int change_N; DateTime minD; DateTime maxD; List <sp_change_depResult> ListChange; // 存放目錄,不存在就要建立一個 if (!(System.IO.Directory.Exists(savepath))) { System.IO.Directory.CreateDirectory(savepath); } #region Making CSV try { // 呼叫SQL stored procedure using (CSDataContext dc = new CSDataContext()) { ListChange = dc.sp_change_dep(_strYM).ToList(); } // 自動產生名字 string savefile = $"\\change_dep_{_strYM}_{DateTime.Now.Year}{(DateTime.Now.Month + 100).ToString().Substring(1)}"; savefile += $"{(DateTime.Now.Day + 100).ToString().Substring(1)}_{DateTime.Now.TimeOfDay}"; savefile = savefile.Replace(":", "").Replace(".", ""); savepath += $"{savefile}.csv"; // 製作csv檔 writing to csv System.IO.StreamWriter sw = new System.IO.StreamWriter(savepath); int i = 1; change_N = ListChange.Count; if (change_N == 0) { tb.ShowBalloonTip("完成", "沒有什麼需要修改的", BalloonIcon.Info); log.Info("change department: 沒有什麼需要修改的"); Logging.Record_admin("change department", "沒有什麼需要修改的"); } else { minD = DateTime.Parse("9999/12/31"); maxD = DateTime.Parse("0001/01/01"); foreach (var c in ListChange) { sw.Write(c.o); // 欄位名叫o if (i < change_N) { sw.Write(sw.NewLine); } DateTime tempD = DateTime.Parse($"{c.o.Substring(0, 4)}/{c.o.Substring(4, 2)}/{c.o.Substring(6, 2)}"); // 找尋最大的值 if (tempD.CompareTo(maxD) > 0) { maxD = tempD; } // 找尋最小的值 if (tempD.CompareTo(minD) < 0) { minD = tempD; } i++; } // 20200518 放在foreach的loop迴圈裡是錯誤的, 我把它放出來了 string output = $"{minD:d}~{maxD:d}, 共{change_N}筆需要修改"; tb.ShowBalloonTip("需修改:", output, BalloonIcon.Info); log.Info($"change department: {output}"); Logging.Record_admin("change department", output); sw.Close(); } } catch (System.Exception ex) { Logging.Record_error(ex.Message); log.Error(ex.Message); return; } #endregion Making CSV #region Environment try { // 營造環境 if (AutoItX.WinExists("看診清單") == 1) //如果直接存在就直接叫用 { AutoItX.WinActivate("看診清單"); } else { Thesis.LogIN(); // 打開"看診清單" AutoItX.Run(@"C:\Program Files (x86)\THESE\杏雲醫療資訊系統\THCClinic.exe", @"C:\Program Files (x86)\THESE\杏雲醫療資訊系統\"); AutoItX.WinWaitActive("看診清單"); AutoItX.WinActivate("看診清單"); } } catch (Exception ex) { Logging.Record_error(ex.Message); log.Error(ex.Message); return; } #endregion Environment #region Execute change department try { string strD_o = string.Empty; string strV_o = string.Empty; string strR_o = string.Empty; foreach (var c in ListChange) { string strD_n = c.o.Substring(0, 8); string strV_n = c.o.Substring(8, 1); string strR_n = c.o.Substring(9, 2); bool changed = false; string strNr = c.o.Substring(11, 3); string strDEP = c.o.Substring(14, 2); // 先檢查是否換日, 如果有就換到新日期; if (strD_n != strD_o) { // 製造3個AutoIT VB程式, 1. changeDP_DATE, 針對"看診清單", [NAME:dtpSDate] // 一個參數, 格式YYYYMMDD AutoItX.Run($"C:\\vpn\\exe\\changeDP_DATE.exe {strD_n}", @"C:\vpn\exe\"); log.Info($"Change Date from {strD_o} to {strD_n}. Then sleep 1000ms."); strD_o = strD_n; changed = true; AutoItX.Sleep(1000); } // 再檢查是否換午別, 如果有就換到新的午別 if (strV_n != strV_o) { // 製造3個AutoIT VB程式, 2. changeDP_VIST, 針對"看診清單", [NAME:cmbVist] // 一個參數, 格式V AutoItX.Run($"C:\\vpn\\exe\\changeDP_VIST.exe {strV_n}", @"C:\vpn\exe\"); log.Info($"Change Vist from {strV_o} to {strV_n}. Then sleep 1000ms."); strV_o = strV_n; changed = true; AutoItX.Sleep(1000); } // 最後檢查是否換診間, 如果有就換到新的診間 if (strR_n != strR_o) { // 製造3個AutoIT VB程式, 3. changeDP_ROOM, 針對"看診清單", [NAME:cmbRmno] // 一個參數, 格式RR AutoItX.Run($"C:\\vpn\\exe\\changeDP_ROOM.exe {strR_n}", @"C:\vpn\exe\"); log.Info($"Change Date from {strR_o} to {strR_n}. Then sleep 1000ms."); strR_o = strR_n; changed = true; AutoItX.Sleep(1000); } if (changed) { AutoItX.ControlClick("看診清單", "", "[NAME:btnRefresh]"); log.Info($"Press Refresh button. [NAME:btnRefresh]."); AutoItX.WinWaitActive("看診清單"); changed = false; } // 按下新的號碼; // Seq NO // 輸入診號 AutoItX.ControlSend("看診清單", "", "[NAME:txbSqno]", strNr); log.Info($"Enter {strNr}."); // 按鈕 AutoItX.ControlClick("看診清單", "", "[NAME:btnGo]"); log.Info($"Press GO button. [NAME:btnGo]."); // 進入問診畫面 AutoItX.WinWaitActive("問診畫面"); AutoItX.Sleep(500); // 製造一個AutoIT VB程式, changeDP_DEP, 針對"問診畫面"[NAME:cmbDept] // 一個參數, 格式DD AutoItX.Run($"C:\\vpn\\exe\\changeDP_DEP.exe {strDEP}", @"C:\vpn\exe\"); AutoItX.Sleep(500); int idx = 0; // 先問「此病患已批價, 是否繼續?」, THCClinic, 還可能問重大傷病, 超過8種藥物, 可能有重複用藥畫面 do { AutoItX.Send("{F9}"); AutoItX.Sleep(100); idx++; // time out for 10 sec at most } while (AutoItX.WinExists("THCClinic") == 0 && idx < 100); // 下一個畫面「確定要重複開立收據」, // 一定會有「已經批價」, 可能會有「重大傷病身分」, 可能會有「八種以上藥物] // 可能會有「跨院重複開立醫囑提示」 idx = 0; do { if (AutoItX.WinExists("THCClinic") == 1) { AutoItX.ControlClick("THCClinic", "", "[CLASSNN:Button1]"); } if (AutoItX.WinExists("跨院重複開立醫囑提示") == 1) { AutoItX.ControlClick("跨院重複開立醫囑提示", "", "[NAME:OK_Button]"); } AutoItX.Sleep(100); idx++; // time out for 10 sec at most } while (AutoItX.WinExists("These.CludCln.Accounting") == 0 && idx < 100); // 是否重印收據 AutoItX.WinWaitActive("These.CludCln.Accounting"); AutoItX.ControlClick("These.CludCln.Accounting", "", "[CLASSNN:Button2]"); AutoItX.Sleep(1000); } Logging.Record_admin("change department", $"修改了{change_N}筆"); tb.ShowBalloonTip("完成", $"修改了{change_N}筆, 請匯入門診資料.", BalloonIcon.Info); } catch (Exception ex) { Logging.Record_error(ex.Message); log.Error(ex.Message); return; } #endregion Execute change department }