Jump to content
Sign in to follow this  
Storm

A basic ControlClick question

Recommended Posts

Storm

Hi,

I got a question about controlclick.

I am basically trying to make a script, that will control the multiple versions of the game running at the same time.

When I was plotting an outline on what I want to achieve, I had just found out about controlsend, that lets you send text to a window, even without focusing on it. That means, you are free to do your stuff, while it keeps working in the background.

Now basically I have to control 4 game clients simultaneously while I am on the 5th one.

My aim was to use the same script for this, so I could control the clients somewhat by using hotkeys.

But the problem is I need to use mouse to do some clicking, and in the beginning I thought that controlclick was the same as controlsend, only for mouse.

So far, I have tried so many things but I just cant get it to run without showing an error. I cant even test if this command will actually do what I need.

Basically I will be trying to click on a particular cordinates. I got the cordinates, but what is the proper way to use the command? Since it is a game there is no name of the control.

The only info I can give you is I know the title of the window, it will have to be a single left click and the cordinates are known.

I know this seems a very noob request, but I tried searching google already, and I couldnt find my answers.

Share this post


Link to post
Share on other sites
Drew

It would help out if you'd give us a bit of your code lol.

It might just be a typo or something.

Share this post


Link to post
Share on other sites
Storm

ControlClick( "RebirthRO Server", "", "", "left" , 1 , 400 , 600 )

There is no script yet, cause I cant start until I know if I can even use this command.

This is what I tried anyway.

So far I havent even been able to run the script without getting an error so I havent even had a chance to play with it.

Share this post


Link to post
Share on other sites
Manjish

See, Control Click will click a control, eg a button.

What i suggest u do is this:

1st select the control u want to click on.

Use the Autoit Window Info tool, to get the info regarding the control, from the control tab.

Put the data in respective fields..

controlClick("title","","[advanced Class]","left",1,x,y)


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites
Storm

The game actually has no controls that the autoit can detect.

So unfortunately that option is out for me.

Cant I treat the whole window as 1 control?

In case this helps this is the summery of the window.

>>>> Window <<<<

Title: RebirthRO Server ( www.RebirthRO.com Version 11.0

Class: RebirthRO Server ( www.RebirthRO.com Version 11.0

Position: 320, 160

Size: 646, 513

Style: 0x16CA0000

ExStyle: 0x00000100

Handle: 0x001C01F4

>>>> Control <<<<

Class:

Instance:

ClassnameNN:

Advanced (Class):

ID:

Text:

Position:

Size:

ControlClick Coords:

Style:

ExStyle:

Handle: 0x0010049E

>>>> Mouse <<<<

Position: 910, 390

Cursor ID: 15

Color: 0x63849C

>>>> StatusBar <<<<

>>>> Visible Text <<<<

>>>> Hidden Text <<<<

Share this post


Link to post
Share on other sites
Drew

This isn't for like... Diablo or something is it?

Share this post


Link to post
Share on other sites
Storm

Ragnarok Online.

I suppose you can compare it to diablo.

Basically, there is this part of the game where you need 5 people, but just trying to gather 5 people takes ages, basically not worth it.

I thought why not make a script that can work 4 of the players, and I can be the 5th one, and control the other 4 via hotkeys. Will be crude, but should be effective.

I tried the code by keeping the Control ID blank, and then again by using the title in the ControlID.

Didnt work either time. Btw this is how I tried to test it.

HotKeySet("{Home}", "Start")
HotKeySet("{Delete}", "Pause")

While 1
Sleep(5000)
WEnd

Func Start()
controlClick("RebirthRO Server ( www.RebirthRO.com Version 11.0","","RebirthRO Server ( www.RebirthRO.com Version 11.0","left",1,300,500)
pause()
EndFunc

Func Pause()
    While 1
    Sleep(5000)
    WEnd
EndFunc
Edited by Storm

Share this post


Link to post
Share on other sites
Zohar

Basically, there is this part of the game where you need 5 people, but just trying to gather 5 people takes ages, basically not worth it.

I thought why not make a script that can work 4 of the players, and I can be the 5th one, and control the other 4 via hotkeys. Will be crude, but should be effective.

hehe:))

great idea.

I was in the same problem too.

I found a solution.

I wrote it here:

http://www.autoitscript.com/forum/index.ph...t=0#entry636051

Edited by Zohar

Share this post


Link to post
Share on other sites
Storm

Thanks a lot man.

This is exactly what I was after.

Now i am very new to autoit or any programing language for that matter.

How do I use it?

If you give me an example I should be able to work it out.

Also what is MouseCoordMode?

Just a basic example will be enough. :)

Edited by Storm

Share this post


Link to post
Share on other sites
Zohar

Press F1(while in SciTE), and start reading :]

Edited by Zohar

Share this post


Link to post
Share on other sites
Storm

So. now something like this should work right?

HotKeySet("{Home}", "Start")
HotKeySet("{Delete}", "Pause")

Opt("MouseCoordMode", 0)
While 1
Sleep(5000)
WEnd

Func Start()
_MouseClickPlus(RebirthRO Server ( www.RebirthRO.com Version 11.0, left, 300, 500, 1)
pause()
EndFunc

Func Pause()
    While 1
    Sleep(5000)
    WEnd
EndFunc


Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
Local $MK_LBUTTON = 0x0001
Local $WM_LBUTTONDOWN = 0x0201
Local $WM_LBUTTONUP = 0x0202

Local $MK_RBUTTON = 0x0002
Local $WM_RBUTTONDOWN = 0x0204
Local $WM_RBUTTONUP = 0x0205

Local $WM_MOUSEMOVE = 0x0200

Local $i = 0

Select
Case $Button = "left"
$Button = $MK_LBUTTON
$ButtonDown = $WM_LBUTTONDOWN
$ButtonUp = $WM_LBUTTONUP
Case $Button = "right"
$Button = $MK_RBUTTON
$ButtonDown = $WM_RBUTTONDOWN
$ButtonUp = $WM_RBUTTONUP
EndSelect

If $X = "" OR $Y = "" Then
$MouseCoord = MouseGetPos()
$X = $MouseCoord[0]
$Y = $MouseCoord[1]
EndIf

For $i = 1 to $Clicks
DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $WM_MOUSEMOVE, "int", 0, "long", _MakeLong($X, $Y))

DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $ButtonDown, "int", $Button, "long", _MakeLong($X, $Y))

DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $ButtonUp, "int", $Button, "long", _MakeLong($X, $Y))
Next
EndFunc

Func _MakeLong($LoWord,$HiWord)
Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

I wont get a chance to try it out until later, So I will post how I went with this later.

Edited by Storm

Share this post


Link to post
Share on other sites
Storm

All right..

It is probably me being an idiot, but I cannot get this to work at all.

It registers the hotkey just fine, goes on to the function you gave me fine too, but then nothing happens.

Am I supposed to get a return value from the second function or something?

I even made sure that the focus was on the window.

HotKeySet("{Home}", "Start")
HotKeySet("{Delete}", "Pause")

Opt("MouseCoordMode", 0)
While 1
Sleep(5000)
WEnd

Func Start()
_MouseClickPlus("RebirthRO Server ( www.RebirthRO.com Version 11.0", "left", 300, 500, 1)
pause()
EndFunc

Func Pause()
    While 1
    Sleep(5000)
    WEnd
EndFunc
    
Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
Local $MK_LBUTTON = 0x0001
Local $WM_LBUTTONDOWN = 0x0201
Local $WM_LBUTTONUP = 0x0202

Local $MK_RBUTTON = 0x0002
Local $WM_RBUTTONDOWN = 0x0204
Local $WM_RBUTTONUP = 0x0205

Local $WM_MOUSEMOVE = 0x0200

Local $i = 0

Select
Case $Button = "left"
$Button = $MK_LBUTTON
$ButtonDown = $WM_LBUTTONDOWN
$ButtonUp = $WM_LBUTTONUP
Case $Button = "right"
$Button = $MK_RBUTTON
$ButtonDown = $WM_RBUTTONDOWN
$ButtonUp = $WM_RBUTTONUP
EndSelect

If $X = "" OR $Y = "" Then
$MouseCoord = MouseGetPos()
$X = $MouseCoord[0]
$Y = $MouseCoord[1]
EndIf

For $i = 1 to $Clicks
DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $WM_MOUSEMOVE, "int", 0, "long", _MakeLong($X, $Y))

DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $ButtonDown, "int", $Button, "long", _MakeLong($X, $Y))

DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $ButtonUp, "int", $Button, "long", _MakeLong($X, $Y))
Next
EndFunc

Func _MakeLong($LoWord,$HiWord)
Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

I searched for this script in the forums too.

And came up with quite a few topics about these.

The thing is none of them worked for me. I tried all the scripts I could find for this function, but couldnt get a single one working.. Actually from what I read the new autoit cannot work with these scripts or something, because in 2004,05 when the script was made, people had it working, then as time went on, it stopped working for people, so I am guessing it just isn't compatible with the new autoit. I even tried to make it work on windows paint, thiking that a single click with turn the whole window from white to black, so will be easy to tell, but it just doesent work.

Share this post


Link to post
Share on other sites
Storm

Anyone?

Share this post


Link to post
Share on other sites
Arm

Looking forward the solution!


------------------------------------------------------"You are never a loser,until you quit trying"------------------------------------------------------

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  

×