D4rk^S0ul Posted March 16, 2009 Share Posted March 16, 2009 I'm sure there must be a easy explanation why this problem is happening but i have never really worked with controlclick before. What i am trying to do is make a program that duplicates clicks from one window to another exact window i tried it but it does not seem to be sending the click, the window i am trying to duplicate does not have class controls and i have been trying with mspaint aswell to see if i could make it paint where i click (I know it wont hold down the button but it does not even drop a single dot on the page). While i was looking at it i had a feeling that control click could have been made just to press a control like a button but i am hoping it is possible to use it to click anywhere on a window. This is the code i have been trying to get to work, I am using 2 paint windows so that i can see where it should be setting a paint drop at: #include <Misc.au3> $dll = DllOpen("user32.dll") Opt("MouseCoordMode", 2) While 1 If _IsPressed("01", $dll) Then $MousePos = MouseGetPos() ControlClick("Untitled", "", "", "left", 1, $MousePos[0], $MousePos[1]) EndIf Sleep(250) WEnd Any help will be greatly appreciated. Link to comment Share on other sites More sharing options...
Authenticity Posted March 16, 2009 Share Posted March 16, 2009 What about: ControlClick("untitled", "", "Afx:1000000:81", "left", 1, $MousePos[0], $MousePos[1]) Link to comment Share on other sites More sharing options...
D4rk^S0ul Posted March 16, 2009 Author Share Posted March 16, 2009 What about: ControlClick("untitled", "", "Afx:1000000:81", "left", 1, $MousePos[0], $MousePos[1]) Unfortunately i have already tried this and it does now work, plus the window i am trying to do it in does not have controlid's i am just using paint as a tester but it seems neither programs it works in with or without the control id. Link to comment Share on other sites More sharing options...
Authenticity Posted March 16, 2009 Share Posted March 16, 2009 Can you post the AutoIt Window Info summary? Also, what isn't working for you right now? the dot on the mspaint? maybe you need to convert the coords to the client area of mspaint, even though you're using Opt("MouseCoordMode", 2), just a guess. Link to comment Share on other sites More sharing options...
D4rk^S0ul Posted March 16, 2009 Author Share Posted March 16, 2009 Shamefully i cannot copy and paste it since the computer i am running the program on is not the one i am posting from due to some strange happenings with my internet on it (If i use the explorer to much or open to many tabs watching things etc, it just stops responding to webpages but not most internet applications) i am not sure why it would not work on mspaint but i have a feeling while checking the summary on the game i am trying to do it on that it just is not possible i am getting nothing but the handle showing up on control no controlclick coords, class or instance. I don't know why this is it just must be how it is made it just shows up with nothing. Link to comment Share on other sites More sharing options...
Authenticity Posted March 16, 2009 Share Posted March 16, 2009 (edited) So it's a game. It should be mentioned earlier.Anyway, I'm quite sure the ClassNN of mspaint is Afx:1000000:81 for the ControlID parameter of ControlClick. About the coords, again, I think you should not use the Opt("MouseCoordMode", 2) option.Example that works fine on my end:expandcollapse popup#include <Misc.au3> HotKeySet('{ESC}', '_EXIT') Run('mspaint "' & @ScriptDir & '\tranathuluank9.jpg"') ShellExecute('"' & @ScriptDir & '\tranathuluank9.jpg"') WinWait('[CLASS:ShImgVw:CPreviewWnd]') WinWaitActive('[CLASS:MSPaintApp]') Dim $dll = DllOpen('user32.dll'), $Pos Dim $PT = DllStructCreate('int;int'), $pPT = DllStructGetPtr($PT) Dim $hWnd = WinGetHandle('[CLASS:MSPaintApp]') While 1 If _IsPressed('01', $dll) Then $Pos = MouseGetPos() DllStructSetData($PT, 1, $Pos[0]) DllStructSetData($PT, 2, $Pos[1]) ConsoleWrite('Before -> iX: ' & DllStructGetData($PT, 1) & @TAB & 'iY: ' & DllStructGetData($PT, 2) & @LF) DllCall($dll, 'int', 'ScreentoClient', 'hwnd', $hWnd, 'ptr', $pPT) ConsoleWrite('After -> iX: ' & DllStructGetData($PT, 1) & @TAB & 'iY: ' & DllStructGetData($PT, 2) & @LF) For $i = -5 To 5 ControlClick($hWnd, '', 'Afx:1000000:81', 'right', 1, $Pos[0]+$i, $Pos[1]+$i) Next EndIf Sleep(20) WEnd Func _EXIT() DllClose($dll) Exit EndFunc.jpg is attached.I've opened it using Windows Picture and Fax Viewer and clicked on a spot there, then switch to the mspaint and it draws white lines, but not in the place they should be (press upper left to see the lines in the ~middle) but it's another thing. Edited March 16, 2009 by Authenticity Link to comment Share on other sites More sharing options...
D4rk^S0ul Posted March 16, 2009 Author Share Posted March 16, 2009 Very nice mate cheers, it seems to just draw the lines slightly off due to the tool bars on the side as it is getting the coords from the beginning of the control, I will have to give this a test see if this also works on the other app. Link to comment Share on other sites More sharing options...
Authenticity Posted March 17, 2009 Share Posted March 17, 2009 It's because the Windows Picture and Fax Viewer is adding or padding the picture with white border, if it was 1:1 then the client position of the mspaint may be exactly where you hit the picture (or window as in your case). 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