Jump to content

SetTimer in AHK->AutoIT?


Recommended Posts

I'm trying to convert the following from AutoHotKey to AutoIt and can't figure out any equal to settimer, searching led me to AdLibEnable(), but I'm not sure it'll work as I want it to.

Basically I just want to be able to click the hotkey whenever I wish and turn the script on or off from continuously repeating.

IsStart := 1
SetTimer, Click, 4000
SetTimer, Click, Off
Hotkey, !^z, ControlTimer
Return

ControlTimer:
If IsStart = 1
  {
    SetTimer, Click, On
    IsStart := 0
  }
Else
  {
    SetTimer, Click, Off
    IsStart := 1
  }
Return

Click:
Click 548,895
Return
Link to comment
Share on other sites

  • Moderators

DatOneGuy,

May I suggest reading the Interrupting a running function tutorial in the Wiki? It suggests several ways to do what you want. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I'll just have to do it manually I guess, I don't understand that article too much, how do I do it without having to use aGUI? I just want to press a hotkey, not use a UI.

Thanks though, this'll work as is for me without having to add that anyway I suppose.

Link to comment
Share on other sites

I'll just have to do it manually I guess, I don't understand that article too much, how do I do it without having to use aGUI? I just want to press a hotkey, not use a UI.

Thanks though, this'll work as is for me without having to add that anyway I suppose.

so you use HotkeySet("key", "function")

the hotkey will call the function when it's pressed and interrupt anything else running

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

@DatOneGuy

Hi and Welcome to the forum!

I doesn't sound like you want a timer, it sounds like you want the example for HotKeySet(), see helpfile :)

Edited by AdmiralAlkex
Link to comment
Share on other sites

Yes, you should use AdlibEnable AdlibRegister as the AutoIt equivalent to SetTimer.

$IsStart = 1 ;IsStart := 1
;SetTimer, Click, 4000
;SetTimer, Click, Off
HotKeySet("!^z", "ControlTimer") ;Hotkey, !^z, ControlTimer
Exit ;Return

Func ControlTimer();ControlTimer:
    If $IsStart = 1 Then;If IsStart = 1
      ;{
        AdlibRegister("Click", 4000) ;SetTimer, Click, On
        $IsStart = 0; IsStart := 0
      ;}
    Else
      ;{
        AdlibUnRegister("Click") ;SetTimer, Click, Off
        $IsStart = 0;IsStart := 1
      ;}
    EndIf
EndFunc

Func Click();Click:
    MouseClick(548, 895); Click 548,895
EndFunc ;Return
Edited by Manadar
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...