I write script to display dialog when I try to open PDF and choose between two PDF viewer.
No problem when files are in folders but when files are in archive, it’s failed.
Is there a way to emulate “Open with” by command/script ?
Function OnInit(initData)
initData.name = "ChoisirLecteurPDF"
initData.desc = "Propose de choisir entre Adobe Acrobat Reader ou Nuance Power PDF"
initData.copyright = "2018 Albator V (Michiels Thomas)"
initData.version = "1.0"
initData.group = "Évènement"
initData.default_enable = true
End Function
Function OnDoubleClick(doubleClickData)
If doubleClickData.item.ext = ".pdf" Then
OnDoubleClick = True
Set dlg = DOpus.Dlg
dlg.window = DOpus.Listers(0)
dlg.message = "Voulez-vous ouvrir le PDF avec Adobe Acrobat Reader ou Nuance Power PDF ?"
dlg.title = "Lecteur PDF"
dlg.buttons = "Acrobat Reader|Power PDF|Annuler"
dlg.icon = "question"
ret = dlg.Show
If ret = 1 Then ' Ouvre le fichier dans Adobe Reader
DOpus.NewCommand.RunCommand ("""C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"" """ & doubleClickData.item.realpath & """")
End If
If ret = 2 Then ' Ouvre le fichier dans Nuance PDF
DOpus.NewCommand.RunCommand ("""C:\Program Files\Nuance\Power PDF 20\bin\NuancePDF.exe"" """ & doubleClickData.item.realpath & """")
End If
End If
End Function
Function OnInit(initData)
initData.name = "ChoisirLecteurPDF"
initData.desc = "Propose de choisir entre Adobe Acrobat Reader ou Nuance Power PDF"
initData.copyright = "2018 Albator V (Michiels Thomas)"
initData.version = "1.0"
initData.group = "Évènement"
initData.default_enable = true
End Function
Function OnDoubleClick(doubleClickData)
If doubleClickData.item.ext = ".pdf" Then
OnDoubleClick = True
Set dlg = DOpus.Dlg
dlg.window = DOpus.Listers(0)
dlg.message = "Voulez-vous ouvrir le PDF avec Adobe Acrobat Reader ou Nuance Power PDF ?"
dlg.title = "Lecteur PDF"
dlg.buttons = "Acrobat Reader|Power PDF|Annuler"
dlg.icon = "question"
ret = dlg.Show
If ret = 1 Then ' Ouvre le fichier dans Adobe Reader
OnDoubleClick = """C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"" {filepath$}"
End If
If ret = 2 Then ' Ouvre le fichier dans Nuance PDF
OnDoubleClick = """C:\Program Files\Nuance\Power PDF 20\bin\NuancePDF.exe"" {filepath$}"
End If
End If
End Function
Only the two lines with the commands were changed. Instead of having the script running commands with the filepath (which will be the path within the archive, which is what the script gets passed), return the commands you want Opus to run, and use the {filepath$} placeholder.
That way Opus will run those commands instead of the one it would have run normally, and it will automatically extract the files from the archives into tempfiles, as it would for a normal command.
Ok, in 12.10.3, thanks.
(On the other hand, a pity that the progress window of the extraction appears and disappears immediately for small files, "Delayed progress indicators" option not respected?)