Beispiel #1
0
        public static Hashtable GetRunningObjectTable()
        {
            Hashtable result = new Hashtable();

            IntPtr numFetched = IntPtr.Zero;
            IRunningObjectTable runningObjectTable;
            IEnumMoniker        monikerEnumerator;

            IMoniker[] monikers = new IMoniker[1];

            SUIWinAPIs.GetRunningObjectTable(0, out runningObjectTable);
            runningObjectTable.EnumRunning(out monikerEnumerator);
            monikerEnumerator.Reset();

            while (monikerEnumerator.Next(1, monikers, numFetched) == 0)
            {
                IBindCtx ctx;
                SUIWinAPIs.CreateBindCtx(0, out ctx);

                string runningObjectName;
                monikers[0].GetDisplayName(ctx, null, out runningObjectName);

                object runningObjectVal;
                runningObjectTable.GetObject(monikers[0], out runningObjectVal);

                result[runningObjectName] = runningObjectVal;
            }

            return(result);
        }
Beispiel #2
0
 private static void SendInputs(INPUT[] inputs)
 {
     if (inputs != null && inputs.Length > 0)
     {
         SUIWinAPIs.SendInput(inputs.Length, inputs, Marshal.SizeOf(inputs[0]));
     }
 }
Beispiel #3
0
        public static void InitializeSMARTUI(SUIWindow sui)
        {
            int    proId     = 0;
            IntPtr winThread = SUIWinAPIs.GetWindowThreadProcessId(sui.WindowHandle, ref proId);
            IntPtr curThread = SUIWinAPIs.GetCurrentThreadId();

            SUIWinAPIs.AttachThreadInput(curThread, winThread, 1);
        }
Beispiel #4
0
        private static byte GetVirtualKeyCode(char character)
        {
            IntPtr    KeyboardLayout = SUIWinAPIs.GetKeyboardLayout(0);
            HandleRef keyboardLayout = new HandleRef(null, KeyboardLayout);
            short     num            = SUIWinAPIs.VkKeyScanEx(character, keyboardLayout);

            return(Convert.ToByte(num & 0xff, CultureInfo.InvariantCulture));
        }
Beispiel #5
0
 public static void MouseMove(int x, int y, bool NeedTransfer)
 {
     if (NeedTransfer)
     {
         PixelsToAbsNormalCoors(x, y, ref x, ref y);
     }
     SUIWinAPIs.mouse_event((uint)(MouseEventFlags.ABSOLUTE | MouseEventFlags.MOVE), (uint)x, (uint)y, 0, 0);
 }
Beispiel #6
0
 public static void MouseDrag(SUIWindow startWindow, int xStart, int yStart, SUIWindow endWindow, int xEnd, int yEnd)
 {
     xStart += startWindow.X; yStart += startWindow.Y;
     xEnd   += endWindow.X; yEnd += endWindow.Y;
     MouseMove(xStart, yStart);
     SUIWinAPIs.mouse_event((uint)(MouseEventFlags.ABSOLUTE | MouseEventFlags.LEFTDOWN), (uint)xStart, (uint)yStart, 0, 0);
     MouseMove(xEnd, yEnd);
     SUIWinAPIs.mouse_event((uint)(MouseEventFlags.ABSOLUTE | MouseEventFlags.LEFTUP), (uint)xEnd, (uint)yEnd, 0, 0);
 }
Beispiel #7
0
 public static void MouseRightClick(int x, int y, bool NeedTransfer)
 {
     if (NeedTransfer)
     {
         PixelsToAbsNormalCoors(x, y, ref x, ref y);
     }
     SUIWinAPIs.mouse_event((uint)(MouseEventFlags.ABSOLUTE | MouseEventFlags.RIGHTDOWN), (uint)x, (uint)y, 0, 0);
     SUIWinAPIs.mouse_event((uint)(MouseEventFlags.ABSOLUTE | MouseEventFlags.RIGHTUP), (uint)x, (uint)y, 0, 0);
 }
Beispiel #8
0
 public static void MouseDrag(int xStart, int yStart, int xEnd, int yEnd)
 {
     MouseMove(xStart, yStart);
     SUISleeper.Sleep(500);
     SUIWinAPIs.mouse_event((uint)(MouseEventFlags.ABSOLUTE | MouseEventFlags.LEFTDOWN), (uint)xStart, (uint)yStart, 0, 0);
     SUISleeper.Sleep(500);
     MouseMove(xEnd, yEnd);
     SUISleeper.Sleep(500);
     SUIWinAPIs.mouse_event((uint)(MouseEventFlags.ABSOLUTE | MouseEventFlags.LEFTUP), (uint)xEnd, (uint)yEnd, 0, 0);
     SUISleeper.Sleep(500);
 }
Beispiel #9
0
        public int FindTargetWindow(IntPtr HWND, int lpram)
        {
            int processId = 0;

            SUIWinAPIs.GetWindowThreadProcessId(HWND, ref processId);
            if (processId == lpram)
            {
                if (SUIWinAPIs.IsWindowVisible(HWND))
                {
                    mainWindow = new SUIWindow(HWND);
                    return(0);
                }
            }
            return(1);
        }
Beispiel #10
0
        //public SUIWindow StartApplication(string exepath, string title)
        //{
        //    Process p = new Process();
        //    p.StartInfo.FileName = exepath;
        //    p.Start();

        //    Thread.Sleep(1000);
        //    SUIWindow desktop = SUIWindow.DesktopWindow;
        //    SUIWindow sui = SUIWindow.FindSMARTUIWindow(desktop, null, title);

        //    SUIProcess.InitializeSMARTUI(sui);
        //    sui.Maximized = true;
        //    return sui;
        //}

        public SUIWindow FindMainWindowByID(int processId)
        {
            SUIWinAPIs.EnumWindows(new SUI.Base.SUIWindow.EnumSMARTUIWindowsProc(FindTargetWindow), processId);
            return(mainWindow);
        }
Beispiel #11
0
 private static void SendInput(INPUT input)
 {
     SUIWinAPIs.SendInput(1, new INPUT[] { input }, Marshal.SizeOf(input));
 }
Beispiel #12
0
 public static void Release(VK key)
 {
     Thread.Sleep(pause);
     SUIWinAPIs.keybd_event((byte)key, 0, 2, 0);
 }
Beispiel #13
0
 public static void Press(char key)
 {
     Thread.Sleep(pause);
     SUIWinAPIs.keybd_event((byte)key, 0, 0, 0);
 }
Beispiel #14
0
 public static void Type(VK key, int pauserate)
 {
     Thread.Sleep(pauserate);
     SUIWinAPIs.keybd_event((byte)key, 0, 0, 0);
     SUIWinAPIs.keybd_event((byte)key, 0, 2, 0);
 }