Hints, tips and tricks for newbies
Moderators: JRL, Dorian (MJT support)
-
Massimo
- Newbie
- Posts: 15
- Joined: Sat Dec 28, 2019 5:16 pm
Post
by Massimo » Tue May 10, 2022 6:34 am
Any one knows if there is a method to know that the script is running in debug mode?
I need to change the behavior of my program in function of this.
For sure I could set a variable to True or False, but it would be great if this could be evaluated automatically by testing a system variable
Thanks
Massimo
-
Grovkillen
- Automation Wizard
- Posts: 1132
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
-
Contact:
Post
by Grovkillen » Tue May 10, 2022 9:47 am
You can look at the command line variable and see what process it is running from.
-
Massimo
- Newbie
- Posts: 15
- Joined: Sat Dec 28, 2019 5:16 pm
Post
by Massimo » Tue May 10, 2022 12:02 pm
Thanks, very simple
However I had to change in:
Let>Me=%COMMAND_LINE%
Result:
Me="C:\Program Files (x86)\Macro Scheduler 15\msched.exe"
-
JRL
- Automation Wizard
- Posts: 3529
- Joined: Mon Jan 10, 2005 6:22 pm
- Location: Iowa
Post
by JRL » Tue May 10, 2022 8:43 pm
Am I missing something here?
Is not "running in debug" simply another way of saying "running in the editor"? In my experience no matter how you run a non-compiled script the command_line variable will always be
installed_directory\msched.exe. That includes running in the editor. The only way I am aware to determine whether you are running in the editor is to check if the current window is "Macro - ScriptName". If the current window is "Macro - ScriptName", you in Debug or running in the editor.
Code: Select all
ExtractFileName>Script_name,fName,1
GetActiveWindow>WinTitle,WinX,Winy
Let>TestName=Macro - %FName%
If>{(%WinTitle%=%TestName%)or(%script_Name%="__debug.dbg")}
Let>Debug_Mode=True
Else
Let>Debug_Mode=False
EndIf
MDL>Debug_Mode
-
Dorian (MJT support)
- Automation Wizard
- Posts: 1414
- Joined: Sun Nov 03, 2002 3:19 am
Post
by Dorian (MJT support) » Tue May 10, 2022 9:04 pm
JRL wrote: ↑Tue May 10, 2022 8:43 pm
Am I missing something here?
Is not "running in debug" simply another way of saying "running in the editor"? In my experience no matter how you run a non-compiled script the command_line variable will always be
installed_directory\msched.exe. That includes running in the editor. The only way I am aware to determine whether you are running in the editor is to check if the current window is "Macro - ScriptName". If the current window is "Macro - ScriptName", you in Debug or running in the editor.
Code: Select all
ExtractFileName>Script_name,fName,1
GetActiveWindow>WinTitle,WinX,Winy
Let>TestName=Macro - %FName%
If>{(%WinTitle%=%TestName%)or(%script_Name%="__debug.dbg")}
Let>Debug_Mode=True
Else
Let>Debug_Mode=False
EndIf
MDL>Debug_Mode
I was thinking along the same lines as you too. The previous solution would identify if it was a compiled script or being run by Macro Scheduler.
This was my effort.
Code: Select all
GetActiveWindow>window_title,XX,YY
Pos>%script_name%,window_title,1,Open,
If>Open>0
mdl>Open in debugger
else
mdl>NOT open in debugger
Endif
-
JRL
- Automation Wizard
- Posts: 3529
- Joined: Mon Jan 10, 2005 6:22 pm
- Location: Iowa
Post
by JRL » Tue May 10, 2022 9:43 pm
Glad you agree. Its always worrisome not quite knowing what others are thinking. Not that I haven't had to pull my foot out of my mouth hundreds of times before. Still, strive for "accuracy".
I would add to your "If>" line to catch the possibility of not yet having saved/named the new macro.
Code: Select all
GetActiveWindow>window_title,XX,YY
Pos>%script_name%,window_title,1,Open,
If>{(%Open%>0)or(%window_title%="Macro - ")}
mdl>Open in debugger
else
mdl>NOT open in debugger
Endif