Jump to content

ControlClick Problem


Recommended Posts

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

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. :P

Link to comment
Share on other sites

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

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:

#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.

post-45291-1237243228_thumb.jpg

Edited by Authenticity
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...