GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Button to change preferences option (CBR/CBZ)


#7

Drag this into Preferences / Toolbars / Scripts and it should do what you want:

ShowForComics.vbs.txt (472 Bytes)

[code]Function OnInit(initData)
initData.name = "ShowForComics"
initData.desc = "Divert double-clicks to internal viewer inside comic archives"
initData.version = "1.0"
initData.default_enable = true
End Function

Function OnDoubleClick(doubleClickData)
Set folderTest = DOpus.FSUtil.NewWild("*.(cbr|cbz|cb7)")
If (folderTest.match( doubleClickData.tab.path )) Then
OnDoubleClick = "Show LISTSIBLINGS"
Else
OnDoubleClick = False
End If
End Function[/code]

More intelligence, like checking that it’s really inside an archive and not a folder that happens to have “.cbr” as parts of its name, or like checking the type of file that has been double-clicked, is left as an exercise. :slight_smile:


#8

Doesn’t seem to work here… something wrong with the wild match, it never never catches it.

Checking it out now…


#9

It’s because the script is running before we’ve opened the archive into the new path… so the doubleClickData.tab.path is evaluated as the parent folder OF the archive.

I’ll tweak it and add in a check for sub-dirs as well.


#10

The script changes what happens when you double-click an image file while inside a .CBZ (etc.) archive.

If you want to change what happens when you double-click the archive itself, that would need something slightly different, but is still possible.


#11

Ah, yeah. That works fine - sorry. Had a different idea for scripting. Post shortly…


#12

Ok, Christmas Eve family festivities complete!

Here’s what I had in mind for a script with a bit more coverage than Leo’s excellent starter script, simply based on being familiar with digital comics, from the scripts opening comments:

[quote=“steje”]The purpose of this script is to help Opus treat comic book archives with a user configurable file extension (commonly .cb7, .cbr, or .cbz) similar to how dedicated comic archive readers work, where double-clicking on the archive itself automatically starts displaying the comic book images inside the archive - but in this case, using Opus’ internal picture viewer.

For the script to work, Opus must ALREADY be configured to treat files with these extensions as archives (7zip, RAR, and ZIP respectively)…

The script also forces the use of the internal picture viewer when double clicking on images inside either an archive (if you’ve browsed inside it as a folder) or a real folder that has an extension which matches one from the configurable list of archive file extensions.

There is also an option to configure the list of image file extensions that the script will handle inside of archives and archive extension folders…

In addition to this primary behavior, the script also provides an option to specify a qualifier key that you can use when double-clicking on the comic archives to control if the script should do it’s job or not. By default, this option is set to “none”.

NOTE: the script has logic to handle the fairly common tendency for some comic book archives to contain a single child folder at the root of the archive, which in turn contains the comic images. If there are MULTIPLE items inside the archive root in addition to that single child folder, then it’s not clear what the “right” thing to do is.

If this turns out to be the case, the script will NOT attempt to figure something out and will instead just open the archive as normal - like a folder, at which point a variation on Leo’s original code for the request that generated this script will still let the Opus internal picture viewer open any images you double click on once you’ve found them manually inside the archive.

Either way, this also helps in case you want to have another application than Opus handle opening images outside of comic archives, but still like the Opus internal picture viewer for simple viewing and scrolling through comic book images…[/quote]

How to install and use it?:
The script is provided here as an Opus Script Package… which in turn is actually a zip file with the VBScript that does the work packaged inside.

ShowForComics.osp (2.56 KB)
It can be installed by either manually copying the OSP file to the /dopusdata\Script AddIns folder, or via drag-and-drop into the Preferences / Toolbars / Scripts page. As shown in the screenshot below, as well as mentioned above, the script has a set of configurable options:




#13

Oh - and Happy Holidays!


#14

Sorry guys, Holidays got in the way. That works really well steje, thank you very much! :slight_smile:


#15

Wasn’t expecting any replies during the brunt of the holidays :slight_smile:… but sure, no problem. I’m using this myself now as well, so thank YOU for raising the idea again (it has come up in the past from digital comic fans, but I think before we had scripting in Opus).

Going to upload a new version tomorrow… with a new name and some other changes, such as support for not just the qualifier key to ENABLE the scripts behavior, but also for support of a qualifier key to DISABLE the scripts behavior, and run whatever you want as the default action (in my case, to open the archive like normal using the ‘Go FROMSEL’ command).


#16

And… thanks to Leo for the starter idea.

I only piped up after he posted his excellently simple starter script because I wanted to share a version that opened images inside of comic archives automatically after double-clicking the archive, rather than having to still browse INTO the archive and again double-click on the images.


#17

It works but I get some errors, by the way:

ShowForComics: Error at line 97, position 4 ShowForComics: Object doesn't support this property or method: 'doubleClickData.item.is_dir' (0x800a01b6) ShowForComics: Error at line 97, position 4 ShowForComics: Object doesn't support this property or method: 'doubleClickData.item.is_dir' (0x800a01b6)


#18

That’s really odd… there shouldn’t be any dependency for the use of that property that DOESN’T get satisfied that could cause that error.

Can you say what exactly you were double clicking on when that error gets thrown?

I’ve made some other changes (and renamed the script) and am posting it to the Script Buttons & Add-Ins forum… Please delete the current script package and install the new one. You will need to reset any script configuration options.


#19

I couldn’t find it in the forum, did you post it?


#20

Sorry - holidays, and some other scripting stuff got in the way.

I’ll upload it tomorrow after updating 2 other previous scripts that some folks asked for some enhancements on.

Can you say what exactly you were double clicking on when that ‘doubleClickData.item.is_dir’ error was thrown? Can you reproduce it?


#21

It’s pretty weird, I noticed I get the error even without opening CBR/CBZ files. Yesterday, for example, when moving a video file from one drive to another. And some times just by opening DOpus. But not always! Maybe once or twice a day.

I’ll inform you if I get to understand when it happens xD.


#22

Hi there Joe. Happy New Year!

I’ve posted a re-tooled version of the script to the Script Buttons & Add-Ins forum.

Little later than I’d planned - but was spending too much time on computer over the holiday so… :slight_smile:.

I don’t have any ideas what could cause that weird error… it shouldn’t cause any harm though as far as I know, but I’m using it heavily myself now as well so I will also keep my eye out for those errors. Up until that part of the code, all the script is doing is checking to see if any of the things that control it’s execution are in play, with that one in particular simply being a check to see if ~whatever you double-clicked on is a directory or not. And that could literally be ANYTHING you double-click on, not just CBR/CBZ archives.

I’ll mess around a bit to see if I can reproduce it… maybe something not so usual, like junctions or shortcuts or something. Dunno… maybe Leo or Jon might have some ideas…


#23

I got the error on two laptops. But I have no idea what caused it as I didn’t notice it until way after it happened.

I’ve added some debug in my private version to print out everything I dbl-click on to the log in order to try and catch what is causing it.


#24

I also got the error with the new version, when I open any drive, but not if I go to the drive navigating through the Folder Tree. Now the position of the error is different:

CBX_Handler: Error at line 266, position 4 CBX_Handler: Object doesn't support this property or method: 'doubleClickData.item.is_dir' (0x800a01b6)

Hope that helps! :slight_smile:


#25

Ah - yes, reproduced here as well. So it’s the drive object that throws the error. Thanks… I’ll see what GPSoft have to say.


#26

I’ve posted a new update (v1.2.1) to the forums with a workaround that Leo kindly suggested while they fix the root cause.

Works a treat now! Let me know if it you like it or would like to see any additional features… and thanks again for raising the question! I’m using this myself now quite a bit…