Welcome, Guest. Please login or register.
Did you miss your activation email?
April 22, 2018, 01:44:19 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  Mach SDK plugin questions and answers.
| | |-+  Finished Plugins for Download
| | | |-+  Plugin to run script on Shutdown
Pages: 1   Go Down
Print
Author Topic: Plugin to run script on Shutdown  (Read 841 times)
0 Members and 1 Guest are viewing this topic.
X-TRA78
Active Member

Offline Offline

Posts: 4


View Profile
« on: January 06, 2018, 08:05:30 AM »

Hello,

For my new ScreenSet (Sinumerik OP47), i have written a plugin with which one can execute a script (*. vbs or * hta) when Mach3 is shut down.
Maybe someone else need such a function and that's why I uploaded the plugin.

The Script should be stored in the following location.:
{Mach3InstallPath}\Macros\{Profile}\Shutdown(x).(vbs|hta)
It will look first for Shutdown(x).hta and if Not found, then Shutdown(x).vbs.

You can use multiple shutdown scripts, e.g. one to shut down Windows and one to modify XML-Profile and reboot Mach3 etc.

1.Shutdown.vbs
2.Shutdown2.vbs
3.Shutdown3.vbs
4....

The number of the shutdown script (x), can be set by using the "SetShutdownScriptNum (wNum)" subroutine.

Code:
Declare Sub SetShutdownScriptNum Lib "ShutdownScript" (ByVal Num As Integer)

The plugin does not need to be activated via the "config Plugins" menu.


currently two parameters are passed to the shutdown script.
Parameter 1 = path of Mach3 install folder
Parameter 2 = profile name

* ShutDownScript.m3p (16 KB - downloaded 63 times.)

* PluginNeedNoActivation.png (19.74 KB, 504x347 - viewed 96 times.)
« Last Edit: January 06, 2018, 08:10:26 AM by X-TRA78 » Logged
X-TRA78
Active Member

Offline Offline

Posts: 4


View Profile
« Reply #1 on: January 06, 2018, 08:29:30 AM »

Example for Shutdown.vbs to get the Params and wait until Mach3 shut down is finish.

Code:

Dim iCount
Dim iArg
Dim sProfileName
Dim sMach3Path

iCount = wScript.Arguments.Count

if iCount >= 2 then

sMach3Path = wScript.Arguments(0)
sProfileName = wScript.Arguments(1)

Else
' ....
End If

Set svc=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name='mach3.exe'"
set cproc=svc.execquery(sQuery)
iniproc=cproc.count   

Do While iniproc = 1
    wscript.sleep 200
    set svc=getobject("winmgmts:root\cimv2")
    sQuery="select * from win32_process where name='mach3.exe'"
    set cproc=svc.execquery(sQuery)
    iniproc=cproc.count
Loop

set cproc=nothing
set svc=nothing

' Mach3 has been fully shut down.
' now modify XML-Profile or something else.
« Last Edit: January 06, 2018, 08:31:03 AM by X-TRA78 » Logged
Tweakie.CNC
CNC is only limited by our imagination.
Global Moderator
*
Offline Offline

Posts: 7,173


Super Kitty


View Profile WWW
« Reply #2 on: January 06, 2018, 11:08:12 AM »

That sounds very interesting, thanks for sharing.

Tweakie.
Logged

Success consists of going from failure to failure without loss of enthusiasm.  Winston Churchill.
X-TRA78
Active Member

Offline Offline

Posts: 4


View Profile
« Reply #3 on: January 08, 2018, 03:55:33 AM »

Hello,

here is a new version of the plugin (v0.2.2.106).
I've adjusted the search paths for the script and added a new feature that lets you set the search path for the script.
In addition, the name of the first ScreenSet will be passed to the script.

The following function can now be used to set the search path
Code:
Declare Sub SetShutdownScriptPath Lib "ShutdownScript" (ByVal szPath As String)

SetShutdownScriptPath "C:\Mach3\ScreenSetMacros\Test.set\Scripts"

if no search path has been set, it is first searched in dir "{Mach3Path}\Macros\{Profile}\" for the file and then in dir "{Mach3Path}\ScreenSetMacros\{ScreenSetName}.set\"

These three parameters are now passed to the script:

Parameter 1 = path of Mach3 install folder
Parameter 2 = profile name
Parameter 3 = main screenset name (currently only first loaded ScreenSet)

* ShutDownScript_v022106.zip (9.35 KB - downloaded 32 times.)
Logged
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!