Results 1 to 2 of 2
  1. #1
    dkofek's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    The toilet in the club next to your house
    Posts
    59
    Reputation
    13
    Thanks
    114
    My Mood
    Bored

    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!

  2. #2
    Skullz420's Avatar
    Join Date
    Mar 2014
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    0
    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 )

Similar Threads

  1. [Help Request] Help required modding Arma 2 Wasteland?
    By Jordan ZG in forum DayZ Help & Requests
    Replies: 3
    Last Post: 04-03-2013, 11:19 AM
  2. [Help Request] Please I Need a Small Help !!!
    By ~dody~ in forum CrossFire Help
    Replies: 24
    Last Post: 02-02-2013, 08:54 AM
  3. Need some small help
    By 0oShameo0 in forum Combat Arms Mod Discussion
    Replies: 0
    Last Post: 12-09-2010, 09:15 PM
  4. SMALL HELP !
    By hack.lolbb,com9 in forum CrossFire Help
    Replies: 10
    Last Post: 11-14-2010, 06:11 PM
  5. Help required
    By str1k3r21 in forum WarRock - International Hacks
    Replies: 4
    Last Post: 10-21-2007, 09:00 AM