How do I send a keypress for ENTER in a button script?

DOpus 12.33

I have a button "Last_Rename" defined to recall the last rename that was used:

[Standard Function]

Rename Pattern * to *

Rename PRESET=last

The script correctly opens the rename dialog and recalls the last rename that was used. However I still have to click the ENTER button in the dialog. That's not a big deal, but I want to automate the ENTER button press, execute the rename, and close the rename window. What I'm missing is the keypress step. It seems simple but I've spent two hours trying to find/script a solution.

I've tried using the most relevant example I could find from another (unrelated) forum post but I'm getting completely lost.

This is the code that doesn't work:

Rename Pattern * to *

Rename PRESET=last

@script vbscript
Option Explicit
function OnClick(clickData)
{
var wsh = new ActiveXObject("WScript.Shell");
wsh.SendKeys("{ENTER}");
}

When I use that code into my Last_Rename button, I get a script error, and I can not for life of me (out of pure ignorance, I'm sure) figure out what I'm doing wrong:

Error at line 4, position 1
{
^
Invalid character (0x800a0408)
Parse error - script aborted

Can someone who knows way more about scripting than I do tell me what I'm doing wrong?

Use the rename preset script directly in the button...

Rename Pattern * to *
@script vbscript
...

No script needed:

Rename PRESET=!last 
1 Like

Thank you so much for the quick reply. This worked perfectly without having to revisit the rename dialog each time it's called from the button.

It seems what I missed was the exclamation point prepended to the script name. I didn't see that mentioned anywhere else, so thank you. MUCH simpler than what I was trying to do.

It is mentioned in the documentation:
https://docs.dopus.com/doku.php?id=reference:command_reference:internal_commands:rename#:~:text=PATTERN%20*%20TO%20*.bak-,PRESET%20/K,-findrep