ControlClick problem [UNSOLVED]

Recommended Posts

ARozanski 0

ARozanski 0

Hey guys...i have created a program that finds something in a window and then right-clicks on it...but the window is not maximized so i need to find the actual object. Now i know where the object is on my screen. Let's say it's at [x,y]. This is what i did...

$WinPos = WinGetPos("ABC","","")

x = x - $WinPos[0] ; gives me a new 'x' and 'y' mathematically depending on where the object is on the screen and what the position of the window is

y = y - $WinPos[1]

So now TECHNICALLY it should work...but it doesn't...

IF i have my mouse in the window it actually ends up right-clicking at wherever the mouse is...which is also wrong....why is it not working :-(

Share this post

Link to post

Share on other sites

ARozanski 0

ARozanski 0

You are totally RIGHT! i am extremely sorry, i re-read my own post and couldn't even understand what i was trying to say...hehehe...

Ok, here goes again.

I am trying to create a B O T for a game that right-clicks on a target whenever a specific target comes into focus on the window. Now, Since i want to be using my computer while this thing is running, everything i have done works with ControlSend and ControlClick and the window is NOT maximized... but the ControlClick does not work for me...

so this is what happens...

ControlClick "Sends a mouse click command to a given control" to "the x,y position to click within the control." -- Therefore, it will not be the usual x,y in my screen BUT the x,y in the window of the game...

Share this post

Link to post

Share on other sites

ARozanski 0

ARozanski 0

You'll have to translate WinGetPos()'s "screen" coordinates to "Client" coordinates (Control functions only work within the client area of the window).

Might do a search for ScreenToClient.

Thanks...i will change my code to ScreenToClient becuase it is less sloppy, but my function already finds the x,y of the target BECAUSE - it already knows the screen x,y of the target and then i work it out by subtracting the x,y value on the target (in the screen) by the x,y value of the position of the window...my problem is that the controlclick is not working...

Share this post

Link to post

Share on other sites

SmOke_N 199

SmOke_N 199

Thanks...i will change my code to ScreenToClient becuase it is less sloppy, but my function already finds the x,y of the target BECAUSE - it already knows the screen x,y of the target and then i work it out by subtracting the x,y value on the target (in the screen) by the x,y value of the position of the window...my problem is that the controlclick is not working...

If you have the "Screen" xy coords, then ScreenToClient is all you would need.

Share this post

Link to post

Share on other sites

ARozanski 0

ARozanski 0

Sorry, i dont think you understand me...my program works out the X,Y of the target IN the control window. i even checked it out...its 100%...but something is wrong with my CONTROLCLICK - it just doesn't click where i ask it to :-/ ... i fact - i think it doesn't click at all in the control window

thanks again...

Edited November 27, 2008 by ARozanski

Share this post

Link to post

Share on other sites

SmOke_N 199

SmOke_N 199

Sorry, i dont think you understand me...my program works out the X,Y of the target IN the control window. i even checked it out...its 100%...but something is wrong with my CONTROLCLICK - it just doesn't click where i ask it to :-/ ... i fact - i think it doesn't click at all in the control window

thanks again...

So what you are saying is... "SmOke_N, I have the x and y "Client Coordinates", however ControlClick() is still failing"?

1. You are not using any control identifier.

2. I'm done with the cloak and dagger... There's no replication script, and no idea what to even test in.

Might try manipulating _MouseClickPlus() to suit your needs.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post

Link to post

Share on other sites

ARozanski 0

ARozanski 0

Presumably between steps 3 and 4 in your list you moved the mouse to the correct position. Have you tried adding a delay so you can see where the mouse click is made?

As far as competence is concerned I suspect you could fix it yourself if you carefully checked and tested each step, adding something to help you debug your script and so on.

Well - the mouseclick version works just fine - that was child's play...but for SOME REASON ControlClick does not. I don't know, MAYBE it just doesn't work all the time...who knows...im just waiting for an answer...as far as checking all possible problems:

1) i checked that the calculations for the x,y coords in the game window were correct (they are)\

2) i activated the window just incase that was the problem (like the helpfile said) - didnt solve anything...

3) i moved the mouse over the game and it clicks where ever my mouse is - which means that the controlclick function works to some extent...just not the desired extent :-(

Share this post

Link to post

Share on other sites

SmOke_N 199

SmOke_N 199

Well - the mouseclick version works just fine - that was child's play...but for SOME REASON ControlClick does not. I don't know, MAYBE it just doesn't work all the time...who knows...im just waiting for an answer...as far as checking all possible problems:

1) i checked that the calculations for the x,y coords in the game window were correct (they are)\

2) i activated the window just incase that was the problem (like the helpfile said) - didnt solve anything...

3) i moved the mouse over the game and it clicks where ever my mouse is - which means that the controlclick function works to some extent...just not the desired extent :-(

I don't think you've heard or understood a thing I've said... GL.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.