AutoHotkey Community

It is currently May 27th, 2012, 1:36 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Loop
PostPosted: November 22nd, 2009, 1:22 am 
First off I appologize. I really do not understand the script or how to put it together.

Is there a way to loop a button press like, 1, where it pushes once every 30secs and then have it stop and push, 2 and wait a minute before resuming 1?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 1:24 am 
Well to be a little bit more specific...

1 every 30 secs
After two or three minutes 2 and then wait a minute before resuming 1.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 3:17 am 
Offline

Joined: February 17th, 2008, 7:09 am
Posts: 536
yes. Although i'd use Sleep and send.

Code:
loop, {
Send ;whatever you plan on sending.
Sleep 1000 ;every 1000 is a second

}



This is the minimal structure you're looking for. Read up the documentation more, and if you have trouble, post your attempts.

http://www.autohotkey.com/docs/commands/Loop.htm

http://www.autohotkey.com/docs/commands/Sleep.htm

http://www.autohotkey.com/docs/commands/Send.htm


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 2:07 pm 
I do not really understand the documentation. I understand how to change the number for sleep and to change it to a different time but do not understand how to put stuff together.

Right now I am using a old script that I found for World of Warcraft where it simulates a button press, it is not a loop or anything but it pretty much makes it where is have to use a folded piece of paper to hold down the 1 key.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 2:12 pm 
Where is the documentation that helps you be able to read the documentation you posted? With no knowledge of script the terms are unfamiliar to me and it is almost like trying to assemble something using spanish instructions.

Potentially if there is a way I can learn how to read it then I will be able to put scripts together.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 2:42 pm 
Offline

Joined: July 18th, 2006, 12:18 pm
Posts: 403
Maiyr wrote:
Where is the documentation that helps you be able to read the documentation you posted? With no knowledge of script the terms are unfamiliar to me and it is almost like trying to assemble something using spanish instructions.

Potentially if there is a way I can learn how to read it then I will be able to put scripts together.


Haha!! So a syntax documentation isnt enough? You want another doc to read this one? Seriously you are kidding right?

Really wouldnt say stuff like that around here, We cant help people who cannot help themselves.

Open the documentation and read everything in there. EVERYTHING. Look at the code examples ect. Its very easy stufff.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 4:51 pm 
Offline

Joined: May 12th, 2009, 2:37 pm
Posts: 640
Location: Gloucester UK
It can seem like a foreign language to begin with and I found the learning curve to be quite steep when I started but it is worth the effort.

The best way to start is as i3egohan said: Try out the examples at the bottom of each doc page by putting just that code in a script and running it so that you can see what effect it has. The re-read the doc page and see if you can combine what it says with what you see when you run the code.

If you do get stuck with anything the forum is here but we need more specific questions to answer.

Have Fun :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 5:08 pm 
How would you make it where,

Code:
loop, {
Send ; 1
Sleep 30000 ;

}


Stops doing 1 every 30 secs after lets say 3 minutes and does 2 once and waits a minute before resuming 1?

I think it would be like...

Start - 1 (Wait 30 sec)
30 sec - 1 (Wait 30 sec)
1 min - 1 (Wait 30 sec)
1.5 min - 1 (Wait 30 sec)
2 min - 1 (Wait 30 sec)
2.5 min - 1 (Wait 30 sec)
3 min - 2 (Wait 1 minute)
[/code]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 5:27 pm 
Offline

Joined: May 12th, 2009, 2:37 pm
Posts: 640
Location: Gloucester UK
At it's simplest you can just put sends and sleeps into the loop like so:

Code:
Loop
{
     Send, 1
     Sleep, 30000
     Send, 1
     Sleep, 30000
     Send, 1
     Sleep, 30000
     Send, 1
     Sleep, 30000
     Send, 1
     Sleep, 30000
     Send, 1
     Sleep, 30000
     Send, 2
     Sleep, 60000
}


This will do what you are asking but feels clunky and un-elegant. There are other ways which will do what you want but use a lot less code.
Have a play around with this first and see if you get the result you're after. If you feel up to something a bit more complicated just report back here.
If you do I would recommend reading the documentation for Loop as there are a couple of things in there which the docs explain a lot better than I can


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 5:33 pm 
That made it a lot less complicated then what I thought it was going to be. I will play around with this and I shall be back. Was seeing that there is a way to activate the loop and turn it off as well. Will see if I can figure out to get that to work.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2009, 12:24 am 
Ok going to attempt to add a start up, F1, and a end F2, to the Loop


Code:
F1::
Loop
{
Send, 1
Sleep, 30000
Send, 1
Sleep, 30000
Send, 1
Sleep, 30000
Send, 1
Sleep, 30000
Send, 1
Sleep, 30000
Send, 1
Sleep, 30000
Send, 2
Sleep, 60000
F2::break
}



Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2009, 12:55 am 
Offline

Joined: May 12th, 2009, 2:37 pm
Posts: 640
Location: Gloucester UK
You might ant to take a look at this as it addresses what you are trying to do

http://www.autohotkey.com/docs/FAQ.htm#repeat


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2009, 2:12 am 
I saw pause and was thinking that when resumed it would start back where it paused at.

How I have it going now. Would F1 Start the Loop and F2 Stop the Loop and if I were to push F1 would it start anew?

Or does pause(resume) start the script from the beginning after it resumes?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2009, 3:43 am 
Offline

Joined: December 21st, 2008, 7:29 pm
Posts: 181
Could you post the code you are using?

Autohotkey executes by moving through the file with code from the top down, jumping to functions or labels when they are called and then returning to where they are called from. The Pause command just pauses execution wherever it is at, when the script is un-paused it resumes executing from where it stopped.

The easiest way to exit the loop at any time would be something like this:

Code:

F2::Reload

F1::
    Loop
    {
        Send, 1
        Sleep, 30000
        Send, 1
        Sleep, 30000
        Send, 1
        Sleep, 30000
        Send, 1
        Sleep, 30000
        Send, 1
        Sleep, 30000
        Send, 1
        Sleep, 30000
        Send, 2
        Sleep, 60000
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2009, 3:48 pm 
I have been looking through the FAQs and such as well as see what some of the people do with the possibilities and it amazes me.

Just a question. I really do wish to learn more and I think it may be helpful if I had something more tangible instead of digital. Would a book on scripting be appropriate or what should I look for at the book store?


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Bing [Bot], bobbysoon, iDrug, Tipsy3000, Yahoo [Bot] and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group