Jump to content

How to delay between two controlclicks


Recommended Posts

Basically my script is the following:

 

#include <AutoItConstants.au3>
#include <Misc.au3>

HotKeySet("{F1}", "Start")
HotKeySet("{ESC}", "Pause")

Global $Paused

Func Pause()
     $Paused = NOT $Paused
     While $Paused
        sleep(0)
    WEnd
EndFunc

Func Start()
   While 1
          $point = MouseGetPos()
          Opt("WinTitleMatchMode", 4)
          ControlClick("Hotel - Habbo - Google Chrome", "Chrome Legacy Window", "", "left", 2, $point[0], $point[1])

 

< I want a delay here let's say a minute then control click again >

ControlClick("Hotel - Habbo - Google Chrome", "Chrome Legacy Window", "", "left", 2, $point[0], $point[1])
    WEnd
   EndFunc

While 1
   Sleep(0)
WEnd

 

 

as you can see I just want to know how to delay between two controlclicks. I tried putting sleep but it doesn't delay it at all. Perhaps for controlclick  it's a different line? 

 

Please help me.

Link to comment
Share on other sites

5 minutes ago, Looney11 said:

Hotel - Habbo - Google Chrome

 

It looks like you are trying to automate a game. If that is the case then please read the rules.

Please correct me if I'm wrong and your script has nothing to do with game automation.

Link to comment
Share on other sites

@Looney11, Let's say you want to perform ControlClick() after 1 minute, right? or did I missed to understand your problem  (just let me know).:D

Try:

Local $Shell = ObjCreate("shell.application")
Global $delays
$TimeInput = "1" ; minimum value is 1.

$delays = $TimeInput * 60 ; set amount of time 60(one minute), 30(30 seconds)
$delays = $delays * 1000 ; set seconds cound 1000(one minute), 500(half minute)

sleep($delays)
Send("{ENTER}"); you can add ControlClick() here and do something.

Or

Local $Shell = ObjCreate("shell.application")
Global $tots
$TimeInput = "1"

$delays = $TimeInput * 60 ; set amount of time 60(one minute), 30(30 seconds)
$delays = $delays * 1000 ; set seconds cound 1000(one minute), 500(half minute)

sleep($delays)
ControlClick("Hotel - Habbo - Google Chrome", "Chrome Legacy Window", "", "left", 2, $point[0], $point[1])
  WEnd
EndFunc

This function add time interval of which you desired amount of time before running the code. Hope this is what you want.

 

KS15

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

13 minutes ago, KickStarter15 said:

@Looney11, Let's say you want to perform ControlClick() after 1 minute, right? or did I missed to understand your problem  (just let me know).:D

Try:

Local $Shell = ObjCreate("shell.application")
Global $delays
$TimeInput = "1" ; minimum value is 1.

$delays = $TimeInput * 60 ; set amount of time 60(one minute), 30(30 seconds)
$delays = $delays * 1000 ; set seconds cound 1000(one minute), 500(half minute)

sleep($delays)
Send("{ENTER}"); you can add ControlClick() here and do something.

Or

Local $Shell = ObjCreate("shell.application")
Global $tots
$TimeInput = "1"

$delays = $TimeInput * 60 ; set amount of time 60(one minute), 30(30 seconds)
$delays = $delays * 1000 ; set seconds cound 1000(one minute), 500(half minute)

sleep($delays)
ControlClick("Hotel - Habbo - Google Chrome", "Chrome Legacy Window", "", "left", 2, $point[0], $point[1])
  WEnd
EndFunc

This function add time interval of which you desired amount of time before running the code. Hope this is what you want.

 

KS15

Yes! I wanted there to be a control click then delay then another control click. How would that be like because the way you made it is the delay before te control click.

 

i wanted controlclick then delay 1 minute ten another controlclick

 

Link to comment
Share on other sites

On 5/29/2017 at 1:10 PM, Looney11 said:

< I want a delay here let's say a minute then control click again >

In your post above, you wanted the delay between the two ControlClick() for 1 minute idle time. So, just insert this code between them as see.

Here's the simplest way of using this code.

Local $Shell = ObjCreate("shell.application")
Global $delays
$TimeInput = "1" ; value 1
$delays = $TimeInput * 10 ; 10 seconds delay
$delays = $delays * 200 ; miliseconds count/second

Example()

Func Example()
    Run("notepad.exe"); running notepad
    Local $hWnd = WinWait("[CLASS:Notepad]", "", $delays) ; wait until the delayed time reached.

    ControlClick($hWnd, "", "Edit1") ; first ControlClick()

     sleep($delays) ; delaying second ControlClick()
     WinClose($hWnd);close notepad
  
    Run("notepad.exe")
    ControlClick($hWnd, "", "Edit1")
   
     sleep($delays)
EndFunc   ;==>Example

Where ever you wanted the delayed time, just add "sleep($delays)" in every ControlClick() you wanted.

Edited by KickStarter15

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...