Scripting Tutorials

Hello!
I'm new to scripting in DO12.
Is there any scripting tutorials for this? I prefer text, not video.
Best regards,
Andrey.

There are lots of example scripts, most quite simple (although not all, of course!), but no step-by-step tutorials, unfortunately. At least not so far.

I'd suggest reading the Scripting section of the manual for an intro to the different types of scripts. Then looking at some example scripts here on the forum. And the default script you get when creating a new button and setting it to script mode also gives you examples of some commonly needed techniques.

Once you have a feel for those things, browse through the manual's Scripting Reference section (which is a separate from the Scripting section mentioned before) to see all the different events and objects which you can use.

Remember you can also use JScript/VBScript built-in features (e.g. regular expressions using JScript's syntax are a bit more convenient than using the Opus regex object, unless you need identical handling to other parts of Opus, or something special). You can also use scripting objects that come with the OS such as WMI and the Windows FilesystemObject. Those come under general Windows scripting and aren't specific to Opus, as do JScript and VBScript themselves.

Hello.
These resources aren't easy. I can't find anything in it.

For example my script doesn't work, and I have no idea, why.

@echo off
echo Type password:
set /p pwd=
net use Y: https://webdav.yandex.ru "%pwd%" /user:"user"

upd1: I found that my bat script didn't work and edited it.

-- Andrey.

That isn't what we'd call a script (VBScript or JScript, using the scripting API). It's some MS-DOS commands, like from a .bat (batch) file.

MS-DOS commands and .bat files are a bit like scripting but a much older and less powerful way to do things, that also shows its age with potential problems with things like Unicode. That said, if the aim is to run the "net use" command then it's not a bad way to do it.

I feel your pain sindzicat. This response is probably going to be deleted, but I'm going to say it all anyway.

I just discovered Directory Opus is scriptable, and I kinda wish I hadn't. I'm sure at some point in the past I searched for Directory Opus macros and didn't find anything, but then, you won't. It's all under things like 'custom buttons' and 'scripting'. So that's a fail both for google and the writer of the Dopus help files, IMHO.

I've been a programmer for over 20 years, in dozens of languages, including some rather obscure scripting languages. I've not been stumped much in the past, but I have found both Auto Hotkey and Powershell scripting completely inscrutable, and now, as it turns out, Directory Opus as well. I have coded VBA before too, so it's not like the language is unknown to me.

I have searched for a proper tutorial in vain. I have searched and read a few dozen forum posts here without learning anything useful to a newcomer to scripting Dopus. There aren't many (any?) good examples of a simple, well coded script that can be a jumping off point for a beginner.

The reference in the help (once you find it) is next to useless. The 2 examples provided are convoluted. What is really needed is something really simple. Here is how to delete a file. Here is how to move the selected files to a preset directory. I literally can't even find the relevant commands to do either of these things (a simple file move or delete). And maybe these thing's aren't worth a script, but you have to start somewhere. All that stuff about responding to events and designing dialog boxes is a waste because I'm sure 99.99% of people will never get anywhere near that far along because the basics are just not covered.

Somebody obviously spent a lot of time formally documenting every single object, method and properly, all without a single line of example code; I have never seen anything like it in my life. What would have been more useful is a dozen or so really simple, really obvious demonstration scripts. Most applications I know that are scriptable come with these things.

If I had time I'd create a course, but it would be a video course, which the original poster doesn't want. I don't have time. As it is I think I'll stick with my original play, which is to try AutoIt and see if I can use that to drive Dopus. There are tutorials for it, so I think I'll start there.

There are several example scripts in the manual (look in the Scripting section, not the Scripting Reference section).

But most of the example scripts can be found here on the forum, where there is a large number of scripts.

If you don't already know the basics of JScript (Javascript) or VBScript, there are tutorials for them on the web. Teaching basic scripting is not in the scope of the Opus manual or forum, although we're happy to help answer questions about it if you get stuck trying to learn.

You won't get far with any kind of programming, or searching the web to learn new things in general, if you are put off by not finding things by looking for the first word you think of and stopping there. Not everyone uses the term "macros" for scripting. (A macro to us is usually something generated automatically by recording keyboard and mouse inputs and re-playing them. But some people use the word to mean more general scripting, it's true.)

If you have found it impossible to learn scripting for the other programs you mention then maybe the best thing to do is some tutorials on simple scripting/programming to learn more basic concepts. Most programming concepts are transferable between languages and programs/frameworks, and scripting Opus or anything else may seem incomprehensible if you aren't already familiar with the basics of programming itself.

A large part of programming is also working out how to build what you want from the blocks provided. That's the beauty and utility of programming: It lets you build things nobody else has even thought of. But since no one else has thought of them, they also can't preemptively provide instructions on how to build them, except in the form of the (hundreds of) examples on the forum to do various other things people wanted.

2 Likes

Next time Leo, just do us all a favor and delete the post. Your answer is absurd and condescending.

I was going to say that I wasn't talking to you, which I wasn't, but that hardly seems necessary since you didn't really read it.

To me it doesn't look like you really read Leo's reply! Some introspection may be useful.

4 Likes