Jump to content
Sign in to follow this  
smcombs

ControlClick only works when mouse is hovering over it

Recommended Posts

smcombs

Not sure why this is must be the game. Though I would try my hand at making a bot not sure if thats allowed to be discussed here but please let me know if not. Everything works pretty well, but my controlclick does not seem to work unless my mouse is hovering over the area to be clicked, same whether the window is active or unactive. Tried doing a controlfocus and that didnt seem to work, anywho here is my code:

CODE
HotKeySet("{ESC}", "Terminate")

$handle = ControlGetHandle("game", "", "[CLASS:AfxWnd42; INSTANCE:5]")

$handle2 = ControlGetHandle("game", "", "[CLASS:AfxWnd42; INSTANCE:2]")

While 1

Sleep(100)

If PixelGetColor(739, 289) = 0xFF9933 Then

Controlclick("game", "", $handle, "left", 1, 615, 30)

Else

Sleep(1000)

$coord = PixelSearch(30, 52,644, 377, 0x009900,0,2)

If Not @error Then

Controlclick("game","", $handle2, "left", 1, $coord[0], $coord[1])

;MouseClick("left", $coord[0], $coord[1])

Else

Controlclick("game", "", $handle, "left", 1, 657, 29)

EndIf

EndIf

WEnd

Func Terminate()

Exit

EndFunc

Let me know of any ideas why this may be. Thanks

Edited by smcombs

Share this post


Link to post
Share on other sites
bo8ster

ControlClick will work with a valid handle and proper coords. I can't tell if you get a valid handle but im not sure PixelSearch is giving you the coords you think.

Have a look firstly at the MouseCoordMode option, then do some testing with MouseGetPos/MouseMove.

I would suggest using a ConsoleWrite to see if yo have the correct coords.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites
Bowmore

From my experiences there are some non-standard controls that will not respond to clicks etc. unless the mouse cursor is first possitiond over the control. If this is the case then you need to use MouseMove() to position the cursor over the control. The control will then usually respond to ControlClick() or MouseClick().


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
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
Sign in to follow this  

×