get the name of the open files
Hi,
I need to get the names of the opened images ( not only the active one) so I can use them as variable to activate the different opened images when needed.
Thank you
0
Best Answer
-
It looks like in your macro you activate different image (doc3), which is not the results of the operations in the macro nor the original image, that's why it's identified by name.
You should come up with a workflow where you either start from a single image or use all it's derivatives, or, if it's not possible, record a macro when you Load images from disk and do further processing. Then you can just make the Open command interactive (set .FileNames = Nothing) and the rest will be the same.
Yuri0
Answers
-
You don't really need image name to activate every window, you can use collection of Premier windows ThisApplication.Windows and activate any window in it by wnd.Activate.
Here is the example:Public Sub ActivateWindowsOneByOne 'use list of windows For Each wnd As McWindow In ThisApplication.Windows 'print window, document, image parameters Dim doc As IMcDocument=wnd.Document Dim im As McImage=TryCast(wnd.Document.Data,McImage) Debug.Print String.Format("Window name = {0}, File name = {1}",wnd.Name,doc.FileName) wnd.Activate'activate this window, it sets ThisApplication.ActiveImage,ThisApplication.ActiveDocument,ThisApplication.ActiveWindow 'do something with this window MsgBox (String.Format("Window {0} activated",wnd.Caption),vbInformation) Next End Sub
If you just want to write a macro that does multi-image processing, which starts from a single image (e.g. you extract channel, create mask, apply filter, do arithmetic operation between these images,...) then you should just activate macro recording and do your steps, all operations and activations will be recorded properly (without names), so you can then run the macro on any other image.
Yuri0 -
YuriG said:You don't really need image name to activate every window, you can use collection of Premier windows ThisApplication.Windows and activate any window in it by wnd.Activate.
Here is the example:Public Sub ActivateWindowsOneByOne 'use list of windows For Each wnd As McWindow In ThisApplication.Windows 'print window, document, image parameters Dim doc As IMcDocument=wnd.Document Dim im As McImage=TryCast(wnd.Document.Data,McImage) Debug.Print String.Format("Window name = {0}, File name = {1}",wnd.Name,doc.FileName) wnd.Activate'activate this window, it sets ThisApplication.ActiveImage,ThisApplication.ActiveDocument,ThisApplication.ActiveWindow 'do something with this window MsgBox (String.Format("Window {0} activated",wnd.Caption),vbInformation) Next End Sub
If you just want to write a macro that does multi-image processing, which starts from a single image (e.g. you extract channel, create mask, apply filter, do arithmetic operation between these images,...) then you should just activate macro recording and do your steps, all operations and activations will be recorded properly (without names), so you can then run the macro on any other image.
Yuri
Thank you. I started by recording a macro. But in the code of the macro, it actually put the full name of one of the file:Public Function Test() As SimpleScript Test = New SimpleScript Dim doc1, image1, doc2 Dim var1 = "jet1_25nmGFP170307_001_TIF", doc3, image2, doc4 With Application.DocumentCommands.Active(Test) .Run(doc1) End With With Adjust.ImageCommands.Convert(Test) .Destination = Image.ConvertTypes.Mono16 .ConvertOption = Image.ConvertOptions.Scale .Visible = True .Run(doc1, image1) End With With Application.DocumentCommands.Activate(Test) .Run(image1, doc2) End With With Application.DocumentCommands.Activate(Test) .Run(var1, doc3) End With With Adjust.ImageCommands.Convert(Test) .Destination = Image.ConvertTypes.Mono16 .ConvertOption = Image.ConvertOptions.Scale .Visible = True .Run(doc3, image2) End With With Application.DocumentCommands.Activate(Test) .Run(image2, doc4) End With End Function
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions