I have looked at Folder Options, but cannot seem to find what I'm looking for. I'm wondering if dopus has the ability of when I navigate to a directory that contains photos, it would automatically open the viewer pane in order for me to have a look at them.
I wouldn't want this to happen for each and every directory that contains photos, just the ones that I designate. Is this possible??
However, when it comes to scripting, well that's something outside my wheelhouse, up to this point. I'm eager to learn, however, if you would be willing to point me in the right direction to get started? Thanks!
This script should make a good starting point, since it does something similar:
If you use multiple tabs, you'd probably want to also want to handle the OnActivateTab event so the viewer pane turns on and off when you change tabs.
You might also want to extend the script so it can run a different command when the current folder/tab does not match the list, so it can turn the viewer pane off in non-matching folders, and on in matching ones.
I appreciate you providing me with that, Leo! Back in the day (WAY back) I used to hear the term "script kiddie", and while I'm far and away from being one of those, I will do my best to understand the workings of that provided script, and see if I can modify it to suit my needs/wants.
If I have any success, I'll post the result back for any suggestions on improvement.
Side Note: I have just read your post entitled "How to use buttons and scripts from this forum", and I can see a little of what I'm letting myself in for. To your knowledge, is there anywhere that I can use as a basic reference for the creation of Script Add-Ins? In order to be effective, I'll need a basic set of commands and such to refer to, so that I can try to understand what is going on inside a script.
Update To Side Note: Well, I see that the Help file does a pretty good job at providing some guidance in the 'Scripting' section, so I think that should get me going in the right direction. I tell you true, it never ceases to amaze me at all the features that Directory Opus provides, including the extensive Help file!!
OK Leo, quick question. I think I might be close, but the script that I modded from that base you provided just is not doing anything. I believe the problem is with the command I'm trying to pass. What I came up with in the script is the following line:
I feel that is probably wrong. I have searched but cannot find the command to use. Am I close, or if not, would you tell me the correct command to use? Thanks!
UPDATE: Ok, I found my error, and changed it to read "Set VIEWPANE=on"
However the script is not working.. surprise surprise..
I dragged the script into the Prefs/Toolbars/Scripts section, and checked the configuration, which looks good, then OKed out of Prefs. But when I enter the test folder I have set up, the viewer pane does not open....
I will paste the script I modded in the next reply for you to have a look at, if you don't mind?
Option Explicit
Function OnInit(initData)
initData.name = "Viewer Pane Auto Open"
initData.version = "1.0"
initData.desc = "Automatically Open Viewer Pane when entering configured folders"
initData.copyright = "(c) 2018 Mod By Oblias"
initData.default_enable = true
Dim vecDefFolders
Set vecDefFolders = DOpus.Create.Vector
' Default folders / example config.
' vecDefFolders.push_back("/desktop")
vecDefFolders.push_back("E:\Photos-ViewerPane")
initData.config.ViewerPaneCommand = "Set VIEWPANE=on"
initData.config.ViewerPaneFolders = vecDefFolders
initData.config_desc = DOpus.Create.Map( _
"ViewerPaneCommand", "Command to run when triggered.", _
"ViewerPaneFolders", "Folders which trigger the command.")
End Function
' Helper Function
Function IsPathInVector(fsu, path, vecFolders)
IsPathInVector = False
' Resolve aliases, libraries, etc. to their real/absolute paths.
path = fsu.Resolve(path)
Dim testPath
For Each testPath in vecFolders
If (fsu.ComparePath(path, fsu.Resolve(testPath))) Then
IsPathInVector = True
Exit Function
End If
Next
End Function
Function OnAfterFolderChange(afterFolderChangeData)
If (Not afterFolderChangeData.result) Then
Exit Function ' Folder didn't change.
End If
' Un-comment to make qualifiers (e.g. Alt, Shift, Ctrl) temporarily disable the script.
' If (afterFolderChangeData.qualifiers <> "none") Then
' Exit Function
' End If
If (Not IsPathInVector(DOpus.FSUtil, afterFolderChangeData.tab.Path, Script.config.FlatViewFolders)) Then
Exit Function
End If
Dim cmd
Set cmd = DOpus.Create.Command
cmd.SetSourceTab afterFolderChangeData.tab
cmd.RunCommand Script.config.ViewerPaneCommand
End Function
Ah ha, I found my mistake, and changed the above line to read 'ViewerPaneFolders'.
So, at this point, it now works when I enter the folder, and like magic, the Viewer Pane is opened.
Here's the biggie... I've gotten this far, but I have no idea on how to make the Viewer Pane close when I navigate away from that test folder. Is it in the 'Afterfolderchange' section???
Hey, thank you for pointing me to that one! At the moment, I'm scratching my head on the script I've been trying to mod, because I get the viewer to open, but not to close when I leave the target folder... So, I'll take a short break from that one, and go check out yours.
At this point, I'd really like to know what I'm doing wrong with the one I've been working on, but maybe I'll get some ideas from yours... or at least I have an alternative script to use if I make a complete mess out of mine....
@wowbagger Well, I followed your instructions, they are very clear, but I have a problem.
When I dragged and dropped your StyleSetter.js into the Prefs/Toolbars/Scripts it doesn't show up in the list of scripts. I double checked the C:\Users\Oblias\AppData\Roaming\GPSoftware\Directory Opus\Script AddIns folder, and it is indeed there.
Just not showing up in the Prefs list. Any idea what I'm doing wrong? Using Opus 11.19 Pro, if that makes a difference in the scripting syntax.
I made the 2 styles already, no problem there, and put the folder.xml into my test folder. Just waiting for your main script to be recognized....
I didn't notice that you are on DOpus 11. The script is configured to only work on DOpus 12. So that would be the reason you cant see it.
The script was written and tested in version 12, But it might not be using any features that are new to 12. So might actually work on version 11.
To try it out, open the .js file, look for initData.min_version = "12.0"; and change it to initData.min_version = "11.9";. See how you go.
This will allow the script to load. It might error if the script relies on a DOpus 12 feature. But that error will just stop the script working, should not impact your DOpus is a bad way.
Alternatively, maybe its a good time to upgrade
Keen to know how you go. If it works ok I will update the script to change the version setting.
Ok, making progress here! Changing the version number did make it show up in the scripts list.
A good start. Now, for the small issues... Issue #1 is that when the viewer pane opens up, it displays the text of the folder.xml file. Not that it's a deal breaker, but not really desirable for me.. I just have to click on the first image file after the folder.xml in order to see an actual photo.
The other issue, and more important to me, is that the size of the viewer pane that opens is pretty small. It takes up only about 1/3 of my screen size on the extreme right side of my dual lister setup. When I use the command to open the viewer pane in the script I was modding, the size was almost twice as large. Thing is, with the smaller size pane I get with your script, the photos are smaller for viewing. The larger size viewer pane with Set ViewPane=on allows viewing the photos in the larger format.
Is that the result of your script, or some setting within Opus itself?
EDIT: OK, I found a workaround for the folder.xml being displayed first. Since I have my files sorted alphabetically, I figured that was the problem. So I changed your script to look for zzz.xml , then renamed folder.xml to zzz.xml and now that is the last file in the folder, so it does not show up as the first thing when entering the folder.
Not the greatest solution, but the only one I can think of..
I'm now at the point in modding this script where I need to figure out how to do just that, turn it off when I exit the folder. I have been searching, reading, trying different things in the script, but I cannot seem to find the answer... Would you mind giving me a short example of what I need to put in the script to shut the viewer pane off?
Yes, I understand that part. What I don't understand is how to add on to the script so that it watches for me to exit the folder, and then I can pass along that command..
Exiting the folder means entering another one. The script is already checking when you enter a folder to see if the pane should be turned on - if it decides it shouldn't be turned on, that's the point you'd turn it off.
I think its better to keep this thread to @Leo's script (having two conversions can get confusing). Sounds like you almost have it sorted anyway.
If you want to persist with the Style Setter script, would you mind posting in that thread?
To answer your questions though.
Issue #1 Is resolvable a couple of ways. I will update scripts main post to detail how to do this.
Issue #2 As the script is just changing Styles I think this should be fixable. It should just use your default settings. I don't think it does that for me.
That makes sense to me, looking at it that way. Again, as a reminder, I am less than a beginner at scripting of any sort. The most experience I have in it is way back in the days when Basic was popular, a long time ago. So, I sort of remember the way an "If - Then" statement works, and I have a feeling that the below code is the part that is watching to see if I am in my test folder, or if I am not in my test folder.
If (Not IsPathInVector(DOpus.FSUtil, afterFolderChangeData.tab.Path, Script.config.ViewerPaneFolders)) Then
Set cmd = DOpus.Create.Command
initData.config.ViewerOffCommand = "Set VIEWPANE=off"
Exit Function
End If
Now, to see if I was right, I added those 2 lines just above the 'Exit Function' part, to see if the viewer pane would turn off when I left the test folder. It does not, so that's a fail, and I don't see anywhere else to shut off the viewer.
The solution is probably staring me in the face, and I just cannot see it because of my inexperience. Would you mind spoon-feeding me with the section of code that I need to finish up on modding your script? I could then copy it and insert it into the script, and be done, and learn the correct way to do it at the same time, by example.
In the meantime, I tried this alteration, but it also did not turn the viewer off -
If (Not afterFolderChangeData.result) Then
Set cmd = DOpus.Create.Command
initData.config.ViewerOffCommand = "Set VIEWPANE=off"
Exit Function ' Folder didn't change.
End If
So at this point, I'm completely out of ideas as to where to insert the viewpane=off command at. Or, even if I am using the correct syntax to turn it off... Basically, I'm lost.