Exemplo n.º 1
0
        public static int WriteText(int index, string text)
        {
            int           hWnd = ro_ListEdit[index];
            StringBuilder sb   = new StringBuilder(1024);

            sb.Append(text);
            Win32Handle.SendMessage(hWnd, Win32Handle.WM_WRITE, 0, sb);
            Thread.Sleep(_mediumWaitDuration);

            return(hWnd);
        }
Exemplo n.º 2
0
        private static int s_EnumChildGetValue(int hWnd, int lParam)
        {
            StringBuilder formDetails = new StringBuilder(256);
            int           txtValue;
            string        editText = "";

            txtValue = Win32Handle.GetWindowText(hWnd, formDetails, 256);
            editText = formDetails.ToString().Trim();
            if (editText == "")
            {
                Win32Handle.SendMessage(hWnd, Win32Handle.WM_GETTEXT, 256, formDetails);
                editText = formDetails.ToString().Trim();
            }
            ro_DictChildWindows.Add(hWnd, editText);

            StringBuilder cb = new StringBuilder(1024);

            Win32Handle.GetClassName(hWnd, cb, cb.Capacity);

            if (cb.ToString().Contains("Button"))
            {
                ro_ListButtons.Add(hWnd);
                ro_DictButtons.Add(hWnd, editText);
            }
            if (cb.ToString().Contains("Edit"))
            {
                ro_ListEdit.Add(hWnd);
                ro_ListEditValue.Add(editText);
                ro_DictEdit.Add(hWnd, editText);
            }
            if (!ro_ListClass.Contains(cb.ToString()))
            {
                ro_ListClass.Add(cb.ToString());
            }
            ro_DictChildWindowsValue.Add(hWnd + "_" + cb.ToString(), editText);

            return(1);
        }
Exemplo n.º 3
0
        public static IntPtr GetWindow(string windowFullName)
        {
            if (windowFullName.Equals(_currentWindowName))
            {
                GatLogger.Instance.AddMessage(string.Format("Window [{0}] is current window.", windowFullName));
                return(_currentWinHandle);
            }

            _currentWindowName = windowFullName;
            GatLogger.Instance.AddMessage(string.Format("Attempting to find window [{0}]", _currentWindowName));
            Callback myCallBack = new Callback(s_EnumChildGetValue);

            s_ClearLists();

            _currentWinHandle = Win32Handle.SearchForWindow(null, _currentWindowName);
            Win32Handle.EnumChildWindows((int)_currentWinHandle, myCallBack, 0);

            GatLogger.Instance.AddMessage(_currentWinHandle == IntPtr.Zero
                                              ? string.Format("Window [{0}] found", _currentWindowName)
                                              : string.Format("Warning Window [{0}] not found", _currentWindowName));

            return(_currentWinHandle);
        }
Exemplo n.º 4
0
        private static decimal _Trade(string cuspid, string side, int quantity)
        {
            GetWindow(strQT);
            int hWnd = 0;

            Thread.Sleep(_mediumWaitDuration);

            hWnd = WriteText(0, cuspid);
            Win32Handle.SetForegroundWindow(hWnd);

            Thread.Sleep(_shortWaitDuration);
            s_Go(side);
            Thread.Sleep(_mediumWaitDuration);

            IntPtr hWnd2 = GetWindow(strTicket);

            if (hWnd2 != IntPtr.Zero)
            {
                hWnd = WriteText(5, quantity.ToString());
                Win32Handle.SetForegroundWindow(hWnd);
                InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN);

                s_Go("Send");
            }

            Thread.Sleep(_extendedWaitDuration);
            IntPtr hWnd3 = GetWindow(strTrade);

            decimal val1 = 0;
            decimal val2 = 0;

            if ((int)hWnd3 != 0)
            {
                decimal price1 = 0;
                decimal price2 = 0;
                decimal price3 = 0;

                if (side == "SELL") // In the even that a broker doesnt list a proce, set it high som it ont get chosen.
                {
                    price1 = 1000;
                    price2 = 1000;
                    price3 = 1000;
                }

                if (ro_ListEditValue[1] != "")
                {
                    price1 = Convert.ToDecimal(ro_ListEditValue[1]);
                }
                if (ro_ListEditValue[3] != "")
                {
                    price2 = Convert.ToDecimal(ro_ListEditValue[3]);
                }
                if (ro_ListEditValue[5] != "")
                {
                    price3 = Convert.ToDecimal(ro_ListEditValue[5]);
                }

                int button1 = 10;
                int button2 = 12;
                int button3 = 14;

                if (side == "BUY")
                {
                    val1 = Math.Max(price1, price2);
                    val2 = Math.Max(val1, price3);
                }
                else
                {
                    val1 = Math.Min(price1, price2);
                    val2 = Math.Min(val1, price3);
                }
                int buttonPress = 0;

                if (val2 == price1)
                {
                    buttonPress = button1;
                }
                else if (val2 == price2)
                {
                    buttonPress = button2;
                }
                else if (val2 == price3)
                {
                    buttonPress = button3;
                }

                // HIT/LIFT button needs to be clicked twice for the trade to go thru
                ButtonClick(buttonPress);
                Thread.Sleep(_mediumWaitDuration);
                ButtonClick(buttonPress);

                // If Trade was not accepted, end trading
                Thread.Sleep(_longWaitDuration);
                hWnd3 = GetWindow(strTrade);
                if (s_Go("END TRADING"))
                {
                    val2 = 0;
                }
            }

            // close last open window
            IntPtr hWndClose = hWnd3;

            if ((int)hWndClose == 0)
            {
                hWndClose = hWnd2;
            }
            StringBuilder sb = new StringBuilder();

            Win32Handle.SendMessage((int)hWndClose, Win32Handle.WM_CLOSE, 0, sb);

            return(val2);
        }
Exemplo n.º 5
0
        private static void s_ClickButton(int hWnd)
        {
            StringBuilder sb = new StringBuilder(256);

            Win32Handle.SendMessage(hWnd, Win32Handle.BN_CLICKED, 0, sb);
        }