• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 525
  • Last Modified:

Click External Button on seperate windows app

I would like to Programatically click on an external Button in a windows app.
I have downloaded Windowscrape.dll and using SPY++ to get the handler, etc...
using Visual Studio 2010.
Most examples i've seen haven't been helping me out...would appreciate it!
  • 2
1 Solution
a vb code, but you can get ideas through the lines of code you will see;
Shaggy1Author Commented:
Figured it out...here is what i got..

 [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
        static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);

        static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);

        public enum MouseEventFlags
            LEFTDOWN = 0x00000002,
            LEFTUP = 0x00000004,
            MIDDLEDOWN = 0x00000020,
            MIDDLEUP = 0x00000040,
            MOVE = 0x00000001,
            ABSOLUTE = 0x00008000,
            RIGHTDOWN = 0x00000008,
            RIGHTUP = 0x00000010

        public static void LeftClick(int x, int y)
            Cursor.Position = new System.Drawing.Point(x, y);
            mouse_event((int)(MouseEventFlags.LEFTDOWN), 0, 0, 0, 0);
            mouse_event((int)(MouseEventFlags.LEFTUP), 0, 0, 0, 0);

        private void timer2_Tick(object sender, EventArgs e)
            LeftClick(1050, 72);
            LeftClick(1180, 77);
            LeftClick(1180, 100);

Open in new window

Shaggy1Author Commented:
this is the solution

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now