open a note from command line

keldi
Posts: 6
Joined: Fri Sep 27, 2019 9:43 pm
Contact:

open a note from command line

Postby keldi » Mon Nov 01, 2021 11:39 am

Hello,

Is there a way to open a specific note in a specific CintaNotes installation using command line?


Let's say I have several Portable installations of CintaNotes:

Code: Select all

D:\A\CintaNotes.exe
D:\B\CintaNotes.exe
D:\C\CintaNotes.exe
Databases A.db, B.db and C.db are opened, and the notes have links:

Code: Select all

cintanotes://2d49b3d8-8c73-4129-a70e-8c4d7c89d4c7/note/30b0faa3-bece-4e2a-b005-7e024dfcbb06
cintanotes://1071fa4a-dc49-406e-8a82-6a2633213705/note/078958a0-f670-43ad-9957-25188a31b443
cintanotes://5f605449-80bf-4119-8fe3-8526de8e0295/note/f2f18dae-d3a9-46d9-acb9-7dcfe58c156e

I would like to do something like this:

Code: Select all

D:\A\CintaNotes.exe A.db -note 30b0faa3-bece-4e2a-b005-7e024dfcbb06
D:\B\CintaNotes.exe B.db -note 078958a0-f670-43ad-9957-25188a31b443
D:\C\CintaNotes.exe C.db -note f2f18dae-d3a9-46d9-acb9-7dcfe58c156e


