Hello,
I am familiar with VBS scripting but I am looking for advised on how to do the following:
- automatically run a macro when program opens.
- How do I set my J1939 protocol to active instead of using CAN protocol?
Thanks - JCheese
Automatic Run of Macro
- PEAK-Support
- Sales & Support
- Posts: 1646
- Joined: Fri 10. Sep 2010, 19:34
Re: Automatic Run of Macro
Here the answers:
So you could simply run double cklick this file to run and start PE5 with a project and a macro.
This Script should be saved with the extension .vbs and stored in the project directory.automatically run a macro when program opens.
So you could simply run double cklick this file to run and start PE5 with a project and a macro.
Code: Select all
' This VB-Script opens a project in PCAN-Explorer
'-----------------------------------------------------------------------------
' Copyright (c) 2010 PEAK-System Technik GmbH. All rights reserved.
Dim app
Dim Doc
Set app = CreateObject("PCANExplorer5.Application")
' Open the project
' Replace the Path with your project directory
app.Documents.Open "c:\Users\Support\Documents\PCAN-Explorer 5\Projects\SliderDemo\SliderDemo.peproj"
' Show the application window
app.MainWindow.IsVisible = True
' Replace the Path with your Project AddIns like Panel, Plotter etc.
Set Doc = app.Documents.Open("c:\Users\Support\Documents\PCAN-Explorer 5\Projects\SliderDemo\SliderDemoPanel.ipf")
' Set the last loaded Window as active Windows (set Focus)
Doc.ActiveWindow.IsActive=true
' Load the Macro which is part of your loaded Project
app.Documents.Open("SliderDemo.pem")
' Set the loaded Macro as applyed
app.ExecuteCommand "FileApply"
' and run any command in this Macro file you want
app.ExecuteCommand "SliderDemo"
' Now it's time to show the main application window
app.MainWindow.IsVisible = True
' And toggle the FullScreen Mode
app.ExecuteCommand "ToggleFullScreen"
' to switch back from Fullscreen press F11
Select your Connection and switch in the properties section the Protocol from CAN to J1939:How do I set my J1939 protocol to active instead of using CAN protocol?
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
Re: Automatic Run of Macro
Thank you for your reply. Tweeked it to suite exactly what I wanted!
I have another situation. Once this attached macro is running, I want to be able to do something.
I want to have a StopAndClose.VBS that stops the macro running, saves the data as the rest of the traces are and then closes the program. I think I would have to modify the macro for some kind of loop but not sure. Any ideas? I just modified a sample file of a trace macro for what is here.
Thanks again, you are a life saver!
JCheese
I have another situation. Once this attached macro is running, I want to be able to do something.
I want to have a StopAndClose.VBS that stops the macro running, saves the data as the rest of the traces are and then closes the program. I think I would have to modify the macro for some kind of loop but not sure. Any ideas? I just modified a sample file of a trace macro for what is here.
Thanks again, you are a life saver!
JCheese
- Attachments
-
- StartConnectionLog.pem
- (3.27 KiB) Downloaded 701 times
- PEAK-Support
- Sales & Support
- Posts: 1646
- Joined: Fri 10. Sep 2010, 19:34
Re: Automatic Run of Macro
Here a sample Macro that shows how to quit the started Application
In the code that you have posted (based on our loosless trace sample) you use a VAR called
Simple change the state of this VAR to FALSE that ends your Loop.
Code: Select all
' This VB-Script generates an Output into the Output Window
'-----------------------------------------------------------------------------
' Copyright (c) 2010 PEAK-System Technik GmbH. All rights reserved.
Set app = CreateObject("PCANExplorer5.Application")
app.MainWindow.IsVisible = True
app.PrintToOutputwindow "Hello from VBScript"
MsgBox "The script has sent a message to PCAN-Explorer...", vbSystemModal
app.Quit
Code: Select all
IsRunning
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------