• 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!
0
Shaggy1
Asked:
Shaggy1
  • 2
1 Solution
 
systanCommented:
a vb code, but you can get ideas through the lines of code you will see;
http://www.vbforums.com/showthread.php?t=345259
0
 
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);

        [DllImport("user32.dll")]
        static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);



        [Flags]
        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);
            timer2.Stop();
        }

Open in new window

0
 
Shaggy1Author Commented:
this is the solution
0

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