Need help!

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Godly
Newbie
Posts: 5
Joined: Tue Jul 18, 2006 10:48 pm

Need help!

Post by Godly » Tue Jul 18, 2006 10:54 pm

Ok, here is the code.
Dialog>Dialog1
Caption=Dialog1
Width=445
Height=250
Top=119
Left=16
Label=Welcome to atuotyper 1.00,160,8,true
Button=Start,24,32,75,25,1,,Starts Typing
Memo=type,24,112,185,89,Type in the auto type message here
Button=Stop,24,64,75,25,2,,Stops Typing
Button=Exit,344,168,75,25,4
ComboBox=Delay_Message,120,32,145,Delay between each message%CRLF%1%CRLF%1.5%CRLF%2%CRLF%3%CRLF%4
Button=Setup Message,232,112,185,25,3
ProgressBar=msProgressBar1,232,144,185,17,0
Button=Clean Up,288,32,121,65,7
EndDialog>Dialog1

let>p=0
let>wait[1]=0.05
let>wait[2]=0.06
let>wait[3]=0.07
let>wait[4]=0.08
let>wait[5]=0.09
let>wait[6]=0.10
let>wait[7]=0.11
let>wait[8]=0.12
let>wait[9]=0.13
let>wait[10]=0.14
let>wait[12]=0.15
let>wait[13]=0.16
let>wait[14]=0.18
let>wait[15]=0.19
let>wait[16]=0.20
let>wait[17]=0.21
let>wait[18]=0.22
let>wait[19]=0.23
let>wait[20]=0.24
let>wait[21]=0.456

Show>Dialog1

Label>ActionLoop
GetDialogAction>Dialog1,r
if>r=1,Start
if>r=2,Stop
if>r=3,Setup
if>r=4,bexit
if>r=5,exit
if>r=7,clean
Goto>ActionLoop
Label>exit

SRT>Start
PlayWav>c:\windows\media\ding.wav
wait>5
label>mainloop
let>n=1
let>m=1
random>19,ra
let>ra=ra+1
Length>message[%ra%],Len
label>loop
MidStr>message[%ra%],%n%,%m%,mes2
Send Character/Text>mes2
if>n=len
press enter
random>20,random
let>rnd=dialog1.delay_message+wait[%random%]
wait>rnd
if>end=1
else
goto>mainloop
endif
else
let>n=n+1
let>m=m
random>21,random
wait>wait[%random%]
goto>loop
endif
ResetDialogAction>Dialog1
END>Start

SRT>Stop
PlayWav>c:\windows\media\ding.wav
let>end=1
END>Start
ResetDialogAction>Dialog1
END>Stop

SRT>Setup
let>message[1]=dialog1.type
let>message[2]=dialog1.type
let>message[3]=dialog1.type
let>message[4]=dialog1.type
let>message[5]=dialog1.type
let>message[6]=dialog1.type
let>message[7]=dialog1.type
let>message[8]=dialog1.type
let>message[9]=dialog1.type
let>message[10]=dialog1.type
let>string=dialog1.type
StringReplace>string,a,s,string2
let>message[11]=string2
StringReplace>string,s,d,string2
let>message[12]=string2
StringReplace>string,e,r,string2
let>message[13]=string2
StringReplace>string,b,n,string2
let>message[14]=string2
StringReplace>string,o,p,string2
let>message[15]=string2
StringReplace>string,v,b,string2
let>message[16]=string2
StringReplace>string,g,h,string2
let>message[17]=string2
StringReplace>string,i,u,string2
let>message[18]=string2
StringReplace>string,t,y,string2
let>message[19]=string2
StringReplace>string,l,;,string2
let>message[20]=string2
let>dialog1.msprogressbar1=100
ResetDialogAction>Dialog1
END>Setup

SRT>bexit
PlayWav>c:\windows\media\chimes.wav
let>end=1
let>r=5
DeleteFile>c:\scripts\autot\*.*
END>bexit
Yes i kow that im a little newbie, i couldnt figure out how to make a random number that is not an integer, so i just created variables with arrays.

Anyways, here is the question, right now, i have an infinite loop for my message program, and im wondering, after i hit start, is there any wya i can make it stop, after i hit the stop button on my dialog?
As you can see i alrleady tried ... :oops:
Its a little messy, but advanced scripters should be able to figure it out :P.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Jul 19, 2006 12:31 am

