A small help required

Posts 1–2 of 2 · Page 1 of 1
A small help required
I've been playing around with autoit, trying to send a window left mouse clicks.
So far I've gotten up to this code:
Code:
Opt ("WinTitleMatchMode",'2') ; Helps With Getting The Window Information...
$Title = "Saga" ; The Name Of The Game...
$Full = WinGetTitle ($Title) ; Get The Full Title..
$HWnD = WinGetHandle ($Full) ; Get The Handle
$iButton = 'left' ; Button The Mouse Will Click I.E. "Left Or Right"
$iClicks = '1000' ; The Number Of Times To Click 
$iX = '200' ; The "X" Pos For The Mouse To Click
$iY = '400' ; The "Y" Pos For The Mouse To Click


msgbox(0,"hwnd",$hwnd);This line I had to enter..


If IsHWnD ($HWnD) And WinExists ($Full) <> '0' Then ; Win Check
ControlClick ($HWnD, '','', $iButton, $iClicks, $iX, $iY) ; Clicking The Window While Its Minmized
EndIf
source: autoit help

I ran the script, and it seemed like it did nothing... so I entered a msgbox to see if the handle is actually right, and it is.
After I clicked "ok" in the msgbox, there only one single click (better than nothing, right?)

So, I've a couple of questions about this script..

1. How can I make the script work without having to open a msgbox and click ok before it starts
2. How can I add a delay between the clicks in ControlClick, so it won't use all $iClicks right away and close? (also, need the delay for ingame purpose)

Thanks in advance for all your comments!
Hi I'm new here, I didn't think I could help with my limited knowledge, but this one caught my eye and I read up on some stuff and played with it for a bit and got it to work in calc.exe on my computer. The following code will check if the calculator is open and press the '9' button 5 times, each 2 seconds apart
Code:
Opt ("WinTitleMatchMode",'2') ; Helps With Getting The Window Information...
$Title = "Calculator" ; The Name Of The Game or program
$Full = WinGetTitle ($Title) ; Get The Full Title..
$HWnD = WinGetHandle ($Full) ; Get The Handle
$ThingToClick = 'Button14' ; the controlID or ClassNameNN of the Thing to be clicked (not the window)
$iButton = 'main' ; Button The Mouse Will Click I.E. "Main Or Menu" (these are better than left/right)
$iClicks = '5' ; The Number Of Times To Click The Thing
$iX = '15' ; The "X" Pos On The Thing For The Mouse To Click
$iY = '15' ; The "Y" Pos On The Thing For The Mouse To Click 

If IsHWnD ($HWnD) And WinExists ($Full) <> 0 Then ; Win Check 
    $i=0 
    Do
	  ControlClick ($HWnD, '',$ThingToClick, $iButton, 1, $iX, $iY) ; Single Click The Thing While Window Is Minimised
	  Sleep(2000) ;after clicking wait 2 seconds
	  $i = $i + 1
   Until $i = $iClicks
EndIf
I think the problem is trying to send the clicks to the window and not to the ControlID of the button, I found the $ThingToClick name by using the AutoIt Window Info tool.
I removed the '' from around the 0 on the Win Check line and added a 'Do Until' loop


I hope this helps, it will help me with my future bots )
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?