2

我使用以下脚本创建插件(gtk),但运行脚本后,我不知道创建的插件(gtk)文件在哪里?我检查了文件夹

C:\Program Files (x86)\Gatan\DigitalMicrograph\PlugIns

我不知道在文件夹中看到任何新创建gtk的文件。

这个脚本是错误的还是创建的gtk文件应该在其他地方?

/ Define the necessary variables string base,menu,submenu,item,packageNAME,name
number maxitem,i,j,maxfolder taggroup tgFILES,tgFOLDERS,tg

// Just some starting text in the results window.
result("\n Automatic Installation of all scripts in a folder as Plugin:\n\n")

// First get the default folder. (In this case, the folder last opened within DM)
base = GetApplicationDirectory(2,0)

// Prompt the user with a dialog to choose a folder, with the default folder as first choice.

// If the user cancels the dialog, the script will stop.
If (!GetDirectoryDialog("Please select the folder containing the scripts",base,base)) exit(0)

// Ask the user for a package name

If (!GetString("Name of package file?","",packageNAME)) exit(0)

// Ask the user for a menu name

If (!GetString("Name of menu to install the scripts in","",menu)) exit(0)

// Get all files/folders in the folder as a tag-list
tgFILES = GetFilesInDirectory(base,1)
tgFOLDERS = GetFilesInDirectory(base,2)

// Install all files from the main folder as menu commands.

// Count Items in the folder
maxitem = tgFILES.TagGroupCountTags()
i = 0

// Loop through all items
while (i<maxitem)
 {

// get taggroup of item
 tgFiles.TagGroupGetIndexedTagAsTagGroup(i,tg)

 // get name of file
 tg.TagGroupGetTagAsString("Name",item)

 // Only if filename end with ".s" continue
 If (right(item,2)==".s")
 {

 // use the name without the ending
 name = left(item,len(item)-2)
 result("\n Installing: "+item)

 // install the menu command

 // use the Try-Catch loop to detect problems during install
 try
 { AddScriptToPackage(base+item,packageNAME,0,name,menu,"", 0) }
 catch
 { result(" \t ERROR DURING INSTALL") } }
 i++ }

// Now install all files from sub-folder as sub-menu commands.

// Count subfolders in the folder

maxfolder = tgFOLDERS.TagGroupCountTags()

// Loop for all subfolders
for (j=0;j<maxfolder;j++) 

 {
 // get taggroup of item
 tgFolders.TagGroupGetIndexedTagAsTagGroup(j,tg)

 // get name of subfolder which is also the name of the submenu
 tg.TagGroupGetTagAsString("Name",submenu)

// Get all files in the subfolder as a tag-list
 tgFILES = GetFilesInDirectory(base+submenu,1)

 // Count Items in the folder
 maxitem = tgFILES.TagGroupCountTags()
 i = 0

 // Loop through all items as before for the main folder
 while (i<maxitem)
 {
 tgFiles.TagGroupGetIndexedTagAsTagGroup(i,tg)
 tg.TagGroupGetTagAsString("Name",item)
 If (right(item,2)==".s")
 {
 name = left(item,len(item)-2)
 result("\n Installing <"+submenu+">: "+item)
 try {
 AddScriptToPackage(base+item,packageNAME,0,name,menu,submenu, 0) }
 catch
 {
 result(" \t ERROR DURING INSTALL") } }
 i++ } } 
4

2 回答 2

1

这在一定程度上取决于 GMS 版本和您运行的操作系统版本。我假设您在 Windows7 或 Windows8 机器上使用 GMS 2.x,那么该命令AddScriptFileToPackage可以有两个语法版本:

void AddScriptFileToPackage( String file_path, String packageName, Number packageLevel, String packageLocation, String command_name, String menu_name, String sub_menu_name, Boolean isLibrary )

void AddScriptFileToPackage( String file_path, String packageName, Number packageLevel, String command_name, String menu_name, String sub_menu_name, Boolean isLibrary )

在第一个版本中packageLocation可以是user_pluginplugin。如果省略此参数(第二个命令版本),则假定为user_plugin

对于user_plugin,您将在以下位置找到创建的文件:
C:\Users\USERNAME\AppData\Local\Gatan\Plugins
其中 USERNAME 是当前的 windows 用户。

对于插件,您将在与“DigitalMicograph.exe”安装相关的“插件”子文件夹中找到创建的文件,很可能位于:
C:\Program Files\Gatan\Plugins

于 2015-11-08T23:15:06.080 回答
1

您可能遇到了 Windows 7 的“兼容性文件”功能。GMS 1.x 只有一种AddScriptFileToPackage功能变体,它总是希望将生成的包文件保存到标准 DM PlugIns 文件夹:

C:\Program Files (x86)\Gatan\DigitalMicrograph\Plugins

但是在 Windows 7 中,这种将文件直接写入 Program Files 目录的子文件夹的行为被阻止,而是将文件写入到用户特定的本地目录,命名如下:

C:\Users\USERNAME\AppData\Local\VirtualStore\Program Files (x86)\Gatan\DigitalMicrograph\Plugins

但是,通过单击标准插件文件夹的 Windows 资源管理器窗口的工具栏中出现的“兼容性文件”按钮,可以轻松地使此类虚拟化文件可见。

于 2015-11-10T01:24:17.770 回答