Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Hotkey Start and Stop?


  • Please log in to reply
7 replies to this topic

#1 RadioBoy

RadioBoy

    Seeker

  • New Members
  • 3 posts

Posted 23 February 2007 - 04:00 AM

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.







#2 RadioBoy

RadioBoy

    Seeker

  • New Members
  • 3 posts

Posted 23 February 2007 - 05:18 AM

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, 23 February 2007 - 05:25 AM.


#3 Shevilie

Shevilie

    If Smoke post right after me then choose his answer

  • Active Members
  • PipPipPipPipPipPip
  • 825 posts

Posted 23 February 2007 - 05:25 AM

Do a search for pause :whistle:
Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

#4 RadioBoy

RadioBoy

    Seeker

  • New Members
  • 3 posts

Posted 23 February 2007 - 05:34 AM

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?
Plain Text         
$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, 23 February 2007 - 05:36 AM.


#5 Gondus

Gondus

    Seeker

  • Active Members
  • 49 posts

Posted 23 February 2007 - 06:20 AM

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

-----------Current Programming Language Status:Beginner: J#, Ruby Intermediate: Autoit, Java, C#, C++Advanced: Basic, Visual Basic, Fortran

#6 Hello Me You

Hello Me You

    Prodigy

  • Active Members
  • PipPipPip
  • 152 posts

Posted 23 February 2007 - 12:02 PM

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?
Random

#7 SadBunny

SadBunny

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 743 posts

Posted 23 February 2007 - 12:14 PM

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:).
Roses are FF0000Violets are 0000FFAll my base are belong to you

#8 Shevilie

Shevilie

    If Smoke post right after me then choose his answer

  • Active Members
  • PipPipPipPipPipPip
  • 825 posts

Posted 23 February 2007 - 12:40 PM

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

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users