AutoHotkey Community

It is currently May 26th, 2012, 10:14 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: October 23rd, 2009, 12:21 am 
Offline

Joined: October 22nd, 2009, 11:54 pm
Posts: 4
Hey am really new, gotta start somewhere right :D

i want to press 1,2,3,4 consectivly in a loop
then after 90000 miliseconds
i would like it to pause resuming after 73500 miliseconds


Here is my current script *see below*
which constantly mashes 1234 over and over
Any advice would be great
Thankyou
Quote:
Loop 999999999999
{
Send {1 down}
Sleep 500
Send {1 up}
Sleep 500
Send {2 down}
Sleep 500
Send {2 up}
Sleep 500
Send {3 down}
Sleep 500
Send {3 up}
Sleep 500
Send {4 down}
Sleep 500
Send {4 up}
}

_________________
;
;;
;';.
; ;;
; ;;
; ;;
; ;;
; ;'
; '
,;;;,;
;;;;;;
`;;;;'


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 1:30 am 
Offline

Joined: October 22nd, 2009, 11:54 pm
Posts: 4
BUMP :cry:

_________________
;
;;
;';.
; ;;
; ;;
; ;;
; ;;
; ;'
; '
,;;;,;
;;;;;;
`;;;;'


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 1:37 am 
Offline

Joined: May 12th, 2009, 2:37 pm
Posts: 640
Location: Gloucester UK
Take a look at SetTimer.
This command allows you to set a timer (surprisingly) so that your code can be executed at a specified time period


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 1:39 am 
Offline

Joined: May 22nd, 2007, 1:06 am
Posts: 73
Try not to double post

Code:
Loop, 900 ;(900 x 100ms = 90000ms)
{
Send, 1234
Sleep, 100
}
Sleep, 73500


Edit:
This is probably a better way to do it, I forgot that you wanted it to resume

Code:
Counter =
While Counter < 901
{
Send, 1234
Sleep, 100
Counter ++

If Counter > 901
{
Sleep, 73500
Counter = 0
}
}


Last edited by tekkie2412 on October 23rd, 2009, 2:09 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 1:42 am 
Offline

Joined: October 22nd, 2009, 11:54 pm
Posts: 4
thank you so much
your code is much easier >.<

_________________
;
;;
;';.
; ;;
; ;;
; ;;
; ;;
; ;'
; '
,;;;,;
;;;;;;
`;;;;'


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 1:49 am 
Offline

Joined: September 21st, 2009, 1:25 am
Posts: 10
Code:
StartTime:=A_TickCount            ; Get starting time
ElapsedTime:=A_TickCount-StartTime      ; Just to make sure initialized for while loop

While (ElapsedTime<90000)              ; Loop until your timer hit
{
   Send 1234                            ; Removed your inter key press delays
   Sleep 50                            ; Added some delay before we loop
   ElapsedTime:=A_TickCount-StartTime   ; Calc new time difference
}
Sleep 73500                       ; While broken - sleep
Reload                          ; Reload script

Tested in Notepad -

Edit: this gives more precise control over the total time with such a large number of loops but I like his reset of the counter better than my reload thought.

_________________
StoreyQuickNotes - An AutoHotkey Project for Radiation Oncology


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 2:29 am 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6065
Location: San Diego, California
Code:
#SingleInstance, Force ; to force running of a new copy if another is already running
; prevents the msgbox "An older instance of this script is already running.  Replace it with this instance?"

return

F1:: ; start the mashing by pressing F1

run_time= 90000
pause_time = 73500

; this is a 'flag', if set it allows sending of characters
send_char=1

settimer, stop_char, -%run_time%   ; wait 90000 miliseconds, but "run-only-once mode"

loop
{
  if send_char=1
  {
    Send 1234
  }
  Sleep, 150
}

stop_char:
  send_char=0 ; after the timer delay, set the flag to stop characters
  settimer, start_char, -%pause_time%   ; wait 73500 miliseconds , but "run-only-once mode"
return

start_char:
  send_char=1 ; after the timer delay, set the flag to start characters
  settimer, stop_char, -%run_time%   ; wait 90000 miliseconds, but "run-only-once mode"
return



esc::  ; in case of emergency, hit escape key
exitapp


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: hyper_, JSLover, Leef_me, oldbrother, patgenn123, Yahoo [Bot] and 63 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