Jump to content

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

Loop with button to start/stop (break)


  • Please log in to reply
6 replies to this topic
se7enek
  • Members
  • 21 posts
  • Last active: Sep 16 2015 05:19 AM
  • Joined: 12 Jan 2014

Hi there

I would like to know if im allowed to do such thing like:

 

1. I press F6, 

2. My loop starts and is going through index 1 to 15, and then from start, forever and ever

3. OR if i press again F6, my loop will break.

 

Is it possible?

Now my loop looks like:

(for now its just goin once from 1 to 11)

F6::
IfWinActive MyGamexD ahk_class Direct3DWindowClass
{
WinActivate
SendMode Input
loop
{
 
 SendInput {enter}
 
 SendInput {BS}
 
 SendInput {BS}
 
 SendInput {/}
 
 SendInput {t}
 
 SendInput {Space}
 
 SendInput %A_Index%
 
 SendInput {enter}
 
 SendInput {enter} 
 
 SendInput {Up}
 
 SendInput {Up}
 
 SendInput {enter}
 
If A_Index = 11
Break
else
RandSleep(3000,3100)
}
}
return


se7enek
  • Members
  • 21 posts
  • Last active: Sep 16 2015 05:19 AM
  • Joined: 12 Jan 2014

ok, managed to do something like: Loop forever, until key is pressed again.

 

F6::
toggle := !toggle
 
SendMode Input
loop
{
if toggle
{
 MY LOOP INSIDE
 
If A_Index = 11
??? A_index := 1 ???
}
else
break
}
return


se7enek
  • Members
  • 21 posts
  • Last active: Sep 16 2015 05:19 AM
  • Joined: 12 Jan 2014

/\

\/



se7enek
  • Members
  • 21 posts
  • Last active: Sep 16 2015 05:19 AM
  • Joined: 12 Jan 2014

(SORRY FOR EVEN TRIPLE POST but couldnt send all message in 1 post and something bugged)

 
but still i need another thing.
 
I want to go it like /t 1, /t 2, /t 3, ... /t 10, /t 11, /t 1, /t 2... and so on
so after getting to A_Index = 11, i want to restart counter
 
should i use loop in loop then ?
or another better method ?


se7enek
  • Members
  • 21 posts
  • Last active: Sep 16 2015 05:19 AM
  • Joined: 12 Jan 2014

FOR now , i got something like this, but looking for better solution:

 

F6::
toggle := !toggle
SendMode Input
loop
{
if toggle
{
loop
{
if toggle
{
 
 <<<MY LOOP THERE>>>
 
If A_Index = 10
break
}
else
break
}
}
else
break
}
return


Ruevil2
  • Members
  • 226 posts
  • Last active: Dec 04 2015 11:05 PM
  • Joined: 27 Mar 2012

Give this a try. Notice how the first loop runs indefinitely and breaks on toggle. The second loop runs 11 iterations, 1 for each index, then is restarted by the outside loop. Also once you declare a SendMode it affects all uses of Send so the use of SendInput specifically is redundant.

 

This is untested. Let me know what happens!

 

SendMode Input
 
F6::
    toggle := !toggle
    Loop
    {
        Loop, 11
        {
            If toggle
            {
                Send {enter}
                Send {BS}
                Send {BS}
                Send {/}
                Send {t}
                Send {Space}
                Send %A_Index%
                Send {enter}
                Send {enter} 
                Send {Up}
                Send {Up}
                Send {enter}
            }
        }
        else
        {
            break
        }
    }
return

If I helped you out and you would like to show appreciation, feel free to buy me a beer.  grin.png   btn_donateCC_LG.gif


RaptorX
  • Members
  • 751 posts
  • Last active: Feb 19 2015 02:47 AM
  • Joined: 19 Feb 2010


AutoHotkey Toolkit [Main Project]
Scintilla Wrapper
LexAHKL