AutoHotkey Community

It is currently May 27th, 2012, 4:12 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: July 14th, 2011, 5:06 pm 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
I don't understand by any lines after Msgbox on line 5 are not being executed. The script never executes line 6.

Code:
Counter = 0
progress, B2 Y200,,Please Wait
SetTimer,PleaseWait,250
listlines,on
MsgBox Click Ok to turn off progress bar
MsgBox This line is never executed
SetTimer,PleaseWait,Off
Progress,Off
return

PleaseWait:
listlines,off
Loop
 {
  sleep 50
  Counter++
  progress,%Counter%
  if Counter = 110
   Counter = 0
 }
return
escape::
ExitApp
I know it has something to do with SetTimer but I can not figure out what it is.

DataLife

_________________
Check out my scripts.
(MyIpChanger) (XPSnap) (SavePictureAs)

All my scripts are tested on Windows 7, AutoHotkey_L 32 bit Ansi unless otherwise stated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 14th, 2011, 5:14 pm 
Offline

Joined: July 6th, 2011, 5:37 pm
Posts: 214
Location: Looking over my domain
I hate to point out the obvious... such as I am your supreme ruler on planet Houston. So I won't. Could you tell the class what version of AHK, OS, and flugelbinder you are currently using?

"No not god.... ZOD"

Now son of Jor El

Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 14th, 2011, 5:44 pm 
Offline

Joined: October 15th, 2007, 3:10 pm
Posts: 790
Location: England
Why are you setting a timer, then using it to jump into an infinite loop?

All this will do is mean the timer keeps interrupting your infinite loop to jump into another deeper infinite loop... :)

Just use either the timer, or a loop that you can break out of.

Code:
Counter = 0
progress, B2 Y200,,Please Wait
SetTimer,PleaseWait,50
listlines,on
MsgBox Click Ok to turn off progress bar
MsgBox This line is never executed
SetTimer,PleaseWait,Off
Progress,Off
return

PleaseWait:
   listlines,off
   Counter++
   progress,%Counter%
   if Counter = 110
   Counter = 0
return

_________________
My code is written for AHK Basic unless otherwise specified. This means it may not work in AHK_L (especially Unicode), due to a few known compatibility issues.


Last edited by OceanMachine on July 14th, 2011, 5:48 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 14th, 2011, 5:45 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6073
Location: San Diego, California
Hi DataLife,
The loop inside settimer was "never ending". So the msgbox never got to run.

I added the needed "break".
But since the timing was still marginal, I added the sleep, 200

Code:
Counter = 0
progress, B2 Y200,,Please Wait
SetTimer,PleaseWait,250
;listlines,on
MsgBox Click Ok to turn off progress bar
MsgBox This line is NOW executed `r`n was:`r`nThis line is never executed
SetTimer,PleaseWait,Off
Progress,Off
return

PleaseWait:
;listlines,off
Loop
 {
  sleep 50
  Counter++
  progress,%Counter%
   tooltip, % counter
  if Counter = 110
  {
    Counter = 0
    break
  }
 }
tooltip, done
sleep, 200
return
escape::
ExitApp


However, I suggest the following script will work much more reliably.

Code:
Counter = 0
progress, B2 Y200,,Please Wait
SetTimer,PleaseWait,50
;listlines,on
MsgBox Click Ok to turn off progress bar
SetTimer,PleaseWait,Off
MsgBox This line is NOW executed `r`n was:`r`nThis line is never executed
Progress,Off
return

PleaseWait:
;listlines,off
  Counter++
  progress,%Counter%
   tooltip, % counter
  if Counter = 110
    Counter = 0
;tooltip, done
;sleep, 200
return
escape::
ExitApp

btw, the _real life_ use of progress bars involves incrementing between sections of code, or in loops of useful code to show that progress is being made.
Otherwise its just a "blinky light"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 14th, 2011, 6:07 pm 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
Thanks for the replies. I took a break from the script and thought about it.
The SetTimer was running a loop that took over the script. The following works real good.
thanks
DataLife

Code:
Counter = 0
progress, B2 Y200,,Please Wait
SetTimer,PleaseWait,250
listlines,on
MsgBox Click Ok to turn off progress bar
MsgBox This line is NOW executed
SetTimer,PleaseWait,Off
Progress,Off
return

PleaseWait:
Counter++
progress,%Counter% ,,Please Wait
if counter > 100
 counter = 0
return
escape::
ExitApp

_________________
Check out my scripts.
(MyIpChanger) (XPSnap) (SavePictureAs)

All my scripts are tested on Windows 7, AutoHotkey_L 32 bit Ansi unless otherwise stated.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], rbrtryn, 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