Yes i kow that im a little newbie, i couldnt figure out how to make a random number that is not an integer, so i just created variables with arrays.
A random fractional value between 1 and 10:

Random>100,res
Let>res=res/10
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Godly
Newbie
Posts: 5
Joined: Tue Jul 18, 2006 10:48 pm

Post by Godly » Wed Jul 19, 2006 12:37 am

Thanks, never would thought of it but here is the real problem ...
I have an infinite loop for my message program, and im wondering, after i hit start, is there any way i can make it stop, after i hit the stop button on my dialog?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Jul 19, 2006 12:40 am

Not sure what you are trying to do but here's a simple stop/start example:

Code: Select all

Dialog>Dialog1
   Caption=Dialog1
   Width=348
   Height=169
   Top=305
   Left=233
   Button=Start,32,40,75,25,10
   Button=Stop,32,80,75,25,20
   Edit=msEdit1,144,40,121,
   Edit=msEdit2,144,80,121,Stopped
EndDialog>Dialog1

Show>Dialog1

Let>run=0
Label>ActionLoop
  GetDialogAction>Dialog1,r
  If>r=10
    Let>run=1
	Let>Dialog1.msEdit2=Running
	ResetDialogAction>Dialog1
  endif
  If>r=20
    Let>run=0
	Let>Dialog1.msEdit2=Stopped
	ResetDialogAction>Dialog1
  Endif
  If>r=2
    Goto>exit
  Endif

  If>run=1
    GoSub>DoIt
  endif
  Wait>1

Goto>ActionLoop

Label>exit

SRT>DoIt
  Random>100,rand
  Let>rand=rand/10
  Let>Dialog1.msEdit1=rand
  ResetDialogAction>Dialog1
End>DoIt
Does that help?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Jul 19, 2006 4:16 am

You can't exit because both your "Exit" button and the dialog's upper right hand corner "X" are set to call subroutines. A subroutine returns to the line after the line that called it and continues the script from there.

What this means for your script is if the "Exit" button is selected, the variable "r" is set to "4". The If> statement testing variable "r" detects it is set to "4" and calls the "bexit" subroutine. When the bexit subroutine completes, the script then returns to testing for the value of "r" then returns to the label "ActionLoop" and the cycle continues. What you want instead of subroutines to exit your script is labels. I would change your script in these ways.

Change line 10 result from 2 to 4. 2 is the default for the upper right hand corner "X". so you always want to think of 2 as reserved for exit.
Button=Stop,24,64,75,25,4,,Stops Typing

Change line 11 result from 4 to 2 as described above 2 is for exit
Button=Exit,344,168,75,25,2

Lines 45 and 47 become
if>r=4,Stop

if>r=2,bexit
to reflect above dialog button changes.

Next, change line 127 to a label and remove line 132 which ends the subroutine
Label>bexit

The other change/addition is remove the End>Start from the middle of the "Stop" subroutine.

No guarantees I've caught everything,
Dick

Godly
Newbie
Posts: 5
Joined: Tue Jul 18, 2006 10:48 pm

Post by Godly » Thu Jul 20, 2006 5:49 am

