Sign in to follow this  
Followers 0

Hotkey Start and Stop?

8 posts in this topic

Posted

I have a question. How would you make a macro script in which when you hit a hotkey, such as F4, and it begins spamming text like "HI" over and over in a continuous loop until you hit another hotkey such as F6? I know it's a newbie question... but I tried searching already and came up with nothing. Thank you for even bothering to read this topic because I can't imagine the frustration you have pros have to deal with against newbies like me everyday.

Share this post


Link to post
Share on other sites



Posted (edited)

HotKeySet('{F3}', 'Spam')
HotKeySet('{F4}', 'Stop')
HotKey('{ESC}, 'Exit')

Func Spam()
Do
Send('SPAM' & '{ENTER}')
Until ?
EndFunc

Func Stop()
ExitLoop
EndFunc

Func Exit()
Exit
EndFunc

So far this is my horrible noob script. -.-

Edited by RadioBoy

Share this post


Link to post
Share on other sites

Posted

Do a search for pause :whistle:

Share this post


Link to post
Share on other sites

Posted (edited)

I assume you were trying to lead me to your post in this topic. Well, I read up on it, so I decided to try rewriting the script based off of the script you posted and off of my own assumtions.

Would this work?

$spam = HotKeySet('{F3}', 'Spam')
$exit = HotKeySet('{ESC}', 'Close')

Func Spam()
While 1
$msg = GUIGetMsg()
Select  
Case $msg = $spam
		Do
			Send('SPAM' & '{ENTER}')
			$msg = GUIGetMsg()
		Until $msg = $stop
		MsgBox(0,0,0)
	Case $msg = $GUI_EVENT_CLOSE
		ExitLoop
EndSelect
WEnd
EndFunc

Func Close()
Exit
EndFunc
Edited by RadioBoy

Share this post


Link to post
Share on other sites

Posted

Global $paused
HotKeySet( "{PAUSE}", "TogglePause")

; Put any scripting here
; when you hit the pause key it will stop everthing your script is doing till you hit pause again

Func TogglePause()
	$paused = Not $paused
	While $paused
		Sleep(100)
		ToolTip('PROGRAM IS PAUSED', 500, 100);Not nessesary but i like the tool tip
	WEnd
EndFunc

Share this post


Link to post
Share on other sites

Posted

Global $paused
HotKeySet( "{PAUSE}", "TogglePause")

; Put any scripting here
; when you hit the pause key it will stop everthing your script is doing till you hit pause again

Func TogglePause()
	$paused = Not $paused
	While $paused
		Sleep(100)
		ToolTip('PROGRAM IS PAUSED', 500, 100);Not nessesary but i like the tool tip
	WEnd
EndFunc
How does it understand what $paused is?

Share this post


Link to post
Share on other sites

Posted

How does it understand what $paused is?

It doesn't. $paused is used as a boolean variable in this script, meaning it can have true or false for a value. The statement $pause = not $pause means that the state is inverted (toggled). If it was true before, it is false after, and v.v.. Then the script does something if $pause is true (it pauses, obviously :whistle:).

Share this post


Link to post
Share on other sites

Posted

A more correct / readable way would be like this

Global $paused = FALSE
HotKeySet( "{PAUSE}", "TogglePause")

; Put any scripting here
; when you hit the pause key it will stop everthing your script is doing till you hit pause again

Func TogglePause()
    $paused = Not $paused
    While $paused
        Sleep(100)
        ToolTip('PROGRAM IS PAUSED', 500, 100);Not nessesary but i like the tool tip
    WEnd
EndFunc

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




  • Recently Browsing   0 members

    No registered users viewing this page.