Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Looping macro script?


  • Please log in to reply
2 replies to this topic
bassa
  • Members
  • 9 posts
  • Last active: Sep 11 2009 12:16 PM
  • Joined: 20 Oct 2008
Hello!

I am using a Razer Tarantula keyboard that's got 10 custom Macro Keys, and what I would like to do is to create a specific usage for one of these Macro Keys.

The left row of Macro Keys are called L1-L5.

Let's take the L1 Macro key in this example.

When I press the L1 Macro key (this can be set up in the keyboard driver software that comes with the keyboard, so no problems there), I've made the Macro as to simulate pressing CTRL+1, CTRL+2 and CTRL+3 with just 50 milliseconds delay in between.

What I need my script to achieve is this:

Pressing L1 = CTRL+1, CTRL+2, CTRL+3, 6 seconds delay... REPEAT.

Basically, a Macro key that repeats itself infinitely. And when pressed again, the repeating stops/breaks.

I have searched elsewhere, and came up with a small script written by Tonne. It seems to accomplish what I need to do, but I would like to make sure by asking one of you guys first.

Here's the script code:

#MaxThreadsPerHotkey 2 
$+e:: 
PressKey := ! PressKey   ;Toggle PressKey True/False 
Loop 
{    
  If ! PressKey 
    Break         ;If PressKey is False, stop pressing key 
  Send +e 
  Sleep 500      ;Delay between keypresses 
} 
Return 
#MaxThreadsPerHotkey 1

It looks like this script will accomplish what I need.

I will need to change the delay time and the key pressed. 'E' key is substituted with my 'L1' macro key, and delay time is set to 600 milliseconds (6 seconds?).

Correct?


Cheers,
Bassa[/code]

bassa
  • Members
  • 9 posts
  • Last active: Sep 11 2009 12:16 PM
  • Joined: 20 Oct 2008
I'm using this instead:

Numpad1:: ;Numpad 1 Starts Macro1 
SetTimer Macro1, 5000 
return 

Numpad2:: ;Numpad 2 Starts Macro2 
SetTimer Macro2, 5000 
return 

Numpad0:: ;Numpad 0 Stops Macro 
SetTimer Macro1, Off 
SetTimer Macro2, Off 
return 

Macro1: ;Macro1 
Send, 1 
Sleep, 5000 
Send, 2 
Sleep, 5000
Send, 3 
Sleep, 5000
return 

Macro2: ;Macro2 
Send, 3 
Sleep, 3000 
Send, 4 
Sleep, 3000

But somehow it doesn't work how I want it to in Warhammer.

Seraphem
  • Members
  • 1 posts
  • Last active: Apr 25 2009 01:10 AM
  • Joined: 15 May 2008
Try SendInput instead of Send in your macro....at least that works for me.
Also too, I could not get my keyboard to work correctly with the numpad, possibly due to the keyboard itself. It's a Logitech 5000 bluetooth desktop and it doesn't have a numlock key. Clear Calc/Backspace replaces it.

#IfWinActive, ahk_class WARWIN

Home:: ;Home Starts Macro 
SetTimer Macro 
return 

End:: ;End Stops Macro 
SetTimer Macro, Off 
return 

Macro: ;Macro 
SendInput, ^0
Sleep, 5400 
SendInput, ^-
Sleep, 5400 
SendInput, ^=
Sleep, 5400