So far I found out that I can pass a note link as a parameter (even when Link Protocol isn't registered in the system), but it only works for the last opened instance of CintaNotes.
I mean, if I open portable installations in order A-B-C, this works:

Code: Select all

D:\C\CintaNotes.exe cintanotes://5f605449-80bf-4119-8fe3-8526de8e0295/note/f2f18dae-d3a9-46d9-acb9-7dcfe58c156e
But if I open them in order C-B-A, the command above (for C.db) doesn't work, but the command for A.db does:

Code: Select all

D:\A\CintaNotes.exe cintanotes://2d49b3d8-8c73-4129-a70e-8c4d7c89d4c7/note/30b0faa3-bece-4e2a-b005-7e024dfcbb06
I haven't found a way to make it work for all opened instances, not only the last one.
User avatar
CintaNotes Developer
Site Admin
Posts: 4954
Joined: Fri Dec 12, 2008 4:45 pm
Contact:

Re: open a note from command line

Postby CintaNotes Developer » Tue Nov 09, 2021 2:45 pm

Hi keldi,
thanks for the question and sorry for belated reply!

Can you tell please what exactly "doesn't work" means?

You don't need to tell Cintanotes to open a specific database when you provide a full note link.
The link alone should be enough to switch to the required database, because note link contains notebook uid (the uid between "cintanotes://" and the "/note/" parts).

However! CintaNotes instance needs to be aware of this notebook to be able to open the link.
This means that this notebook should be listed in this instance's File menu before the "Exit" entry. So you need to open this notebook once in this instance.

Hope this helps!
Alex
keldi
Posts: 6
Joined: Fri Sep 27, 2019 9:43 pm
Contact:

Re: open a note from command line

Postby keldi » Thu Nov 18, 2021 9:02 pm

Thank you for your reply.

I copied the folder with Portable Version into 3 different locations. And then I opened in each copy a different database.

Image

I'm trying to open notes from each database in its own already opened CintaNotes installation:

Code: Select all

D:\A\CintaNotes.exe cintanotes://2d49b3d8-8c73-4129-a70e-8c4d7c89d4c7/note/30b0faa3-bece-4e2a-b005-7e024dfcbb06
D:\B\CintaNotes.exe cintanotes://1071fa4a-dc49-406e-8a82-6a2633213705/note/078958a0-f670-43ad-9957-25188a31b443
D:\C\CintaNotes.exe cintanotes://5f605449-80bf-4119-8fe3-8526de8e0295/note/f2f18dae-d3a9-46d9-acb9-7dcfe58c156e

Only one of the three commands from above works at any given moment, depending on whichever CintaNotes.exe was opened last.
My goal is to have three databases opened at the same time (and I want it to be in separate CintaNotes installations, so I can have different hotkeys for them and other settings) and be able to use command line to open a note from any of them.

Before your post I only had one (the opened) database under the File menu in each program. And when I tried the commands above, nothing happened at all (no errors, no notes opened) in two cases out of three.

Now I made sure that each of the programs has all three databases under the File menu. And this time when "D:\C\CintaNotes.exe" was opened last on trying this:

Code: Select all

D:\A\CintaNotes.exe cintanotes://2d49b3d8-8c73-4129-a70e-8c4d7c89d4c7/note/30b0faa3-bece-4e2a-b005-7e024dfcbb06

I'm getting an error:

Code: Select all

---------------------------
[Error]
---------------------------
class app::model::NotebookBusyException
File d:\a\a.db is busy
---------------------------
OK   
---------------------------

After I click on OK:

Code: Select all

---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Assertion failed!

Program: D:\C\CintaNotes.exe
File: .\ui\window.cpp
Line: 465

Expression: false

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts

(Press Retry to debug the application - JIT must be enabled)
---------------------------
Abort   Retry   Ignore   
---------------------------

If I choose Abort, the D:\C\CintaNotes.exe closes.
If I choose Ignore, nothing happens (D:\C\CintaNotes.exe stays open).
If I choose Retry, I get this error:

Code: Select all

---------------------------
CintaNotes
---------------------------
Oops.. something went wrong!
Please press Ctrl+C to copy the error information
and email it to support@cintanotes.com so that we can fix it:

SE EXCEPTION_BREAKPOINT at address 0x00B54EB7 inside D:\C\CintaNotes.exe loaded at base address 0x007C0000

---------------------------
OK   
---------------------------



Regards
User avatar
CintaNotes Developer
Site Admin
Posts: 4954
Joined: Fri Dec 12, 2008 4:45 pm
Contact:

Re: open a note from command line

Postby CintaNotes Developer » Fri Nov 19, 2021 12:25 pm

Ok I see...

Are you sure you actually need 3 separate instances of CN?

I wonder if the following workflow would be ok for you:

- Use 1 instance of CN that has all 3 databases in the File menu;
- Run it as admin and register the cintanotes:// protocol in it (Options/System/Register link protocol)
- When you want to open a link, simply click on it to have the correct DB/note open , or
use the following command line to do it:
start cintanotes://link
e.g. "start cintanotes://2d49b3d8-8c73-4129-a70e-8c ... 024dfcbb06"
Alex
User avatar
CintaNotes Developer
Site Admin
Posts: 4954
Joined: Fri Dec 12, 2008 4:45 pm
Contact:

Re: open a note from command line

Postby CintaNotes Developer » Fri Nov 19, 2021 12:28 pm

Otherwise, please make sure that Options/Startup/Allow multiple instances is set in all 3 copies.
And if you take care yourself of calling the correct instance, have only 1 db file in File menu in each instance - the correct one.

(So that no instance tries to open the db that is currently open in another instance.)
Alex
keldi
Posts: 6
Joined: Fri Sep 27, 2019 9:43 pm
Contact:

Re: open a note from command line

Postby keldi » Fri Nov 19, 2021 2:18 pm

Using one instance isn't a solution for me. I have different font/note list/shortcut settings for each of the databases. And I also often copy notes between them, so having all 3 opened at the same time is important for me.

CintaNotes Developer wrote:Otherwise, please make sure that Options/Startup/Allow multiple instances is set in all 3 copies.
And if you take care yourself of calling the correct instance, have only 1 db file in File menu in each instance - the correct one.

(So that no instance tries to open the db that is currently open in another instance.)
I believe that's the first thing I've tried. Thee CintaNotes.exe with Allow multiple instances, only 1 db under the File menu in each, and then I specified the paths and links in the command line:
path1\CintaNotes.exe cintanotes://link-in-db-1
path2\CintaNotes.exe cintanotes://link-in-db-2
path3\CintaNotes.exe cintanotes://link-in-db-3

What am I doing wrong here? It feels like the last opened instance tries to open all the links despite the specified paths.

Regards

Return to “CintaNotes Personal Notes Manager”