Sign in to follow this  
Followers 0
DatOneGuy

SetTimer in AHK->AutoIT?

6 posts in this topic

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

Share this post


Link to post
Share on other sites



DatOneGuy,

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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.

Share this post


Link to post
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.8.8 [30/09/2015]

Download Here

s!mpL3

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

@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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

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  
Followers 0