Happy Button
Moderators: JRL, Dorian (MJT support)
Happy Button
More fun with dialogs. Happy Button dialog moves around the screen in random fashion.
For anyone who's interested there's a couple of interesting tidbits in here. The up and down arrow keys will speed up the motion or slow down the motion. Demonstrates a workaround for a non-modal Macro> function. (Will work as a script or compiled.) Also another method for handling dialog label and button version compatibility.
Select the dialog button or press enter to close dialog and end script.
Be sure and read the comments. I didn't put in very many.
Hope it makes you smile.
Dick
[code]
//Set a bunch-o-variables
Let>XSpeeed=5
Let>YSpeeed=5
Let>ChangeRate=100
Let>Xcharge=0
Let>Ycharge=0
Let>wide=185
Let>high=80
//Determine if the process is a script or an exe
//Set mProcessor variable accordingly
StringReplace>%COMMAND_LINE%,",,COMMAND_LINE
VBSTART
VBEND
VBEval>Lcase("%COMMAND_LINE%"),COMMAND_LINE
Position>.exe,%COMMAND_LINE%,1,exe_loc
Add>exe_loc,4
Midstr>%COMMAND_LINE%,1,%exe_loc%,COMMAND_LINE
Separate>%COMMAND_LINE%,\,prossvar
Let>value=prossvar_%prossvar_count%
Separate>value,.,value
If>%value_1%=msched
Let>mProcessor=%COMMAND_LINE%%SPACE%
Else
Let>mProcessor=%COMMAND_LINE% /Script=
EndIf
//If the variable "Script" has a value, then this executable has been
//invoked by itself as a script processing agent. Run the script then exit.
Ass>Script,RunScript
If>RunScript=TRUE
Macro>Script
Goto>EOF
EndIF
//This cannot come before the variable "script" test above.
Let>macrofile=%TEMP_DIR%~MovePassWinAround~.scp
IfFileExists>%macrofile%
DeleteFile>%macrofile%
EndIf
GetScreenRes>ScreenX,ScreenY
//Up and down arrow keys can vary the button speed
WriteLn>%macrofile%,wresult,OnEvent>KEY_DOWN,VK38,0,UP
WriteLn>%macrofile%,wresult,OnEvent>KEY_DOWN,VK40,0,DOWN
WriteLn>%macrofile%,wresult,SRT>UP
WriteLn>%macrofile%,wresult,If>Xspeed>500,UpEnd
WriteLn>%macrofile%,wresult,Wait>0.1
WriteLn>%macrofile%,wresult,Add>Xspeed,1
WriteLn>%macrofile%,wresult,Add>Yspeed,1
WriteLn>%macrofile%,wresult,Label>UpEnd
WriteLn>%macrofile%,wresult,END>UP
WriteLn>%macrofile%,wresult,SRT>DOWN
WriteLn>%macrofile%,wresult,If>Xspeed%macrofile%,wresult,Wait>0.1
WriteLn>%macrofile%,wresult,Sub>Xspeed,1
WriteLn>%macrofile%,wresult,Sub>Yspeed,1
WriteLn>%macrofile%,wresult,Label>DownEnd
WriteLn>%macrofile%,wresult,END>DOWN
WriteLn>%macrofile%,wresult,Let>XSpeed=%XSpeeed%
WriteLn>%macrofile%,wresult,Let>YSpeed=%YSpeeed%
WriteLn>%macrofile%,wresult,Random>2,moveright
WriteLn>%macrofile%,wresult,Random>2,movedown
WriteLn>%macrofile%,wresult,SRT>Setup
WriteLn>%macrofile%,wresult,Random>2,Xc
WriteLn>%macrofile%,wresult,If>%Xc%=0
WriteLn>%macrofile%,wresult, Let>Xc=-1
WriteLn>%macrofile%,wresult,Else
WriteLn>%macrofile%,wresult, Let>Xc=1
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,Random>2,Yc
WriteLn>%macrofile%,wresult,If>%Yc%=0
WriteLn>%macrofile%,wresult, Let>Yc=-1
WriteLn>%macrofile%,wresult,Else
WriteLn>%macrofile%,wresult, Let>Yc=1
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,Random>%Xspeed%,Xm
WriteLn>%macrofile%,wresult,Random>%Yspeed%,Ym
WriteLn>%macrofile%,wresult,Random>%ChangeRate%,timeout
WriteLn>%macrofile%,wresult,add>Ym,1
WriteLn>%macrofile%,wresult,add>Xm,1
//Unremark the next 2 lines for more random movement
//WriteLn>%macrofile%,wresult,Random>2,moveright
//WriteLn>%macrofile%,wresult,Random>2,movedown
WriteLn>%macrofile%,wresult,END>Setup
WriteLn>%macrofile%,wresult,GoSub>Setup
WriteLn>%macrofile%,wresult,Let>k=0
WriteLn>%macrofile%,wresult,add>timeout,1
WriteLn>%macrofile%,wresult,Label>start
WriteLn>%macrofile%,wresult,Wait>0.01
WriteLn>%macrofile%,wresult,IfWindowOpen>Happy Button*
WriteLn>%macrofile%,wresult,GetWindowPos>Happy Button,X,Y
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,If>{(%X%%macrofile%,wresult, Add>X,%Xm%
WriteLn>%macrofile%,wresult,Else>
WriteLn>%macrofile%,wresult, Let>moveright=0
WriteLn>%macrofile%,wresult, If>{(%X%>0)and(%moveright%=0)}
WriteLn>%macrofile%,wresult, Sub>X,%Xm%
WriteLn>%macrofile%,wresult, Else>
WriteLn>%macrofile%,wresult, Let>moveright=1
WriteLn>%macrofile%,wresult, Add>X,%Xm%
WriteLn>%macrofile%,wresult, EndIf
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,If>{(%Y%%macrofile%,wresult, Add>Y,%Ym%
WriteLn>%macrofile%,wresult,Else>
WriteLn>%macrofile%,wresult, Let>movedown=0
WriteLn>%macrofile%,wresult, If>{(%Y%>0)and(%movedown%=0)}
WriteLn>%macrofile%,wresult, Sub>Y,%Ym%
WriteLn>%macrofile%,wresult, Else>
WriteLn>%macrofile%,wresult, Let>movedown=1
WriteLn>%macrofile%,wresult, Add>Y,%Ym%
WriteLn>%macrofile%,wresult, EndIf
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,IFW>Happy Button*
WriteLn>%macrofile%,wresult,MoveWindow>Happy Button*,%X%,%Y%
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,If>{(%k%>%timeout%)}
WriteLn>%macrofile%,wresult,GoSub>Setup
WriteLn>%macrofile%,wresult,Let>k=0
WriteLn>%macrofile%,wresult,Else
WriteLn>%macrofile%,wresult, add>k,1
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,IfW>Happy Button*,start,end
WriteLn>%macrofile%,wresult,Label>end
//Determine if the process is running under version 10
//or later and compensate for dialog backward incompatibility
Separate>%msched_ver%,.,VerVar
If>%VerVar_1%>9
Let>VV=1
Else
Let>VV=0
EndIf
Dialog>Dialog1
Caption=Happy Button
Width=%wide%
Height=%high%
Top=CENTER
Left=CENTER
Close=0
Button=* *%CRLF%[__________],48,1,85,40,3
EndDialog>Dialog1
show>dialog1
Run>%mProcessor%%macrofile%
Let>kcount=0
Random>150,kwait
Label>start
Add>kcount,1
Wait>0.01
Random>10,kdwell
Let>kdwell=%kdwell%/10
If>kdwellkdwell,1
EndIf
GetDialogAction>dialog1,r1
If>r1=3,EOF
Let>dialog1.msbutton%VV%=* *%CRLF%[__________]
If>%kcount%>%kwait%
Let>dialog1.msbutton%VV%=^ ^%CRLF%{__________}
RDA>dialog1
Wait>%Kdwell%
Let>kcount=0
Random>350,kwait
EndIf
Goto>start
Label>EOF
[/code]
For anyone who's interested there's a couple of interesting tidbits in here. The up and down arrow keys will speed up the motion or slow down the motion. Demonstrates a workaround for a non-modal Macro> function. (Will work as a script or compiled.) Also another method for handling dialog label and button version compatibility.
Select the dialog button or press enter to close dialog and end script.
Be sure and read the comments. I didn't put in very many.
Hope it makes you smile.
Dick
[code]
//Set a bunch-o-variables
Let>XSpeeed=5
Let>YSpeeed=5
Let>ChangeRate=100
Let>Xcharge=0
Let>Ycharge=0
Let>wide=185
Let>high=80
//Determine if the process is a script or an exe
//Set mProcessor variable accordingly
StringReplace>%COMMAND_LINE%,",,COMMAND_LINE
VBSTART
VBEND
VBEval>Lcase("%COMMAND_LINE%"),COMMAND_LINE
Position>.exe,%COMMAND_LINE%,1,exe_loc
Add>exe_loc,4
Midstr>%COMMAND_LINE%,1,%exe_loc%,COMMAND_LINE
Separate>%COMMAND_LINE%,\,prossvar
Let>value=prossvar_%prossvar_count%
Separate>value,.,value
If>%value_1%=msched
Let>mProcessor=%COMMAND_LINE%%SPACE%
Else
Let>mProcessor=%COMMAND_LINE% /Script=
EndIf
//If the variable "Script" has a value, then this executable has been
//invoked by itself as a script processing agent. Run the script then exit.
Ass>Script,RunScript
If>RunScript=TRUE
Macro>Script
Goto>EOF
EndIF
//This cannot come before the variable "script" test above.
Let>macrofile=%TEMP_DIR%~MovePassWinAround~.scp
IfFileExists>%macrofile%
DeleteFile>%macrofile%
EndIf
GetScreenRes>ScreenX,ScreenY
//Up and down arrow keys can vary the button speed
WriteLn>%macrofile%,wresult,OnEvent>KEY_DOWN,VK38,0,UP
WriteLn>%macrofile%,wresult,OnEvent>KEY_DOWN,VK40,0,DOWN
WriteLn>%macrofile%,wresult,SRT>UP
WriteLn>%macrofile%,wresult,If>Xspeed>500,UpEnd
WriteLn>%macrofile%,wresult,Wait>0.1
WriteLn>%macrofile%,wresult,Add>Xspeed,1
WriteLn>%macrofile%,wresult,Add>Yspeed,1
WriteLn>%macrofile%,wresult,Label>UpEnd
WriteLn>%macrofile%,wresult,END>UP
WriteLn>%macrofile%,wresult,SRT>DOWN
WriteLn>%macrofile%,wresult,If>Xspeed%macrofile%,wresult,Wait>0.1
WriteLn>%macrofile%,wresult,Sub>Xspeed,1
WriteLn>%macrofile%,wresult,Sub>Yspeed,1
WriteLn>%macrofile%,wresult,Label>DownEnd
WriteLn>%macrofile%,wresult,END>DOWN
WriteLn>%macrofile%,wresult,Let>XSpeed=%XSpeeed%
WriteLn>%macrofile%,wresult,Let>YSpeed=%YSpeeed%
WriteLn>%macrofile%,wresult,Random>2,moveright
WriteLn>%macrofile%,wresult,Random>2,movedown
WriteLn>%macrofile%,wresult,SRT>Setup
WriteLn>%macrofile%,wresult,Random>2,Xc
WriteLn>%macrofile%,wresult,If>%Xc%=0
WriteLn>%macrofile%,wresult, Let>Xc=-1
WriteLn>%macrofile%,wresult,Else
WriteLn>%macrofile%,wresult, Let>Xc=1
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,Random>2,Yc
WriteLn>%macrofile%,wresult,If>%Yc%=0
WriteLn>%macrofile%,wresult, Let>Yc=-1
WriteLn>%macrofile%,wresult,Else
WriteLn>%macrofile%,wresult, Let>Yc=1
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,Random>%Xspeed%,Xm
WriteLn>%macrofile%,wresult,Random>%Yspeed%,Ym
WriteLn>%macrofile%,wresult,Random>%ChangeRate%,timeout
WriteLn>%macrofile%,wresult,add>Ym,1
WriteLn>%macrofile%,wresult,add>Xm,1
//Unremark the next 2 lines for more random movement
//WriteLn>%macrofile%,wresult,Random>2,moveright
//WriteLn>%macrofile%,wresult,Random>2,movedown
WriteLn>%macrofile%,wresult,END>Setup
WriteLn>%macrofile%,wresult,GoSub>Setup
WriteLn>%macrofile%,wresult,Let>k=0
WriteLn>%macrofile%,wresult,add>timeout,1
WriteLn>%macrofile%,wresult,Label>start
WriteLn>%macrofile%,wresult,Wait>0.01
WriteLn>%macrofile%,wresult,IfWindowOpen>Happy Button*
WriteLn>%macrofile%,wresult,GetWindowPos>Happy Button,X,Y
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,If>{(%X%%macrofile%,wresult, Add>X,%Xm%
WriteLn>%macrofile%,wresult,Else>
WriteLn>%macrofile%,wresult, Let>moveright=0
WriteLn>%macrofile%,wresult, If>{(%X%>0)and(%moveright%=0)}
WriteLn>%macrofile%,wresult, Sub>X,%Xm%
WriteLn>%macrofile%,wresult, Else>
WriteLn>%macrofile%,wresult, Let>moveright=1
WriteLn>%macrofile%,wresult, Add>X,%Xm%
WriteLn>%macrofile%,wresult, EndIf
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,If>{(%Y%%macrofile%,wresult, Add>Y,%Ym%
WriteLn>%macrofile%,wresult,Else>
WriteLn>%macrofile%,wresult, Let>movedown=0
WriteLn>%macrofile%,wresult, If>{(%Y%>0)and(%movedown%=0)}
WriteLn>%macrofile%,wresult, Sub>Y,%Ym%
WriteLn>%macrofile%,wresult, Else>
WriteLn>%macrofile%,wresult, Let>movedown=1
WriteLn>%macrofile%,wresult, Add>Y,%Ym%
WriteLn>%macrofile%,wresult, EndIf
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,IFW>Happy Button*
WriteLn>%macrofile%,wresult,MoveWindow>Happy Button*,%X%,%Y%
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,If>{(%k%>%timeout%)}
WriteLn>%macrofile%,wresult,GoSub>Setup
WriteLn>%macrofile%,wresult,Let>k=0
WriteLn>%macrofile%,wresult,Else
WriteLn>%macrofile%,wresult, add>k,1
WriteLn>%macrofile%,wresult,EndIf
WriteLn>%macrofile%,wresult,IfW>Happy Button*,start,end
WriteLn>%macrofile%,wresult,Label>end
//Determine if the process is running under version 10
//or later and compensate for dialog backward incompatibility
Separate>%msched_ver%,.,VerVar
If>%VerVar_1%>9
Let>VV=1
Else
Let>VV=0
EndIf
Dialog>Dialog1
Caption=Happy Button
Width=%wide%
Height=%high%
Top=CENTER
Left=CENTER
Close=0
Button=* *%CRLF%[__________],48,1,85,40,3
EndDialog>Dialog1
show>dialog1
Run>%mProcessor%%macrofile%
Let>kcount=0
Random>150,kwait
Label>start
Add>kcount,1
Wait>0.01
Random>10,kdwell
Let>kdwell=%kdwell%/10
If>kdwellkdwell,1
EndIf
GetDialogAction>dialog1,r1
If>r1=3,EOF
Let>dialog1.msbutton%VV%=* *%CRLF%[__________]
If>%kcount%>%kwait%
Let>dialog1.msbutton%VV%=^ ^%CRLF%{__________}
RDA>dialog1
Wait>%Kdwell%
Let>kcount=0
Random>350,kwait
EndIf
Goto>start
Label>EOF
[/code]
Thanks for sharing, Dick. Nice way to drive people crazy, especially on fast
However, I'm curious why you are writing the script to the Temp folder.
I have edited your script and it does the same thing without writing it to the Temp folder.

However, I'm curious why you are writing the script to the Temp folder.
I have edited your script and it does the same thing without writing it to the Temp folder.
Code: Select all
//Set a bunch-o-variables
Let>XSpeeed=5
Let>YSpeeed=5
Let>ChangeRate=100
Let>Xcharge=0
Let>Ycharge=0
Let>wide=185
Let>high=80
//Determine if the process is running under version 10
//or later and compensate for dialog backward incompatibility
Separate>%msched_ver%,.,VerVar
If>%VerVar_1%>9
Let>VV=1
Else
Let>VV=0
EndIf
Dialog>Dialog1
Caption=Happy Button
Width=%wide%
Height=%high%
Top=CENTER
Left=CENTER
Close=0
Button=* *%CRLF%[__________],48,1,85,40,3
EndDialog>Dialog1
show>dialog1
Let>kcount=0
Random>150,kwait
GetScreenRes>ScreenX,ScreenY
//Up and down arrow keys can vary the button speed
OnEvent>KEY_DOWN,VK38,0,UP
OnEvent>KEY_DOWN,VK40,0,DOWN
SRT>UP
If>Xspeed>500,UpEnd
Wait>0.1
Add>Xspeed,1
Add>Yspeed,1
Label>UpEnd
END>UP
SRT>DOWN
If>Xspeed<2,DownEnd
Wait>0.1
Sub>Xspeed,1
Sub>Yspeed,1
Label>DownEnd
END>DOWN
Let>XSpeed=%XSpeeed%
Let>YSpeed=%YSpeeed%
Random>2,moveright
Random>2,movedown
SRT>Setup
Random>2,Xc
If>%Xc%=0
Let>Xc=-1
Else
Let>Xc=1
EndIf
Random>2,Yc
If>%Yc%=0
Let>Yc=-1
Else
Let>Yc=1
EndIf
Random>%Xspeed%,Xm
Random>%Yspeed%,Ym
Random>%ChangeRate%,timeout
add>Ym,1
add>Xm,1
//Unremark the next 2 lines for more random movement
//Random>2,moveright
//Random>2,movedown
END>Setup
GoSub>Setup
Let>k=0
add>timeout,1
Label>start
wait>0.0005
Add>kcount,1
Random>10,kdwell
Let>kdwell=%kdwell%/10
If>kdwell<0.3
add>kdwell,1
EndIf
GetDialogAction>Dialog1,r1
If>r1=3,EOF
Let>dialog1.msbutton%VV%=* *%CRLF%[__________]
If>%kcount%>%kwait%
Let>dialog1.msbutton%VV%=^ ^%CRLF%{__________}
RDA>dialog1
Wait>%Kdwell%
Let>kcount=0
Random>350,kwait
EndIf
IfWindowOpen>Happy Button*
GetWindowPos>Happy Button,X,Y
EndIf
If>{(%X%<%screenX%-%wide%)and(%moveright%=1)}
Add>X,%Xm%
Else>
Let>moveright=0
If>{(%X%>0)and(%moveright%=0)}
Sub>X,%Xm%
Else>
Let>moveright=1
Add>X,%Xm%
EndIf
EndIf
If>{(%Y%<%screenY%-%high%)and(%movedown%=1)}
Add>Y,%Ym%
Else>
Let>movedown=0
If>{(%Y%>0)and(%movedown%=0)}
Sub>Y,%Ym%
Else>
Let>movedown=1
Add>Y,%Ym%
EndIf
EndIf
IFW>Happy Button*
MoveWindow>Happy Button*,%X%,%Y%
EndIf
If>{(%k%>%timeout%)}
GoSub>Setup
Let>k=0
Else
add>k,1
EndIf
IfW>Happy Button*,start,end
Label>end
Label>EOF
Last edited by Rain on Thu Jan 10, 2008 3:53 pm, edited 1 time in total.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
The temp folder is where temporary files SHOULD be copied to. And it is the only place Dick can guarantee the script will be ABLE to write to, given that he doesn't know about the system on which you might run this, and where you might run it.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Now I'm even more confused.
Scripts are supposed to run from within Macro Scheduler and if compiled, the exe will run on any Windows operating system, right?
Why would you want to write the script to the Temp folder and in turn reveal your compiled code to everyone when the exe can run the script from inside the executable?
I must be missing something.
Scripts are supposed to run from within Macro Scheduler and if compiled, the exe will run on any Windows operating system, right?
Why would you want to write the script to the Temp folder and in turn reveal your compiled code to everyone when the exe can run the script from inside the executable?
I must be missing something.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I should let Dick answer and stop jumping in but my understanding is that this process needs to be TWO asynchronous scripts to work. So the main script CREATES the second. In order to be sure it can do that it writes it to the TEMP folder.
As far as where a script is for it to run - that doesn't matter. The main script can be stored and run from anywhere, but it has to create a second script and run that at the same time. It uses the TEMP folder in order to do that safely.
That any clearer?
As far as where a script is for it to run - that doesn't matter. The main script can be stored and run from anywhere, but it has to create a second script and run that at the same time. It uses the TEMP folder in order to do that safely.
That any clearer?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Most of the compiled code is not being written out. It is only a temporary macro file that is being written out. And the temp file is deleted. You could add code to make the temp file hidden or it could be encrypted.
And what is the purpose of the compilation?
The purpose here is not for security, but for transportability across systems so that it can be run on any system without Macro Scheduler.
And what is the purpose of the compilation?
The purpose here is not for security, but for transportability across systems so that it can be run on any system without Macro Scheduler.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Hi,
Marcus is correct that two scripts are running so that two separate loops can be operating simultaneously. He is also correct that the temp folder or the root of the C:\ drive are about the only two places one can be somewhat certain will exist on any computer.
If there is a security concern, Bob is probably correct that the written script could be deleted, encrypted or hidden. I'm not sure about encrypted... might be fun to try it. If I had written this to be secure I would probably have simply deleted the temporary file immediately after it was run. As soon as a called macro runs, the script file is no longer needed and can be removed. By doing this the file would only exist for a split second.
For example the green lines are in the script the red line could be added.
...previous lines
show>dialog1
Run>%mProcessor%%macrofile%
DeleteFile>%macrofile%
Let>kcount=0
Random>150,kwait
following lines...
Typically I delete temporary files that I've created at the start AND at the end of a script. I intentionally left the temporary script file so that anyone testing this sample would be able to examine the contents.
Rain is correct that this bouncing window could be made to function in a single script. But in Rain's sample, the Happy Button isn't quite as happy as in my sample. Every time the "eyes blink" it has to stop moving because the loop pauses. Not that this couldn't be avoided in a single script. However, one of the key features I wanted to demonstrate with this sample is how to have one script write another script and run that written script non-modally from a macro or complied macro. To do that I had to output a script to run.
Thanks for the feedback,
Dick
Marcus is correct that two scripts are running so that two separate loops can be operating simultaneously. He is also correct that the temp folder or the root of the C:\ drive are about the only two places one can be somewhat certain will exist on any computer.
If there is a security concern, Bob is probably correct that the written script could be deleted, encrypted or hidden. I'm not sure about encrypted... might be fun to try it. If I had written this to be secure I would probably have simply deleted the temporary file immediately after it was run. As soon as a called macro runs, the script file is no longer needed and can be removed. By doing this the file would only exist for a split second.
For example the green lines are in the script the red line could be added.
...previous lines
show>dialog1
Run>%mProcessor%%macrofile%
DeleteFile>%macrofile%
Let>kcount=0
Random>150,kwait
following lines...
Typically I delete temporary files that I've created at the start AND at the end of a script. I intentionally left the temporary script file so that anyone testing this sample would be able to examine the contents.
Rain is correct that this bouncing window could be made to function in a single script. But in Rain's sample, the Happy Button isn't quite as happy as in my sample. Every time the "eyes blink" it has to stop moving because the loop pauses. Not that this couldn't be avoided in a single script. However, one of the key features I wanted to demonstrate with this sample is how to have one script write another script and run that written script non-modally from a macro or complied macro. To do that I had to output a script to run.
Yes, although if the dialog has focus, you can close this with the press of the Enter key. It can be quite challenging to bag the smiley button with a mouse click.Rain wrote:Nice way to drive people crazy, especially on fast
Thanks for the feedback,
Dick
Dick wrote:He is also correct that the temp folder or the root of the C:\ drive are about the only two places one can be somewhat certain will exist on any computer.
It rarely fails. Every time I think I "know" something I find out differently. Just set up a computer with Vista Ultimate 64 bit. Tried to run the happy button script and it comes back with an error telling me that there was an error trying to execute the macro from the temp folder. Without alteration, Vista won't let me put a script to be run on the C: root and if I also can't put a script in the temp folder, where should it go?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Here is the error:
---------------------------
Warning
---------------------------
Line: 155 Error Executing c:\program files (x86)\macro scheduler\msched.exe C:\Users\VISTAT~1\AppData\Local\Temp\~MovePassWinAround~.scp (0)
---------------------------
OK Abort
---------------------------
The only alterations I've made to this computer are those needed to put it on the network. Also have installed Adobe Reader, Irfanview, FireFox. Pegasus mail and Macro Scheduler. Otherwise, it is a standard Vista installation. The Macro Scheduler error number "0" indicates:
Any thoughts?
Thank you,
Dick
---------------------------
Warning
---------------------------
Line: 155 Error Executing c:\program files (x86)\macro scheduler\msched.exe C:\Users\VISTAT~1\AppData\Local\Temp\~MovePassWinAround~.scp (0)
---------------------------
OK Abort
---------------------------
The only alterations I've made to this computer are those needed to put it on the network. Also have installed Adobe Reader, Irfanview, FireFox. Pegasus mail and Macro Scheduler. Otherwise, it is a standard Vista installation. The Macro Scheduler error number "0" indicates:
The computer has 2 Gig of memory, I've reinstalled build 015 three times and redownloaded the install file once. I don't know what "relocations were invalid" means but RP_WAIT is set to 0.MS Help wrote:0 - The system was out of memory, or the executable file was corrupt, or relocations were invalid. (RP_WAIT=0 only)
Any thoughts?
Thank you,
Dick
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I don't think this is the temp file causing the problem. Does this work:
ExecuteFile>C:\Users\VISTAT~1\AppData\Local\Temp\~MovePassWinAround~.scp
ExecuteFile>C:\Users\VISTAT~1\AppData\Local\Temp\~MovePassWinAround~.scp
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Yes... substituting executefile> for runprogram> does allow the script to run. I had to add a short wait between the executefile> and the deletefile>. Apparently executefile> needs a little longer to process.
Tried leaving the wait in place and rerunning with runprogram> but I still got the same "Error Executing" error.
Tried leaving the wait in place and rerunning with runprogram> but I still got the same "Error Executing" error.