Async execute()? Beep()?

30 views
Skip to first unread message

Dennis Bareis

unread,
Feb 21, 2021, 9:47:54 PM2/21/21
to CopyQ
Hi,

I wish to execute a command async so that the script continues immediately, this is what I'm using now:

        execute('notepad.exe', FN)

Is there a parameter or variation that returns rather than waits for the child process to complete?

I saw some mention of sound integration of some type late last year, is there a "Beep()" command or similar, also async?

Thanks
Dennis

Lukáš Holeček

unread,
Feb 26, 2021, 3:10:32 AM2/26/21
to Dennis Bareis, CopyQ
Hi Dennis,

`action()` starts a command without waiting for it to finish:

    action('notepad.exe ' + FN)

But it requires the command to be a single string instead of a parameter list, so it may be needed to ensure that the command string is correct (for example, add quotes around the parameter).

Lukas

--
You received this message because you are subscribed to the Google Groups "CopyQ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to copyq+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/copyq/0491b4cb-cd85-4210-8b40-76aa3156abdan%40googlegroups.com.

Dennis Bareis

unread,
Apr 11, 2021, 7:05:07 PM4/11/21
to CopyQ
Hi,

I think there is a bug in the action() command that requires an extra level of escaping for every command, for example the following doesn't work:

   action('explorer.exe "D:\\TMP"')

but this will:

   action('explorer.exe "D:\\\\TMP"')

Using forward slashes requires the same.

Lukáš Holeček

unread,
Apr 13, 2021, 5:41:17 AM4/13/21
to Dennis Bareis, CopyQ
I'm not sure this is a bug. Is it something that changed/broke between CopyQ releases?

Dennis Bareis

unread,
Apr 13, 2021, 5:46:40 PM4/13/21
to Lukáš Holeček, CopyQ
Hi,

Well, I've never used it before but if not a bug then exactly what is expected should be documented as it is not a command as you mentioned but a command in a specific format and with specific restrictions.

---
Thanks
Dennis

Dennis Bareis

unread,
Apr 15, 2021, 5:48:43 PM4/15/21
to CopyQ
Hi,

Just to clarify what I mean, it doesn't take a command that the OS can execute directly (at least in Windows) but something that goes through further processing/interpretation by copyq first. Assuming this is "normal" expected for some weird linux or other compatibility reason then there should be a testbed inbult so that you can test the command copyq needs to be passed to execute the command that we need executed.

As for another issue with it, it creates a blue popup, maybe only on non zero return codes, which should be an option as windows programs (and the OS itself) are hopeless for using meaningful exit codes.  

Thanks
Dennis

Dennis Bareis

unread,
Apr 20, 2021, 4:45:27 AM4/20/21
to CopyQ
Hi,

Command containing a percentage sign are also corrupted (%3A%22)

Dennis Bareis

unread,
Apr 20, 2021, 7:28:45 PM4/20/21
to CopyQ
Hi,

I've tried a few more variations on possibly escaping without luck, this is the EXACT command in the variable passed to the "action" function (I log it to 'copyq.log', see function below):

"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" --new-window  "https://www.google.com.au/search?q=site%3Awww.interment.net"

The extra "\" is required as stated earlier.

If I copy/paste the whole command to a Windows command prompt (cmd.exe), then it opens perfectly (obviously the command processor must treat "\\" as "\" also, a little weird), if I copy/paste just the URL into the browser it also works (as you'd expect").

The page that opens via the action command is: https://www.google.com.au/search?q=siteAwww.interment.net

The action() function appears to be none of these that are documented at "https://copyq.readthedocs.io/en/latest/scripting-api.html#action":

action()

Opens action dialog.

/*row*/ action(row...commandoutputItemSeparator)

Runs command for items in current tab.

I'm not opening dialog and doing nothing in the current tab and I don't specify a row. or specify "outputItemSeparator" whatever that undocumented parameter might be...

This is my code:

//============================================================================
MyExecAsync = function(Cmd)
//============================================================================
{
    MyLog("EXECUTING THE COMMAND [ASYNC]: " + Cmd)
    action(Cmd)
}

I can't see any way to interpret this as not being a bug, if it is then perhaps you can create an "async()" function that simply executes the passed command asynchronously (without the unknown, unspecified pre-processing)?

Thanks 
Dennis

Lukáš Holeček

unread,
Apr 21, 2021, 11:40:10 AM4/21/21
to Dennis Bareis, CopyQ
Oh, there is a special meaning for %1..%9 in the Action dialog (and transitively in `action()`). It's described in the info box (if you click the [i] button of press F1 key) in the Action dialog. It says:

> Program argument %1 will be substituted for item text, and %2 through %9 for texts captured by regular expression.

This documentation is very old and I think lot of things changed in the meantime and now the text makes even less sense (the regular expression refers to the Content field in Advanced tab in Command dialog).

I'm fixing the docs and the behavior, so that only %1 is accepted by the Action dialog.

BTW, it would be better if you can open issues on github: https://github.com/hluk/CopyQ/issues

Thanks,
Lukas


Dennis Bareis

unread,
Apr 21, 2021, 6:26:06 PM4/21/21
to Lukáš Holeček, CopyQ
Hi,

It never occurred to me that I was using (an invisible?) dialog to execute something...  

You gave me action() as a way of executing something in the background, can you please create a new function that specifically performs that task without ANY preprocessing of the command (which would also be what is playing with the slashes and who knows what else) .

For now, is there any way to escape that "%" behavior?

---
Thanks
Dennis
cloudHQPowered by
cloudHQ

Lukáš Holeček

unread,
Apr 22, 2021, 11:57:39 AM4/22/21
to Dennis Bareis, CopyQ
On Thu, Apr 22, 2021 at 12:26 AM Dennis Bareis <dba...@gmail.com> wrote:
Hi,

It never occurred to me that I was using (an invisible?) dialog to execute something...  

It's not using the dialog, but the underlying functionality is the same.


You gave me action() as a way of executing something in the background, can you please create a new function that specifically performs that task without ANY preprocessing of the command (which would also be what is playing with the slashes and who knows what else) .

For now, is there any way to escape that "%" behavior?

Yes (backslash), for example: \%1

Dennis Bareis

unread,
Apr 22, 2021, 7:08:34 PM4/22/21
to CopyQ
Thanks "\%3a" (or  "\\%3a"  in a string literal) does indeed work. I'd tried it but I'm still struggling with the "normal" keys ( CTRL+S, TAB  etc) not working in CopyQ and the need to press the "Apply" button as the workaround.
Reply all
Reply to author
Forward
0 new messages