DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Cant see script shortcuts from when my start script is running

My current start script sets up custom memus when I load up diadem. Part of this process involves reseting the menus so that I start fresh before adding any bars/buttons. Unfortunatly, if the user has saved some script shortcuts they are erased next time DIAdem loads up. 

 

I am trying to write some code to preserve their script shortcuts. I have been sucessful when running code from the scripts editor window but I cant seem to reteive any stored scripts when using the same code when diadem starts up. 


For instance, if you run the following function at startup none of the saved script shortcuts show up. Any ideas for how to get around this??

 

Function GetScriptsArray
Dim ScriptButtons : Set ScriptButtons = Barmanager.Bars("SCRDIAdemScriptsFunc").UsedActionObjs
Dim ScriptsArray(12)
Dim ScriptButton
Dim i : i = 0
For Each ScriptButton In ScriptButtons
If i < 12 Then

ScriptsArray(i) = ScriptButton.Caption
ScriptsArray(i) = replace(ScriptsArray(i), "Script: ", "")
ScriptsArray(i) = replace(ScriptsArray(i), "Scri&pt: ", "") 'Sometimes an ampersand gets thrown in there
Msgbox(scriptsArray(i))
End If
i = i + 1
Next
GetScriptsArray = ScriptsArray
End Function

0 Kudos
Message 1 of 3
(3,097 Views)

So I've given up on trying to read in the script presets using a start script. Instead, I'm attempting to recreate the current script preset bars and buttons so that I can save their presets outside the DDD file.

 

1.) Is there a way to handle the click event of an actionobj so that I can tell if there was a right or left click?

 

2.) Is there a way to overload the click code on the native script preset buttons so that I can add some custom code to save the users presets?

0 Kudos
Message 2 of 3
(3,045 Views)

Hi,

 

In order to remove the script shortcuts, you would need to remove them using a function call similar to this:

BarManager.Bars("SCRDIAdemScripts").UsedActionObjs.Remove(DelActionObj.ID)

or

BarManager.Bars.Remove("SCRDIAdemScripts")

 

Theoretically, you could loop through all of the bars in the BarManager and remove everything which it sounds like you might be doing. If you are iterating over all the Bars and ActionObjects, then you can simply check for, and avoid deleting, the pre-included bars: SCRDIAdemScripts, SCRDialogBoxTemplates, SCRDIAdemScriptsFunc. You can find the Bar IDs and Object IDs by holding Ctrl+Shift and then hovering over the individual Action Objects.

 

I hope this helps!

JD B.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 3
(3,029 Views)