Sign in to follow this  
Followers 0
Andrew Chen

Ending Functions using a hotkey?

4 posts in this topic

#1 ·  Posted (edited)

I'm currently making this macro that has multiple functions that will repeat two diffrent letters.

I need a way to end the fuction by pressing a key, ( or pressing another hotkey).

; Cheatx's TugOBot v1.1

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)

$answer = MsgBox(4, "Cheatx's TugOBot v1.1", "This script will run Cheatx's TugOBot v1.1.")

HotKeySet("x", "xc")

HotKeySet("c", "cv")

HotKeySet("v", "vb")

HotKeySet("b", "bn")

HotKeySet("n", "nm")

;;;;;;;;;; Functions ;;;;;;;;;

;Function xc

Func xc()

while 1

Send("xc")

Wend

EndFunc

;Function cv

Func cv()

while 1

Send("cv")

Wend

EndFunc

;Function vb

Func vb()

while 1

Send("vb")

Wend

EndFunc

;Function bn

Func bn()

while 1

Send("bn")

Wend

EndFunc

;Function nm

Func nm()

while 1

Send("nm")

Wend

EndFunc

;;;;;; Terminating Program ;;;;;;

Func Terminate()

Exit 0

EndFunc

Edited by Andrew Chen

Share this post


Link to post
Share on other sites



I'm currently making this macro that has multiple functions that will repeat two diffrent letters.

I need a way to end the fuction by pressing a key, ( or pressing another hotkey).

; Cheatx's TugOBot v1.1

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)

$answer = MsgBox(4, "Cheatx's TugOBot v1.1", "This script will run Cheatx's TugOBot v1.1.")

HotKeySet("x", "xc")

HotKeySet("c", "cv")

HotKeySet("v", "vb")

HotKeySet("b", "bn")

HotKeySet("n", "nm")

;;;;;;;;;; Functions ;;;;;;;;;

Function xc

Func xc()

while 1

Send("xc")

Wend

EndFunc

Function cv

Func cv()

while 1

Send("cv")

Wend

EndFunc

Function vb

Func vb()

while 1

Send("vb")

Wend

EndFunc

Function bn

Func bn()

while 1

Send("bn")

Wend

EndFunc

Function nm

Func nm()

while 1

Send("nm")

Wend

EndFunc

;;;;;; Terminating Program ;;;;;;

Func Terminate()

Exit 0

EndFunc

Andrew Chen,

Welcome to the AutoIt forum.

Try this if you're using beta:

#Include <Misc.au3>
HotKeySet("x", "xc")
HotKeySet("c", "cv")
HotKeySet("v", "vb")
HotKeySet("b", "bn")
HotKeySet("n", "nm")
HotKeySet("t", "Terminate")

While 1
    Sleep(10)
WEnd
Exit

; Function xc
Func xc()
    While 1
    Send("{ASC 120}")
    Send("{ASC 99}")
    If _IsPressed("53") Then ExitLoop; Press 's' to stop
    Wend
EndFunc

; Function cv
Func cv()
    While 1
    Send("{ASC 99}")
    Send("{ASC 118}")
    If _IsPressed("53") Then ExitLoop; Press 's' to stop
    Wend
EndFunc

; Function vb
Func vb()
    While 1
    Send("{ASC 118}")
    Send("{ASC 98}")
    If _IsPressed("53") Then ExitLoop; Press 's' to stop
    Wend
EndFunc

; Function bn
Func bn()
    While 1
    Send("{ASC 98}")
    Send("{ASC 110}")
    If _IsPressed("53") Then ExitLoop; Press 's' to stop
    Wend
EndFunc

; Function nm
Func nm()
    While 1
    Send("{ASC 110}")
    Send("{ASC 109}")
    If _IsPressed("53") Then ExitLoop; Press 's' to stop
    Wend
EndFunc

; Terminating Program
Func Terminate()
    Exit 0
EndFunc

Or this if you're NOT using beta:

HotKeySet("x", "xc")
HotKeySet("c", "cv")
HotKeySet("v", "vb")
HotKeySet("b", "bn")
HotKeySet("n", "nm")
HotKeySet("t", "Terminate")

While 1
    Sleep(10)
WEnd
Exit

; Function xc
Func xc()
    While 1
    Send("{ASC 120}")
    Send("{ASC 99}")
    Wend
EndFunc

; Function cv
Func cv()
    While 1
    Send("{ASC 99}")
    Send("{ASC 118}")
    Wend
EndFunc

; Function vb
Func vb()
    While 1
    Send("{ASC 118}")
    Send("{ASC 98}")
    Wend
EndFunc

; Function bn
Func bn()
    While 1
    Send("{ASC 98}")
    Send("{ASC 110}")
    Wend
EndFunc

; Function nm
Func nm()
    While 1
    Send("{ASC 110}")
    Send("{ASC 109}")
    Wend
EndFunc

; Terminating Program
Func Terminate()
    Exit 0
EndFunc

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites

Thanks taurus905, I tested the script, and it works perfectly on notepad.

But do you have any idea why it doesn't work when im using it on a flash game?

It's like the game doesnt register the keys.

Share this post


Link to post
Share on other sites

Thanks taurus905, I tested the script, and it works perfectly on notepad.

But do you have any idea why it doesn't work when im using it on a flash game?

It's like the game doesnt register the keys.

Andrew Chen,

I don't know why your script does not work with a flash game. But I am sure someone here could. And maybe they can even help you get it to work.

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

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