Sorry to tell, but it doesnt work, as you can see, i have a loop, once i click the start button, is there any way, it can check if it wants to continue loop, without asking me, i tried making "stop" button make "end" bariable set to 1, and if end=1 on start action loop, it ends the typing, but for some reason it doesnt work :(. Any other sugestions?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Jul 20, 2006 9:55 pm

If you want to break out of the loop after you press start by pressing exit, you need to have something in the loop that detects that exit was selected.

Here is your start subroutine with ammendments (in red) for detecting that exit was selected. This assumes you made the changes I suggested earlier. This is untested, there might be typos. Looking at your script I'm not sure what it is you want to accomplish. Hopefully this is a learning exercise.

SRT>Start
PlayWav>c:\windows\media\ding.wav
wait>5
label>mainloop
let>n=1
let>m=1
random>19,ra
let>ra=ra+1
Length>message[%ra%],Len
label>loop


GetDialogAction>Dialog1,r
if>r=2,bexit

MidStr>message[%ra%],%n%,%m%,mes2
Send Character/Text>mes2
if>n=len
press enter
random>20,random
let>rnd=dialog1.delay_message+wait[%random%]
wait>rnd
if>end=1
else
goto>mainloop
endif
else
let>n=n+1
let>m=m
random>21,random
wait>wait[%random%]
goto>loop
endif
ResetDialogAction>Dialog1
END>Start


hope this is helpful,
Dick

Godly
Newbie
Posts: 5
Joined: Tue Jul 18, 2006 10:48 pm

Post by Godly » Fri Jul 21, 2006 9:23 pm

Ok, the exit button works now, but any ideas, on how to stop the script?

Code: Select all

Dialog>Dialog1
   Caption=Dialog1
   Width=445
   Height=250
   Top=119
   Left=16
   Label=Welcome to atuotyper 1.00,160,8,true
   Button=Start,24,32,75,25,1,,Starts Typing
   Memo=type,24,112,185,89,Type in the auto type message here
   Button=Stop,24,64,75,25,2,,Stops Typing
   Button=Exit,344,168,75,25,4
   ComboBox=Delay_Message,120,32,145,Delay between each message%CRLF%1%CRLF%1.5%CRLF%2%CRLF%3%CRLF%4
   Button=Setup Message,232,112,185,25,3
   ProgressBar=msProgressBar1,232,144,185,17,0
   Button=Clean Up,288,32,121,65,7
EndDialog>Dialog1

let>p=0
let>wait[1]=0.05
let>wait[2]=0.06
let>wait[3]=0.07
let>wait[4]=0.08
let>wait[5]=0.09
let>wait[6]=0.10
let>wait[7]=0.11
let>wait[8]=0.12
let>wait[9]=0.13
let>wait[10]=0.14
let>wait[12]=0.15
let>wait[13]=0.16
let>wait[14]=0.18
let>wait[15]=0.19
let>wait[16]=0.20
let>wait[17]=0.21
let>wait[18]=0.22
let>wait[19]=0.23
let>wait[20]=0.24
let>wait[21]=0.456

Show>Dialog1

Label>ActionLoop
GetDialogAction>Dialog1,r
if>r=1,Start
if>r=2,Stop
if>r=3,Setup
if>r=4,exit
Goto>ActionLoop
Label>exit

SRT>Start
   PlayWav>c:\windows\media\ding.wav
   wait>5
   label>mainloop
   let>n=1
   let>m=1
   random>19,ra
   let>ra=ra+1
   Length>message[%ra%],Len
   label>loop
   GetDialogAction>Dialog1,r
   if>r=4,exit
   MidStr>message[%ra%],%n%,%m%,mes2
   Send Character/Text>mes2
   if>n=len
   press enter
   random>20,random
   let>rnd=dialog1.delay_message+wait[%random%]
   wait>rnd
   if>end=1
   else
   goto>mainloop
   endif
   else
   let>n=n+1
   let>m=m
   random>21,random
   wait>wait[%random%]
   goto>loop
   endif
   ResetDialogAction>Dialog1
END>Start

SRT>Stop
   PlayWav>c:\windows\media\ding.wav
   let>end=1
   END>Start
   ResetDialogAction>Dialog1
END>Stop

SRT>Setup
   let>message[1]=dialog1.type
   let>message[2]=dialog1.type
   let>message[3]=dialog1.type
   let>message[4]=dialog1.type
   let>message[5]=dialog1.type
   let>message[6]=dialog1.type
   let>message[7]=dialog1.type
   let>message[8]=dialog1.type
   let>message[9]=dialog1.type
   let>message[10]=dialog1.type
   let>string=dialog1.type
   StringReplace>string,a,s,string2
   let>message[11]=string2
   StringReplace>string,s,d,string2
   let>message[12]=string2
   StringReplace>string,e,r,string2
   let>message[13]=string2
   StringReplace>string,b,n,string2
   let>message[14]=string2
   StringReplace>string,o,p,string2
   let>message[15]=string2
   StringReplace>string,v,b,string2
   let>message[16]=string2
   StringReplace>string,g,h,string2
   let>message[17]=string2
   StringReplace>string,i,u,string2
   let>message[18]=string2
   StringReplace>string,t,y,string2
   let>message[19]=string2
   StringReplace>string,l,;,string2
   let>message[20]=string2
   let>dialog1.msprogressbar1=100
   ResetDialogAction>Dialog1
END>Setup
[/code]

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Jul 21, 2006 9:40 pm

Ok, the exit button works now, but any ideas, on how to stop the script?


I must be missing something or perhaps there is misunderstood terminology. Does picking "Exit" not stop the script for you? It does for me. I copied and pasted your last post and picking the "Exit" button stops the script. The dialog box closes and the macro script is no longer running.

Let us know,
Dick

Godly
Newbie
Posts: 5
Joined: Tue Jul 18, 2006 10:48 pm

Post by Godly » Sat Jul 22, 2006 1:12 am

Yes, you have misunderstood me, by stoping, i ment just stoping the auto typer start command, but continue running .

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sat Jul 22, 2006 3:44 am

Ok, try this. I don't think I've altered anything except "Stop" and "Exit". The "Stop" button should now stop the autotyper. "Exit" should halt the script and close the dialog. I have highlighted the changed lines in red. I did not alter anything regarding your autotyper. Not sure what its supposed to be doing.

Let us know how it works.
dick

Dialog>Dialog1
Caption=Dialog1
Width=445
Height=250
Top=119
Left=16
Label=Welcome to atuotyper 1.00,160,8,true
Button=Start,24,32,75,25,1,,Starts Typing
Memo=type,24,112,185,89,Type in the auto type message here
Button=Stop,24,64,75,25,4,,Stops Typing
Button=Exit,344,168,75,25,2
ComboBox=Delay_Message,120,32,145,Delay between each message%CRLF%1%CRLF%1.5%CRLF%2%CRLF%3%CRLF%4
Button=Setup Message,232,112,185,25,3
ProgressBar=msProgressBar1,232,144,185,17,0
Button=Clean Up,288,32,121,65,7
EndDialog>Dialog1

let>p=0
let>wait[1]=0.05
let>wait[2]=0.06
let>wait[3]=0.07
let>wait[4]=0.08
let>wait[5]=0.09
let>wait[6]=0.10
let>wait[7]=0.11
let>wait[8]=0.12
let>wait[9]=0.13
let>wait[10]=0.14
let>wait[12]=0.15
let>wait[13]=0.16
let>wait[14]=0.18
let>wait[15]=0.19
let>wait[16]=0.20
let>wait[17]=0.21
let>wait[18]=0.22
let>wait[19]=0.23
let>wait[20]=0.24
let>wait[21]=0.456

Show>Dialog1

Label>ActionLoop
GetDialogAction>Dialog1,r
if>r=1,Start
if>r=4,Stop
if>r=3,Setup
if>r=2,exit
Wait>0.01
Goto>ActionLoop
Label>exit

SRT>Start
PlayWav>c:\windows\media\ding.wav
wait>5
label>mainloop
let>n=1
let>m=1
random>19,ra
let>ra=ra+1
Length>message[%ra%],Len
label>loop
GetDialogAction>Dialog1,r
if>r=2,exit
If>r=4
PlayWav>c:\windows\media\ding.wav
let>end=1
RDA>dialog1
Goto>ActionLoop
EndIf

MidStr>message[%ra%],%n%,%m%,mes2
Send Character/Text>mes2
if>n=len
press enter
random>20,random
let>rnd=dialog1.delay_message+wait[%random%]
wait>rnd
if>end=1
else
goto>mainloop
endif
else
let>n=n+1
let>m=m
random>21,random
wait>wait[%random%]
goto>loop
endif
ResetDialogAction>Dialog1
END>Start

SRT>Stop
PlayWav>c:\windows\media\ding.wav
let>end=1
//END>Start
ResetDialogAction>Dialog1
END>Stop

SRT>Setup
let>message[1]=dialog1.type
let>message[2]=dialog1.type
let>message[3]=dialog1.type
let>message[4]=dialog1.type
let>message[5]=dialog1.type
let>message[6]=dialog1.type
let>message[7]=dialog1.type
let>message[8]=dialog1.type
let>message[9]=dialog1.type
let>message[10]=dialog1.type
let>string=dialog1.type
StringReplace>string,a,s,string2
let>message[11]=string2
StringReplace>string,s,d,string2
let>message[12]=string2
StringReplace>string,e,r,string2
let>message[13]=string2
StringReplace>string,b,n,string2
let>message[14]=string2
StringReplace>string,o,p,string2
let>message[15]=string2
StringReplace>string,v,b,string2
let>message[16]=string2
StringReplace>string,g,h,string2
let>message[17]=string2
StringReplace>string,i,u,string2
let>message[18]=string2
StringReplace>string,t,y,string2
let>message[19]=string2
StringReplace>string,l,;,string2
let>message[20]=string2
let>dialog1.msprogressbar1=100
ResetDialogAction>Dialog1
END>Setup

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts