Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Click Click

Click Click

Scheduled Pinned Locked Moved C#
helpquestionlearning
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IceWater42
    wrote on last edited by
    #1

    I have succeeded in getting my code to successfully do mouse clicks on a commercial program, running at a specific screen location, using this code: SetForegroundWindow(targetWindowHandle); input.type = INPUT_MOUSE; input.mi.dx = 900; input.mi.dy = 50; input.mi.mouseData = 0; input.mi.time = 0; input.mi.dwFlags = 0; input.mi.dwExtraInfo = 0; SetCursorPos(input.mi.dx, input.mi.dy); input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE+MOUSEEVENTF_LEFTDOWN); resSendInput = SendInput(1, ref input, Marshal.SizeOf(input)); input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_LEFTUP); resSendInput = SendInput(1, ref input, Marshal.SizeOf(input)); The problem is, of course, if the window is moved, the clicks miss. I would love to be able to do the clicks relative to position 0,0 of the window pointed at by targetWindowHandle instead of relative to position 0,0 of the screen. (I hope that statement makes sense to you guys.) Any suggestions? :rolleyes: Thanks. :rolleyes: -- modified at 20:11 Wednesday 22nd February, 2006

    I 1 Reply Last reply
    0
    • I IceWater42

      I have succeeded in getting my code to successfully do mouse clicks on a commercial program, running at a specific screen location, using this code: SetForegroundWindow(targetWindowHandle); input.type = INPUT_MOUSE; input.mi.dx = 900; input.mi.dy = 50; input.mi.mouseData = 0; input.mi.time = 0; input.mi.dwFlags = 0; input.mi.dwExtraInfo = 0; SetCursorPos(input.mi.dx, input.mi.dy); input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE+MOUSEEVENTF_LEFTDOWN); resSendInput = SendInput(1, ref input, Marshal.SizeOf(input)); input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_LEFTUP); resSendInput = SendInput(1, ref input, Marshal.SizeOf(input)); The problem is, of course, if the window is moved, the clicks miss. I would love to be able to do the clicks relative to position 0,0 of the window pointed at by targetWindowHandle instead of relative to position 0,0 of the screen. (I hope that statement makes sense to you guys.) Any suggestions? :rolleyes: Thanks. :rolleyes: -- modified at 20:11 Wednesday 22nd February, 2006

      I Offline
      I Offline
      IceWater42
      wrote on last edited by
      #2

      for those interested ... The solution was rather trivial after i found "GetWindowRect" in User32: public struct RECT { public int left; public int top; public int right; public int bottom; } [DllImport("user32.dll")] public static extern int GetWindowRect(int hwnd, ref RECT rc); // Get the target window's screen coordinates RECT rect = new RECT(); int hwnd = GetWindowRect((int)targetWindowHandle, ref rect); Persistence pays ... :cool: --- -- modified at 15:34 Thursday 23rd February, 2006

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups