Jump to content
Sign in to follow this  
Storm

ControlClick

Recommended Posts

Storm

Hi,

I just cant get controlclick to work.

This is what I tried to do.

;http://mamasgotmoxie.com/wp-content/uploads/2008/10/play-doh-magic-swirl-ice-cream-shoppe.jpeg
controlclick("http://mamasgotmoxie.com/wp-content/uploads/2008/10/play-doh-magic-swirl-ice-cream-shoppe.jpeg - Windows Internet Explorer", "","" , "left", 1, 751, 453)

I was just doing this to see if this command works, csince I wasent having any luck with getting oit to work with a game. I thought I would try on a simple internet explorer.

Just go to http://mamasgotmoxie.com/wp-content/upload...eam-shoppe.jpeg and the image will streatch bigger than your monitor, soo just clik on it once to zoom in, and nother click should zoom out, so if the command worked the picture would zoom back in, but I get ablsolutly nothing from it.

I am sure, it is a simple mistake on my part.

Share this post


Link to post
Share on other sites
KaFu

You didn't identifiy the control to click. x&y is "[optional] The x position to click within the control. Default is center."

ControlClick("http://mamasgotmoxie.com/wp-content/uploads/2008/10/play-doh-magic-swirl-ice-cream-shoppe.jpeg", "", "[CLASSNN:ToolbarWindow325]","left")

Share this post


Link to post
Share on other sites
Storm

Hi,

All right, now my script reads like this.

#include <WinAPI.au3>
HotKeySet("{ScrollLock}", "Tabs")
Opt('MustDeclareVars', 1)

GLobal $hWnd, $hWndTAB, $pos, $posTAB, $position, $control, $controlTAB
While 1
Sleep(5000)
WEnd
Func Tabs()
HotKeySet("{ScrollLock}")
HotKeySet("{ScrollLock}", "Main")
$hWndTAB = WinGetHandle("")
$controlTAB = ControlGetFocus($hWnd)
$controlTAB = ("[CLASSNN:"& $controlTAB &"]")
$posTAB = MouseGetPos()
While 1
Sleep(5000)
WEnd
EndFunc

Func Main()
HotKeySet("{ScrollLock}")
$hWnd = WinGetHandle("")
$control = ControlGetFocus($hWnd)
$control = ("[CLASSNN:"& $control &"]")
$pos = MouseGetPos()
$position = ($pos[1] + 265)
Click()
EndFunc

Func Click()
HotKeySet("{ScrollLock}")
while 1 
ControlClick($hWnd, "", $control,"middle",1,$pos[0],$pos[1])
ControlClick($hWnd, "", $control,"middle",1,$pos[0],$position)
sleep (1000)
ControlClick($hWndTAB, "", $controlTAB,"middle",1,$posTAB[0],$posTAB[1])
sleep (1000)
ControlClick($hWndTAB, "", $controlTAB,"middle",1,$posTAB[0],$posTAB[1])
Sleep(5000)
WEnd    
exit
EndFunc

This script is meant to middle click a link on a page to open it in a new tab, then middle click another link to open in new tab as well.

After this it will then close the 2 new tabs.

And then after a specified time do the same thing over again.

I didnt want to be restricted by entering the details like title, classnn, mouse position, etc, so I can use it on any computer with any resoloution, on any browser.

So Basically now all I have to do is move my mouse over to where the next tab will open and press SCROLLLOCK once. It will take note of the classnn, window handle and the mouse cordinates, so it knows where to middle click to close the new tab. After that I just move my mouse to the first link and press SCROLLLOCK again. This time it will take the details for where to middle click to open new tabs. Now the second link sahres the X cordinate with the first link, and the Y cordinate will be exactly 265 pixels below the first one, so i just use the mouse position from the first link, to get the position of the second link too. After this the hotkey SCROLLLOCK is disabled so it wont interfare with the script and if free to be used by other programs.

However now my problem is, that this command is getting the mouse cordinates regardless ofthe control. I need the cordinates for the mouse within that particular control. How do I do this? Is there a command for this or maybe some user script.

Edited by Storm

Share this post


Link to post
Share on other sites
Storm

Anyone?

All I am asking is for a command that gives me current mouse coordinates regarding to the control.

If such a command doesn't exist let me know please.

Share this post


Link to post
Share on other sites
KaFu

What you could do is...

get the Position of the Window with WinGetPos()

get the relative position of the control with ControlGetPos()

and calculate the absolute difference to MouseGetPos().

To be honest I've started this way too, trying to identify controls, move the mouse and emulate clicks. Only to switch to the (little more complicated but) more reliable use of either the UDF <IE.au3> (standard UDF) of <FF.au3> (search the examples) to access the info directly. This way you're not dependent that nobody touches the mouse or keyboard or that you're script is busted because the user has a different screen resolution then you have :)...

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.