sesk Posted August 21, 2015 Share Posted August 21, 2015 I've got a window point (x,y) I want to click without hogging the mouse pointer. I checked my options out and other than using SendMessage, there's ControlClick.I made a test script in AutoIt, it works, correct hwnd found, the click occurs.I ported it to C#, I get the same hwnd, but the click does not occurHere's the AutoIt Code#include <WinAPI.au3> $pos = _WinAPI_GetMousePos() $hwnd = _WinAPI_WindowFromPoint($pos) MsgBox(0, "", $hwnd) ControlClick($hwnd, "", 0, "left", 1, 526, 31) And here's the partial C# code[DllImport("user32.dll")] static extern IntPtr WindowFromPoint(POINT point); Rectangle rct = GetWindowRectangle();//uses AutoItX.WinGetPos POINT p = new POINT(); p.x = rct.Left + 1; p.y = rct.Top + 1; Move(p.x, p.y); hWnd = WindowFromPoint(p);//hWnd matches the hwnd found in the autoit script AutoItX.ControlClick(hWnd, IntPtr.Zero, "left", 1, 526, 31);The only thing I can think of that may be wrong is passing IntPtr.Zero for the control handle. I didn't find any examples using the second definition of ControlClick (windowhandle & controlhandle) so I am unsure. Anyone with experience with this ? Link to comment Share on other sites More sharing options...
CrypticKiwi Posted August 22, 2015 Share Posted August 22, 2015 i got no experience with this at all but searching lead me to this Link And this Link they might be related and helpful... Link to comment Share on other sites More sharing options...
sesk Posted August 22, 2015 Author Share Posted August 22, 2015 Solved it: Had to ControlGetHandle on the windowIntPtr ctrlHandle = AutoItX.ControlGetHandle(hWnd); AutoItX.ControlClick(hWnd, ctrlHandle, "left", 1, x, y); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now