static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                return;
            }
            if (!int.TryParse(args[0], out var dropDown))
            {
                return;
            }
            new Process
            {
                StartInfo =
                {
                    FileName  = @"C:\Windows\System32\control.exe",
                    Arguments = "/name Microsoft.Sound /page playback"
                }
            }.Start();
            AutoItX.WinWait("Sound");
            var winHandle     = AutoItX.WinGetHandle("Sound");
            var listView      = AutoItX.ControlGetHandle(winHandle, "[CLASS:SysListView32; INSTANCE:1]");
            var btnSetDefault = AutoItX.ControlGetHandle(winHandle, "[CLASS:Button; INSTANCE:2]");
            var btnOk         = AutoItX.ControlGetHandle(winHandle, "[CLASS:Button; INSTANCE:4]");

            AutoItX.ControlFocus(winHandle, listView);
            AutoItX.ControlSend(winHandle, listView, "{UP}");
            for (var i = 0; i < dropDown; i++)
            {
                AutoItX.ControlSend(winHandle, listView, "{DOWN}");
            }
            AutoItX.ControlClick(winHandle, btnSetDefault);
            AutoItX.ControlClick(winHandle, btnOk);
        }
Esempio n. 2
0
        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("杏雲雲端醫療服務");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Submit a new photo post.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public async Task SubmitPhoto(string path, string description)
        {
            try
            {
                Random rand = new Random();

                //open feed submit and select photo
                var buttonFeedSubmit = WebDriver.FindElementByXPath(DomSelector.NAVIGATION_POST);
                buttonFeedSubmit.Click();

                await Task.Delay(rand.Next(1000, 3000));

                AutoItX.ControlSend("Open", "", "", path);

                await Task.Delay(rand.Next(1000, 3000));

                AutoItX.ControlSend("Open", "", "", "{ENTER}");

                await Task.Delay(rand.Next(500, 3000));

                //click expand photo
                try
                {
                    var expandButton = WebDriver.FindElementByXPath(DomSelector.CREATE_PHOTO_EXPAND);
                    ExecuteJsClick(expandButton);
                    Wait(5);
                }
                catch (NoSuchElementException e)
                {
                    //ignore expand
                }

                //click next button
                var nextButton = WebDriver.FindElementByXPath(DomSelector.CREATE_PHOTO_BUTTON_NEXT);
                //nextButton.Click();
                ExecuteJsClick(nextButton);
                Wait(5);

                //insert photo description
                if (description != null)
                {
                    var photoDescription = WebDriver.FindElementByXPath(DomSelector.CREATE_PHOTO_DESCSRIPTION);
                    photoDescription.Clear();
                    photoDescription.SendKeys(description);
                    Wait(1);
                }

                await Task.Delay(rand.Next(5000, 12000));

                //share photo
                var shareButton = WebDriver.FindElementByXPath(DomSelector.CREATE_PHOTO_SHARE);
                //shareButton.Click();
                ExecuteJsClick(shareButton);
                Wait(10);
            }
            catch (NoSuchElementException e)
            {
                throw new RuntimeException($"Finding element during submit photo failed - {e.Message}", e);
            }
        }
Esempio n. 4
0
        protected override bool SetTimingInternal(Timing timing, string value)
        {
            IntPtr hwnd = GetHandle("ComboBox", GetInstance(timing));

            if (hwnd == IntPtr.Zero)
            {
                return(false);
            }
            AutoItX.WinActivate(process.MainWindowHandle);
            AutoItX.ControlClick(process.MainWindowHandle, hwnd);
            AutoItX.ControlSend(process.MainWindowHandle, hwnd, "{BACKSPACE}");
            Thread.Sleep(50);
            foreach (var character in value.ToCharArray())
            {
                AutoItX.ControlSend(process.MainWindowHandle, hwnd, $"{character}", 1);
                Thread.Sleep(20);
            }
            return(true);
        }
Esempio n. 5
0
        protected override bool SetTimingInternal(Timing timing, int value)
        {
            try
            {
                IntPtr hwnd = GetHandle("ComboBox", GetInstance(timing));

                int currentTiming = GetTiming(timing);

                if (value < currentTiming)
                {
                    while (value < currentTiming)
                    {
                        AutoItX.ControlSend(process.MainWindowHandle, hwnd, "{UP}");
                        currentTiming--;
                        Thread.Sleep(20);
                    }
                }
                else if (value > currentTiming)
                {
                    while (value > currentTiming)
                    {
                        AutoItX.ControlSend(process.MainWindowHandle, hwnd, "{DOWN}");
                        currentTiming++;
                        Thread.Sleep(20);
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                if (Program.verboseLogging)
                {
                    Console.WriteLine();
                    Console.Error.WriteLine(e);
                    Console.WriteLine();
                }
                return(false);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Handles the Click event of the ServiceAccountChangeButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void ServiceAccountChangeButton_Click(object sender, EventArgs e)
        {
            // TODO: trivial to move out into a separate class.
            string fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "mmc.exe");
            string args     = @"C:\Windows\system32\services.msc";

            Process services = new Process();

            services.StartInfo = new ProcessStartInfo
            {
                FileName  = fileName,
                Arguments = args
            };
            services.Start();

            //AutoItX.Run(string.Format("{0} \"{1}\"", fileName, args), AppDomain.CurrentDomain.BaseDirectory);
            AutoItX.WinWaitActive("Services");

            int result   = 0;
            int attempts = 5;

            while (result != 1)
            {
                result = AutoItX.ControlFocus("Services", "Services (Local)", "[CLASS:MMCOCXViewWindow; INSTANCE:1]");
                if (result == 1)
                {
                    AutoItX.ControlSend("Services", "Services (Local)", "[CLASS:SysHeader32; INSTANCE:1]", "{TAB}");
                    AutoItX.Send("SACS{ENTER}");
                }
                else
                {
                    Thread.Sleep(2000);
                    if (attempts-- == 0)
                    {
                        result = 1; // pretend true; no need to break.
                    }
                }
            }
        }
 public int ControlSend(string sendText, int mode = 0, string control = "")
 {
     return(AutoItX.ControlSend(thiswindowHandle, ControlGetHandle(control), sendText, mode));
 }
Esempio n. 8
0
        private Dictionary <string, object[, ]> RetrievePIJIA()
        {
            // 20200519 獨立成一個副程式

            #region Declaration

            Microsoft.Office.Interop.Excel.Application MyExcel;
            Dictionary <string, object[, ]>            output = new Dictionary <string, object[, ]>();

            #endregion Declaration

            #region The Loop of 讀取檔案

            // 20190609 今天竟然完成了最難的部分
            // a FOR loop, LIST of A, B, C, D, E, F, G, H, I, J, K, L, M
            // Making a list
            // A 周孫元診所; B 聖愛; C 啟智; D 由根; E 方舟; F 景仁; G 香園; H 觀音; I 桃園; J 誠信; K 祥育; L 春暉; M 世美
            // 20200319 新增 N 華光
            string[] lArea = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N" };
            foreach (string a in lArea)
            {
                try
                {
                    // 殺掉所有的EXCEL
                    foreach (Process p in Process.GetProcessesByName("EXCEL"))
                    {
                        p.Kill();
                    }
                }
                catch (Exception ex)
                {
                    log.Error($"ignore this {ex.Message}");
                }

                // [NAME:cmbArea]
                // AutoItX.ControlFocus("日收入報表A", "", "[NAME:cmbArea]")
                // AutoItX.Send(a)
                AutoItX.Sleep(3000); //這裡等一下
                AutoItX.ControlSend("日收入報表A", "", "[NAME:cmbArea]", a);
                log.Info($"現在處理{a}");
                // execute AutoIT
                // 日收入報表A
                AutoItX.Sleep(500); // 這裡等一下

                log.Info("Start to Click.");
                int timeout = 0; // 20 sec timeout
                do
                {
                    AutoItX.ControlClick("日收入報表A", "", "[NAME:btnExcel]");
                    AutoItX.Sleep(3000);
                    log.Info($"按下btnExcel {timeout + 1} time.");
                    timeout++;
                } while (Process.GetProcessesByName("EXCEL").Length == 0 && timeout < 2);

                Process[] pr = Process.GetProcessesByName("EXCEL");
                if (pr.Length > 0)
                {
                    log.Info("Excel exists now.");
                    //  有的話,excel.application, getobject, 存檔, 存檔案位置, 供匯入用
                    //  winwait實驗可行, 可偵測excel已經完成
                    // AutoItX.WinWaitActive("活頁簿"), 實際測試失敗, 改用DO Loop
                    //  後來發現process建立後, 一段時間才會建立windows
                    do
                    {
                        AutoItX.Sleep(100);
                    } while (AutoItX.WinExists("活頁簿") == 0);
                    // AutoItX.Sleep(10000), 用等的,等10秒大多有效,但不能保證,且也許不用10秒,這樣就浪費了, 應該要個別化
                    // 好在發現visibility可以有效等到整個檔案製作完成
                    MyExcel = (Microsoft.Office.Interop.Excel.Application)Marshal.GetActiveObject("Excel.Application");

                    do
                    {
                        AutoItX.Sleep(100);
                    } while (!MyExcel.Visible);
                    // 現在開始excel 的處理
                    try
                    {
                        Microsoft.Office.Interop.Excel.Workbook  wb = MyExcel.ActiveWorkbook;
                        Microsoft.Office.Interop.Excel.Worksheet ws = wb.ActiveSheet;

                        // 要刪除什麼欄位,合計等等資料
                        //  ====================================================================================================================================
                        // 檢查欄位, 如果欄位不對, 就不要處理了, 一共要以下27欄位
                        string[] header = { "狀態",   "收據號", "批價人員",   "作廢日期", "看診日期", "午別",   "診別",   "科別",   "醫師", "身分",
                                            "就醫序號", "優免",  "部分負擔說明", "身分證號", "患者姓名", "醫療費用", "掛號費用", "部分負擔", "押金", "自付金額",
                                            "藥費加重", "欠收",  "折扣",     "應收金額", "實收金額", "收據說明", "說明" };
                        // excel檔有幾欄?
                        int total_col_n = ws.UsedRange.Columns.Count;
                        int last_row    = ws.UsedRange.Rows.Count;

                        // 刪除欄位
                        for (int idx = total_col_n; idx > 0; idx--)
                        {
                            if (!header.Contains((string)ws.Cells[1, idx].Value))
                            {
                                ws.Columns[idx].delete();
                            }
                        }

                        if (header_order is null)
                        {
                            log.Info("Check header_order.");
                            // 27欄位以上的都刪除掉
                            header_order = new int[header.Length + 1]; // 0不要用, 使用1 - 27

                            // 檢查格式, header.Length = 27
                            for (int i = 1; i <= header.Length; i++)
                            {
                                for (int j = 1; j <= total_col_n; j++)
                                {
                                    if ((string)ws.Cells[1, j].Value == header[i - 1])
                                    {
                                        header_order[i] = j;
                                        break;
                                    }
                                }
                                // 只要任一header成員找不到ws相對應的文字, 那就是找不到
                                if (header_order[i] == 0)
                                {
                                    // 寫入Error Log
                                    Logging.Record_error($"{a}輸入的批價檔案格式不對");
                                    log.Error($"{a}輸入的批價檔案格式不對");
                                    tb.ShowBalloonTip("錯誤", $"{a}檔案格式不對", BalloonIcon.Error);
                                    return(null);
                                }
                            }

                            // 格式正確
                            Logging.Record_admin("讀取批價檔", $"{a}輸入的批價檔案格式正確");
                            log.Info($"{a}輸入的批價檔案格式正確");
                        }

                        // 刪除最後一列, 存入檔案
                        ws.Rows[last_row].delete();
                        //  ====================================================================================================================================
                        // 製作自動檔名, 並存檔
                        string temp_filepath = @"C:\vpn\bills";
                        //  20190609 因為不小心多一個空格, 搞了好久除錯, 很辛苦啊
                        //  System.Runtime.InteropServices.COMException // 發生例外狀況於 HRESULT: 0x800A03EC//
                        // 存放目錄,不存在就要建立一個
                        if (!System.IO.Directory.Exists(temp_filepath))
                        {
                            System.IO.Directory.CreateDirectory(temp_filepath);
                        }
                        // 自動產生名字
                        temp_filepath += $"\\bill_{a}_{BeginDate}_{EndDate}";
                        temp_filepath += $"_{DateTime.Now.Year}{(DateTime.Now.Month + 100).ToString().Substring(1)}{(DateTime.Now.Day + 100).ToString().Substring(1)}";
                        temp_filepath += DateTime.Now.TimeOfDay.ToString().Replace(":", "").Replace(".", "");
                        temp_filepath += ".csv";
                        // wb.SaveAs(temp_filepath, Excel.XlFileFormat.xlCSV, vbNull, vbNull, False, False, Excel.XlSaveAsAccessMode.xlNoChange, vbNull, vbNull, vbNull, vbNull, vbNull)
                        wb.SaveAs(temp_filepath, Microsoft.Office.Interop.Excel.XlFileFormat.xlCSV);

                        //// 刪除第一列, 存入data
                        //ws.Rows[1].delete();

                        output.Add(a, ws.UsedRange.Value2);

                        try
                        {
                            // 殺掉所有的EXCEL
                            foreach (Process p in Process.GetProcessesByName("EXCEL"))
                            {
                                p.Kill();
                            }
                        }
                        catch (Exception ex)
                        {
                            log.Error($"ignore this {ex.Message}");
                        }
                    }
                    catch (Exception ex)
                    {
                        Logging.Record_error(ex.Message);
                        log.Error(ex.Message);
                    }
                }
            }

            // close windows
            // 日收入報表A
            // [NAME:Cancel_Button]
            AutoItX.ControlClick("日收入報表A", "", "[NAME:Cancel_Button]");
            // [FrmMain] v1.0.0.67
            // [NAME:btnExit]
            AutoItX.ControlClick("[FrmMain] v", "", "[NAME:btnExit]");

            #endregion The Loop of 讀取檔案

            return(output);
        }
Esempio n. 9
0
        public async Task Convert(Progress <ProgressReportModel> progress)
        {
            Microsoft.Office.Interop.Excel.Application MyExcel = new Microsoft.Office.Interop.Excel.Application();

            #region Environment

            // 殺掉所有的EXCEL
            foreach (Process p in Process.GetProcessesByName("EXCEL"))
            {
                p.Kill();
            }
            // 營造環境
            Process[] isCust = Process.GetProcessesByName("THCustomerFilter"); // 處方清單
            if (isCust.Length == 0)                                            // 如果沒有打開
            {
                // 測試"看診清單"是否有打開
                Thesis.LogIN();
                // 打開"各類特殊 追蹤與紀錄查詢"
                AutoItX.Run(@"C:\Program Files (x86)\THESE\杏雲醫療資訊系統\THCustomerFilter.exe", @"C:\Program Files (x86)\THESE\杏雲醫療資訊系統\");
                System.Threading.Thread.Sleep(2000);
            }
            // 準備好
            AutoItX.WinActivate("各類特殊 追蹤與紀錄查詢");
            AutoItX.WinWaitActive("各類特殊 追蹤與紀錄查詢");
            AutoItX.ControlClick("各類特殊 追蹤與紀錄查詢", "", "[NAME:chk允許完整筆數呈現]");
            AutoItX.Sleep(1000);
            // [NAME:btn病歷號查詢]
            AutoItX.ControlClick("各類特殊 追蹤與紀錄查詢", "", "[NAME:btn病歷號查詢]");
            AutoItX.Sleep(1000);
            // 病歷號查詢
            // [NAME:TextBox]
            // [NAME:OKButton]
            AutoItX.ControlSend("病歷號查詢", "", "[NAME:TextBox]", "0000000001~9999999999");
            AutoItX.ControlClick("病歷號查詢", "", "[NAME:OKButton]");
            log.Info("Click inquiry.");
            //AutoItX.WinWaitActive("各類特殊 追蹤與紀錄查詢");
            //AutoItX.WinWaitActive("各類特殊 追蹤與紀錄查詢");
            //log.Info("WinWait ends.");
            //AutoItX.Sleep(20000);

            // 20190610 模仿昨天成功的經驗
            // [NAME:btn匯出EXCEL]
            // aut.WinWait("[dlgPrintMethodAsk]",, 1000)
            // aut.ControlClick("[dlgPrintMethodAsk]", "", "[NAME:OK_Button]")

            log.Info("Start to Click.");
            do
            {
                AutoItX.ControlClick("各類特殊 追蹤與紀錄查詢", "", "[NAME:btn匯出EXCEL]");
                AutoItX.Sleep(10000);
                log.Info("Click export one time.");
            } while (Process.GetProcessesByName("EXCEL").Length == 0);
            log.Info("Excel exists now.");

            // aut.Sleep(10000), 用等的,等10秒大多有效,但不能保證,且也許不用10秒,這樣就浪費了, 應該要個別化
            // 好在發現visibility可以有效等到整個檔案製作完成
            MyExcel = (Microsoft.Office.Interop.Excel.Application)Marshal.GetActiveObject("Excel.Application");
            do
            {
                AutoItX.Sleep(100);
            } while (!MyExcel.Visible);
            log.Info("Excel appears now.");

            #endregion Environment

            #region Saving XLSX files

            // ====================================================================================================================================
            // 製作自動檔名
            string temp_filepath = @"C:\vpn\pt";
            // 20190609 因為不小心多一個空格, 搞了好久除錯, 很辛苦啊
            // System.Runtime.InteropServices.COMException '發生例外狀況於 HRESULT: 0x800A03EC'
            // 存放目錄,不存在就要建立一個
            if (!System.IO.Directory.Exists(temp_filepath))
            {
                System.IO.Directory.CreateDirectory(temp_filepath);
            }
            // 自動產生名字
            string temp_file = $"\\pt_{DateTime.Now.Year}{(DateTime.Now.Month + 100).ToString().Substring(1)}";
            temp_file     += $"{(DateTime.Now.Day + 100).ToString().Substring(1)}_{DateTime.Now.TimeOfDay}";
            temp_file      = temp_file.Replace(":", "").Replace(".", "");
            temp_filepath += $"{temp_file}.xlsx";
            // wb.SaveAs(temp_filepath, Excel.XlFileFormat.xlCSV, vbNull, vbNull, False, False, Excel.XlSaveAsAccessMode.xlNoChange, vbNull, vbNull, vbNull, vbNull, vbNull)
            Microsoft.Office.Interop.Excel.Workbook wb = MyExcel.ActiveWorkbook;
            wb.SaveAs(temp_filepath, Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook);
            Microsoft.Office.Interop.Excel.Worksheet ws = wb.ActiveSheet;

            #endregion Saving XLSX files

            // 丟出的是一個object [,]
            PTconvert pt = new PTconvert(ws.UsedRange.Value2);
            await pt.Transform(progress);


            #region Ending

            // 殺掉所有的EXCEL
            foreach (Process p in Process.GetProcessesByName("EXCEL"))
            {
                p.Kill();
            }
            AutoItX.WinClose("各類特殊 追蹤與紀錄查詢");

            #endregion Ending
        }
Esempio n. 10
0
        /// <summary>
        /// Sends text to file name control of browser open file GUI dialog window and
        /// presses {Enter} key. Supports single and multiple (from the same folder)
        /// file(s) upload. Checks whether the dialog was closed afterwards.
        /// </summary>
        /// <param name="paths">File(s) with full path</param>
        public static void Upload(params string[] paths)
        {
            if (paths == null || paths.Length == 0 || string.IsNullOrEmpty(paths[0]))
            {
                throw new ArgumentException(
                          @"Got null or empty parameter(s). Nothing to upload.", nameof(paths));
            }

            // is it multiple files upload?
            var isMultipleFilesUpload = paths.Length > 1;

            // waits for dialog window appearance
            if (AutoItX.WinWait(WindowTitle, string.Empty, 5) == 0)
            {
                throw new AggregateException($@"AutoItX: '{WindowTitle}' dialog window not found");
            }

            // get handles of dialog window, OK button, and File Name input controls
            _windowHandle          = AutoItX.WinGetHandle(WindowTitle);
            _okControlHandle       = AutoItX.ControlGetHandle(_windowHandle, OkControlName);
            _fileNameControlHandle = AutoItX.ControlGetHandle(_windowHandle, FileNameControlName);

            if ((int)_windowHandle <= 0 || (int)_okControlHandle <= 0)
            {
                throw new AggregateException("AutoItX: Cannot get window or/and control handle(s)");
            }

            // activate dialog window (just in case)
            AutoItX.WinActivate(_windowHandle);

            // set uploaded files folder as current folder in case of multiple files selection
            var dir = Path.GetDirectoryName(paths[0])?.Replace(@"\\", @"\");

            if (isMultipleFilesUpload && !string.IsNullOrEmpty(dir))
            {
                // change path
                // mode: 1 -> no control symbols processing, send text "as is"
                AutoItX.ControlSend(
                    _windowHandle,
                    AutoItX.ControlGetHandle(_windowHandle, FileNameControlName),
                    dir,
                    mode: 1);
                // press OK button
                AutoItX.ControlClick(_windowHandle, _okControlHandle);
                Thread.Sleep(1000);
            }

            // create input string for file name control
            var path1 = string.Empty;

            foreach (var path in paths)
            {
                path1 += (isMultipleFilesUpload ? "\"" + Path.GetFileName(path) + "\" " : path)
                         .Replace(@"\\", @"\");

                // check if dialog is still active and activate it if needed
                if (AutoItX.WinActive(_windowHandle) != 0)
                {
                    continue;
                }

                if (AutoItX.WinActivate(_windowHandle) == 0)
                {
                    throw new AggregateException(
                              $@"AutoItX: Cannot activate '{WindowTitle}' dialog window. " +
                              "Is it closed, overlapped or desktop is locked?");
                }
            }

            // due to upper/lower case AutoIt input typos, following workaround is implemented:
            // input path to File Name control and verify it afterwards; if wrong, input it
            // over and over until succeed or timed out
            var sw = new Stopwatch();

            sw.Start();
            while (AutoItX.ControlGetText(_windowHandle, _fileNameControlHandle) != path1 &&
                   sw.Elapsed < TimeSpan.FromSeconds(60))
            {
                AutoItX.ControlSetText(_windowHandle, _fileNameControlHandle, string.Empty);
                AutoItX.ControlSend(_windowHandle, _fileNameControlHandle, path1, mode: 1);
            }
            sw.Stop();
            // if input is timed out, throw exception
            if (sw.Elapsed >= TimeSpan.FromSeconds(60))
            {
                throw new AggregateException($@"AutoItX: Failed to input path '{path1}'");
            }

            // check if dialog is still active and activate it if not
            if (AutoItX.WinActive(_windowHandle) == 0)
            {
                if (AutoItX.WinActivate(_windowHandle) == 0)
                {
                    throw new AggregateException(
                              $@"AutoItX: Cannot activate '{WindowTitle}' GUI dialog window. " +
                              "Is it closed, overlapped or desktop is locked?");
                }
            }

            // press OK button
            AutoItX.ControlClick(_windowHandle, _okControlHandle);

            // check if the dialog is closed
            var success = AutoItX.WinWaitClose(_windowHandle, 1);

            if (success > 0)
            {
                return;
            }

            // throw exception if dialog is not closed
            throw new AggregateException(
                      $@"AutoItX: Failed to close '{WindowTitle}' GUI dialog window. Was this " +
                      "window closed manually, desktop locked, or 'File not found' error " +
                      "displayed?");
        }
Esempio n. 11
0
        private async void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            stuckTimer.Enabled = false;
            if (webBrowser1.Url.ToString().Contains(@"https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=13&ct=1501178470&rver=6.7.6643.0&wp=MBI_SSL&wreply=https:%2f%2faccount.microsoft.com%2fauth%2fcomplete-signin%3fru%3dhttps%253a%252f%252faccount.microsoft.com%252frewards%253frefd%253daccount.microsoft.com%2526destrt%253drewards-dashboard%2526refp%253dsignedout-index&lc=1033&id=292666&lw=1&fl=easi2&pcexp=true&uictx=me"))
            {
                await PutTaskDelay2();

                webBrowser1.Document.GetElementById("loginfmt").InnerText = username;
                AutoItX.ControlSend("Bing Rewards Search Bot", "", "", "{ENTER}", 0);
                await PutTaskDelay2();

                password = password.Replace("!", "{!}");
                AutoItX.ControlSend("Bing Rewards Search Bot", "", "", password + "{Enter}", 0);
                return;
            }

            if (webBrowser1.Url.ToString() == "" || webBrowser1.Url == null || webBrowser1.Url.ToString().Contains(@"about:blank") || webBrowser1.Url.ToString().Contains(@"newagesoldier")) //could be refreshing page, or script behined the scenes
            {
                return;
            }

            if (webBrowser1.Url.ToString().Equals(@"http://www.msn.com/"))
            {
                dashboardWait.Enabled = true;
                webBrowser1.Navigate(new Uri(@"https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=13&ct=1501178470&rver=6.7.6643.0&wp=MBI_SSL&wreply=https:%2f%2faccount.microsoft.com%2fauth%2fcomplete-signin%3fru%3dhttps%253a%252f%252faccount.microsoft.com%252frewards%253frefd%253daccount.microsoft.com%2526destrt%253drewards-dashboard%2526refp%253dsignedout-index&lc=1033&id=292666&lw=1&fl=easi2&pcexp=true&uictx=me"), null, null, "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063");
                return;
            }

            if (webBrowser1.Url.ToString().Contains(@"bing.com/Passport") || webBrowser1.Url.ToString().Contains(@"live.com") || webBrowser1.Url.ToString().Contains(@"bing.com/secure"))
            {
                return; //after logout, we are redirected. Please wait.
            }
            //if (mobile)
            //    searchModeBox.Text = "mobile";
            //else
            //searchModeBox.Text = "desktop";

            /*if (webBrowser1.Url.ToString().Contains(@"bing.com/rewards/dashboard"))
             * {
             *  dashboardWait.Enabled = true;
             *  return;
             * }*/

            searchesLeftBox.Text = countDown.ToString();
            accountBox.Text      = username;

            //if (!webBrowser1.Url.ToString().Contains(@"bing.com/rewards/dashboard"))
            //    return;

            if (countDown == 0)
            {
                //if (mobile) //just finished with mobile, back to desktop
                //    startTimer.Enabled = true;
                //else
                //{ //switch to mobile
                //    mobile = true;
                countDown           = Properties.Settings.Default.mobilesearches;
                searchTimer.Enabled = true;
                //}
            }
            else
            {
                searchTimer.Enabled = true;
            }

            if (!webBrowser1.Url.ToString().Contains(@"?q="))
            {
                return;
            }
        }
Esempio n. 12
0
        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
        }
Esempio n. 13
0
        public bool Login(string host, string username, string password, int portFw, int timeOut = 20)
        {
            _lastListenPort = portFw;
            if (_bvssh == null || _bvssh.HasExited)
            {
                Start();
            }
            Counter.Login++;
            if (Counter.Login % 50 == 0)
            {
                Kill();
                Start();
                Counter.Login = 1;
            }
            string btnLoginText = "";

            IntPtr
                hwndHost       = GetHandle(Controlnfo.Host),
                hwndUsername   = GetHandle(Controlnfo.Username),
                hwndPassword   = GetHandle(Controlnfo.Password),
                hwndListenPort = GetHandle(Controlnfo.ListenPort),
                hwndLogin      = GetHandle(Controlnfo.Login);

            // set host
            SetControlText(hwndHost, host);

            // set username
            SetControlText(hwndUsername, username);

            // set password
            lock (Sync.oAutoIt)
            {
                AutoItX.ControlFocus(_bvssh.MainWindowHandle, hwndPassword);
                AutoItX.ControlSend(_bvssh.MainWindowHandle, hwndPassword, "{END}");
                AutoItX.ControlSend(_bvssh.MainWindowHandle, hwndPassword, "+{HOME}");
                AutoItX.ControlSend(_bvssh.MainWindowHandle, hwndPassword, password, 1);
            }

            // set listen port
            SetControlText(hwndListenPort, portFw);

            // click Login
            Click(hwndLogin);

            // waiting for logging
            int countdown = timeOut;

            while (countdown != 0)
            {
                status = string.Format("[{0}] Connecting {1} | {2} | {3}", countdown, host, username, password);
                ShowStatus();
                btnLoginText = GetControlText(hwndLogin);
                if (btnLoginText == StringHelper.Logout || btnLoginText == StringHelper.Login)
                {
                    break;
                }
                Thread.Sleep(1000);
                countdown--;
            }

            btnLoginText = GetControlText(hwndLogin);
            if (btnLoginText == StringHelper.Logout)
            {
                _connectStatus = ConnectStatus.Connected;
                status         = string.Format("LIVE {0} | {1} | {2}", host, username, password);
                ShowStatus();
                if (MonitorConnection)
                {
                    new Thread(DisconnectChecker)
                    {
                        IsBackground = true
                    }
                }
 public int ControlSend(string title, string text, string control, string sendText, int mode = 0)
 {
     return(AutoItX.ControlSend(title, text, control, sendText, mode));
 }
Esempio n. 15
0
 public void ControlSend(string title, string text, string control, string sendText)
 {
     AutoItX.ControlSend(title, text, control, sendText);
 }
Esempio n. 16
0
        public void Auto(object obj)
        {
            List <Task> listTauto = (List <Task>)obj;

            if (listTauto[0].Repeat == 0)
            {
                while (true)
                {
                    for (int loop = 0; loop < listTauto.Count; loop++)
                    {
                        //auto theo listTauto[loop]
                        thongtin.TaskIndex = loop;
                        if (listTauto[loop].IsAutoClick)
                        {
                            Point p = new Point(-1, -1);
                            while (p.X == -1)
                            {
                                //trong khi chua tim dc => tim tiep
                                if (stop == true)
                                {
                                    currentThreadAuto.Abort();
                                }
                                p = Image_searchEX(listTauto[loop].ImageLocal, Utilities.CaptureWindow(process.MainWindowHandle, currentThreadAuto), 85);
                                //MessageBox.Show(listTauto[loop].ImageName+":"+ p.ToString());
                            }
                            for (int m = 0; m < listTauto[loop].Clicks; m++)
                            {
                                AutoItX.ControlClick(process.MainWindowHandle, process.MainWindowHandle, listTauto[loop].TypeClick, 1, p.X, p.Y);
                                Thread.Sleep(listTauto[loop].DelayClick);
                            }
                            Thread.Sleep(listTauto[loop].DelaySearch);
                        }
                        if (listTauto[loop].IsClickXY)
                        {
                            for (int m = 0; m < listTauto[loop].Clicks; m++)
                            {
                                AutoItX.ControlClick(process.MainWindowHandle, process.MainWindowHandle, listTauto[loop].TypeClick, 1, listTauto[loop].X, listTauto[loop].Y);
                                Thread.Sleep(listTauto[loop].DelayClick);
                            }
                            Thread.Sleep(listTauto[loop].DelaySearch);
                        }
                        if (listTauto[loop].IsSendText)
                        {
                            for (int m = 0; m < listTauto[loop].SendTimes; m++)
                            {
                                if (stop == true)
                                {
                                    currentThreadAuto.Abort();
                                }
                                AutoItX.ControlSend(process.MainWindowHandle, process.MainWindowHandle, listTauto[loop].Text);
                                Thread.Sleep(listTauto[loop].DelaySend);
                            }
                        }
                        if (listTauto[loop].IsSendKey)
                        {
                            for (int m = 0; m < listTauto[loop].SendTimes; m++)
                            {
                                if (stop == true)
                                {
                                    currentThreadAuto.Abort();
                                }
                                AutoItX.ControlSend(process.MainWindowHandle, process.MainWindowHandle, "{" + listTauto[loop].Key + "}");
                                Thread.Sleep(listTauto[loop].DelaySend);
                            }
                        }
                    }
                }
            }
            else
            {
                for (int rp = 0; rp < listTauto[0].Repeat; rp++)
                {
                    for (int loop = 0; loop < listTauto.Count; loop++)
                    {
                        //auto theo listTauto[loop]
                        thongtin.TaskIndex = loop;
                        if (listTauto[loop].IsAutoClick)
                        {
                            Point p = new Point(-1, -1);
                            while (p.X == -1)
                            {
                                //trong khi chua tim dc => tim tiep
                                if (stop == true)
                                {
                                    currentThreadAuto.Abort();
                                }
                                p = Image_searchEX(listTauto[loop].ImageLocal, Utilities.CaptureWindow(process.MainWindowHandle, currentThreadAuto), 85);
                                //MessageBox.Show(listTauto[loop].ImageName+":"+ p.ToString());
                            }
                            for (int m = 0; m < listTauto[loop].Clicks; m++)
                            {
                                AutoItX.ControlClick(process.MainWindowHandle, process.MainWindowHandle, listTauto[loop].TypeClick, 1, p.X, p.Y);
                                Thread.Sleep(listTauto[loop].DelayClick);
                            }
                            Thread.Sleep(listTauto[loop].DelaySearch);
                        }
                        if (listTauto[loop].IsClickXY)
                        {
                            for (int m = 0; m < listTauto[loop].Clicks; m++)
                            {
                                AutoItX.ControlClick(process.MainWindowHandle, process.MainWindowHandle, listTauto[loop].TypeClick, 1, listTauto[loop].X, listTauto[loop].Y);
                                Thread.Sleep(listTauto[loop].DelayClick);
                            }
                            Thread.Sleep(listTauto[loop].DelaySearch);
                        }
                        if (listTauto[loop].IsSendText)
                        {
                            for (int m = 0; m < listTauto[loop].SendTimes; m++)
                            {
                                if (stop == true)
                                {
                                    currentThreadAuto.Abort();
                                }
                                AutoItX.ControlSend(process.MainWindowHandle, process.MainWindowHandle, listTauto[loop].Text);
                                Thread.Sleep(listTauto[loop].DelaySend);
                            }
                        }
                        if (listTauto[loop].IsSendKey)
                        {
                            for (int m = 0; m < listTauto[loop].SendTimes; m++)
                            {
                                if (stop == true)
                                {
                                    currentThreadAuto.Abort();
                                }
                                AutoItX.ControlSend(process.MainWindowHandle, process.MainWindowHandle, "{" + listTauto[loop].Key + "}");
                                Thread.Sleep(listTauto[loop].DelaySend);
                            }
                        }
                    }
                }
            }
            Action actionControlbtn = () => control_button("stop");

            this.Invoke(actionControlbtn);
            Action actionbtn = () => btnstop.Enabled = false;

            this.Invoke(actionbtn);
            Action actionbtn2 = () => btnstart.Enabled = true;

            this.Invoke(actionbtn2);
            Action actionthreadAbort = () => currentThreadUpdateGUI.Abort();

            this.Invoke(actionthreadAbort);
            Action actionlbl = () => lbltientrinh.Text = "Tất cả tác vụ đã hoàn thành !";

            this.Invoke(actionlbl);
        }
Esempio n. 17
0
        /// <summary>
        /// Автоматизация ветки
        /// Налоговое администрирование\ПОН ИЛ\1. ПОН ИЛ (ПЭ). Организации и физические лица, внесенные в ПОН ИЛ\2.01. ФЛ. Актуальное состояние
        /// </summary>
        /// <param name="pathjurnalerror">Путь к журналу с ошибками</param>
        /// <param name="pathjurnalok">Путь к отработаным</param>
        /// <param name="fid">Фид значения</param>
        public void Click8(string pathjurnalerror, string pathjurnalok, string fid)
        {
            AutoItX.WinActivate(WindowsAis3.AisNalog3);
            ReadWindow.Read.Reades.ClearBuffer();
            WindowsAis3 win = new WindowsAis3();

            win.ControlGetPos1(WindowsAis3.WinGrid[0], WindowsAis3.WinGrid[1], WindowsAis3.WinGrid[2]);
            AutoItX.MouseClick(ButtonConstant.MouseLeft, win.WindowsAis.X + win.X1 + 70, win.WindowsAis.Y + win.Y1 + 35);
            AutoItX.ClipPut(fid);
            AutoItX.Send(ButtonConstant.Right6);
            AutoItX.Send(ButtonConstant.Enter);
            AutoItX.Send(ButtonConstant.CtrlV);
            AutoItX.Send(ButtonConstant.Enter);
            AutoItX.Send(ButtonConstant.F5);
            AutoItX.WinWait(WindowsAis3.AisNalog3, StatusText.FidText, 5000);
            while (true)
            {
                if (AutoItX.WinExists(WindowsAis3.Text, WindowsAis3.DataNotFound) == 1)
                {
                    AutoItX.Send(ButtonConstant.F3);
                    LibaryXMLAuto.ErrorJurnal.ErrorJurnal.JurnalError(pathjurnalerror, fid, ActualStatus, WindowsAis3.DataNotFound);
                    break;
                }
                if (AutoItX.WinExists(WindowsAis3.AisNalog3, StatusText.FidText) == 1)
                {
                    AutoItX.MouseClick(ButtonConstant.MouseLeft, win.WindowsAis.X + 435, win.WindowsAis.Y + 95);
                    AutoItX.WinWait(WindowsAis3.AisNalog3, StatusText.StateSved);
                    if (AutoItX.WinExists(WindowsAis3.AisNalog3, StatusText.StateSved) == 1)
                    {
                        AutoItX.WinActivate(WindowsAis3.AisNalog3);
                        AutoItX.ControlFocus(WindowsAis3.Text, StatusReg.ComboBox[0], StatusReg.ComboBox[1]);
                        AutoItX.Send(StatusText.IsklFl);
                        AutoItX.ControlFocus(WindowsAis3.Text, StatusReg.ComboBox1[0], StatusReg.ComboBox1[1]);
                        AutoItX.Send(StatusText.IsklFlError);
                        AutoItX.ControlClick(WindowsAis3.Text, StatusReg.DateStatus[0], StatusReg.DateStatus[1]);
                        AutoItX.ControlSend(WindowsAis3.Text, StatusReg.DateStatus[0], StatusReg.DateStatus[1], DateTime.Now.ToString("d"));
                        AutoItX.ControlClick(WindowsAis3.Text, StatusReg.DateActual[0], StatusReg.DateActual[1]);
                        AutoItX.ControlSend(WindowsAis3.Text, StatusReg.DateActual[0], StatusReg.DateActual[1], DateTime.Now.ToString("d"));
                        AutoItX.ControlClick(WindowsAis3.AisNalog3, StatusReg.ButtonSelect[0], StatusReg.ButtonSelect[1]);
                        while (true)
                        {
                            if (AutoItX.WinExists(StatusText.DialogWin[0], StatusText.DialogWin[1]) == 1)
                            {
                                AutoItX.Send(ButtonConstant.Enter);
                                AutoItX.Sleep(2000);
                                AutoItX.MouseClick(ButtonConstant.MouseLeft, win.WindowsAis.X + 435, win.WindowsAis.Y + 95);
                                AutoItX.WinWait(WindowsAis3.AisNalog3, StatusText.StateSved);
                                if (AutoItX.WinExists(WindowsAis3.AisNalog3, StatusText.StateSved) == 1)
                                {
                                    AutoItX.WinActivate(WindowsAis3.AisNalog3);
                                    AutoItX.ControlFocus(WindowsAis3.Text, StatusReg.ComboBox[0], StatusReg.ComboBox[1]);
                                    AutoItX.Send(StatusText.VkllFl);
                                    AutoItX.ControlClick(WindowsAis3.Text, StatusReg.DateStatus[0], StatusReg.DateStatus[1]);
                                    AutoItX.ControlSend(WindowsAis3.Text, StatusReg.DateStatus[0], StatusReg.DateStatus[1], DateTime.Now.ToString("d"));
                                    AutoItX.ControlClick(WindowsAis3.Text, StatusReg.DateActual[0], StatusReg.DateActual[1]);
                                    AutoItX.ControlSend(WindowsAis3.Text, StatusReg.DateActual[0], StatusReg.DateActual[1], DateTime.Now.ToString("d"));
                                    AutoItX.ControlClick(WindowsAis3.AisNalog3, StatusReg.ButtonSelect[0], StatusReg.ButtonSelect[1]);
                                    AutoItX.WinWait(StatusText.DialogWin[0], StatusText.DialogWin[1], 5000);
                                    if (AutoItX.WinExists(StatusText.DialogWin[0], StatusText.DialogWin[1]) == 1)
                                    {
                                        AutoItX.Send(ButtonConstant.Enter);
                                        LibaryXMLAuto.ErrorJurnal.OkJurnal.JurnalOk(pathjurnalok, fid, StatusText.FidOk);
                                        AutoItX.Sleep(2000);
                                        win.ControlGetPos1(WindowsAis3.ControlPanel[0], WindowsAis3.ControlPanel[1], WindowsAis3.ControlPanel[2]);
                                        AutoItX.MouseClick(ButtonConstant.MouseLeft, win.WindowsAis.X + win.X1 + 85, win.WindowsAis.Y + win.Y1 + 10, 2);
                                        break;
                                    }
                                }
                            }
                            if (AutoItX.WinExists(StatusText.ErrorStateWin[0], StatusText.ErrorStateWin[1]) == 1)
                            {
                                AutoItX.Send(ButtonConstant.Enter);
                                AutoItX.Sleep(2000);
                                LibaryXMLAuto.ErrorJurnal.ErrorJurnal.JurnalError(pathjurnalerror, fid, ActualStatus, StatusText.FidError);
                                AutoItX.MouseClick(ButtonConstant.MouseLeft, win.WindowsAis.X + win.WindowsAis.Width - 20, win.WindowsAis.Y + 160);
                                break;
                            }
                        }
                    }
                }
                break;
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Атоматизация ветки
        /// Налоговое администрирование\Собственность\07. Взаимодействие с органами ГИБДД, Гостехнадзора – Наземные ТС
        /// </summary>
        /// <param name="pathjurnalerror">Путь к журналу с ошибками</param>
        /// <param name="pathjurnalok">Путь к журналу отработаных</param>
        /// <param name="fid">Значение ФИД</param>
        public void Click5(string pathjurnalerror, string pathjurnalok, string fid)
        {
            WindowsAis3 win = new WindowsAis3();

            win.ControlGetPos1(WindowsAis3.WinGrid[0], WindowsAis3.WinGrid[1], WindowsAis3.WinGrid[2]);
            AutoItX.MouseClick(ButtonConstant.MouseLeft, win.WindowsAis.X + win.X1 + 70, win.WindowsAis.Y + win.Y1 + 35);
            AutoItX.ClipPut(fid);
            AutoItX.Send(ButtonConstant.Right5);
            AutoItX.Send(ButtonConstant.Enter);
            AutoItX.Send(ButtonConstant.CtrlV);
            AutoItX.Send(ButtonConstant.F5);
            while (true)
            {
                if (AutoItX.WinExists(WindowsAis3.Text, WindowsAis3.DataNotFound) == 1)
                {
                    AutoItX.Send(ButtonConstant.F3);
                    LibaryXMLAuto.ErrorJurnal.ErrorJurnal.JurnalError(pathjurnalerror, fid, Okp4Pravo, WindowsAis3.DataNotFound);
                    break;
                }
                if (AutoItX.WinExists(WindowsAis3.Text, PravoZorI.Fid) == 1)
                {
                    AutoItX.MouseClick(ButtonConstant.MouseLeft, win.WindowsAis.X + 395, win.WindowsAis.Y + 90);
                    AutoItX.Send(ButtonConstant.Down3);
                    AutoItX.Send(ButtonConstant.Enter);
                    while (true)
                    {
                        if (AutoItX.WinExists(PravoZorI.WinTitle) == 1)
                        {
                            AutoItX.WinActivate(PravoZorI.WinTitle);
                            AutoItX.Send(ButtonConstant.Enter);
                            LibaryXMLAuto.ErrorJurnal.ErrorJurnal.JurnalError(pathjurnalerror, fid, Okp4Pravo, PravoZorI.ErrorText);
                            AutoItX.Send(ButtonConstant.F3);
                            break;
                        }
                        if (AutoItX.WinExists(PravoZorI.WinRemoveSved) == 1)
                        {
                            AutoItX.ControlSend(PravoZorI.WinRemoveSved, PravoZorI.Exlusive, Pravo.EditDate, DateTime.Now.ToString("d"));
                            AutoItX.ControlFocus(PravoZorI.WinRemoveSved, Pravo.EditNum[0], Pravo.EditNum[1]);
                            AutoItX.Send(PravoZorI.EditString, 1);
                            AutoItX.ControlClick(PravoZorI.WinRemoveSved, Pravo.ComboboxEdit[0], Pravo.ComboboxEdit[1], ButtonConstant.MouseLeft);
                            AutoItX.Send(ButtonConstant.Down3);
                            AutoItX.Send(ButtonConstant.Enter);
                            AutoItX.ControlClick(PravoZorI.WinRemoveSved, Pravo.ButtonOk[0], Pravo.ButtonOk[1], ButtonConstant.MouseLeft);
                            while (true)
                            {
                                if (AutoItX.WinExists(PravoZorI.WinTitle, PravoZorI.ErrorText2) == 1)
                                {
                                    AutoItX.WinActivate(PravoZorI.WinTitle);
                                    AutoItX.Send(ButtonConstant.Enter);
                                    LibaryXMLAuto.ErrorJurnal.ErrorJurnal.JurnalError(pathjurnalerror, fid, Okp4Pravo, PravoZorI.ErrorText2);
                                    AutoItX.Send(ButtonConstant.F3);
                                    break;
                                }
                                if (AutoItX.WinExists(PravoZorI.WinTitle, PravoZorI.OkDelete) == 1)
                                {
                                    AutoItX.Sleep(1000);
                                    AutoItX.WinActivate(PravoZorI.WinTitle);
                                    AutoItX.Send(ButtonConstant.Enter);
                                    LibaryXMLAuto.ErrorJurnal.OkJurnal.JurnalOk(pathjurnalok, fid, "Отработали фид права");
                                    AutoItX.Send(ButtonConstant.F3);
                                    break;
                                }
                            }
                            break;
                        }
                    }
                    break;
                }
            }
        }