OneMore icon indicating copy to clipboard operation
OneMore copied to clipboard

Adding option to not popping notification splash dialog for Copy Link to Pages/Paragraph

Open jabobian opened this issue 1 year ago • 6 comments

Problem to Solve

Provide a clear and concise description of the problem, e.g. I'm always frustrated when...

When Click Reference > Copy Link to Page, it will pop up a splash dialog saying "Copied link to this page". This is not wanted in my work flow. Basically I have an external tab bar app to detect the title change event, when the title change, the app tries to call the "Reference > Copy Link to Page" via shortcut to get the link to page, and then analyze the page id to log it. The tab bar app will generate new tabs for specific pages (e.g. page title contains superscript *). Obviously the "Reference > Copy Link to Page" is desired to run silently.

New Feature/Solution

Provide a clear and concise description of what you want to happen.

Alternative Solutions

Provide a clear and concise description of any alternative solutions or features you've considered.

Additional Context

Provide any other context or screenshots about the feature request here.

THE FINE PRINT This is a hobby project that I started for myself. I'm happy to take requests and will promise to consider each one carefully but offer no guarantees that I will ultimately agree to their usefulness or have time to implement any of them. If OneNote offers a "close enough" work-around then I will probably reject the request - you've been warned!

jabobian avatar Jul 23 '23 03:07 jabobian

For me, Ini file or registry is ok for customization.

jabobian avatar Jul 23 '23 07:07 jabobian

Hi @jabobian, can you elaborate on your "detect title change" - I assume you have written something to do this.

I agree that making it silent would be good, but there is a tiny lag in some of oneMore's functionality, so giving feedback can be useful for some people if they alt+tab away too quickly I would imagine.

Another choice for implementation would be via the OneMore: invoker. If @stevencohn deals with some of the security concerns around this, it could be used as a poor-mans automation: "oneMore:copyLastFocusedPageLinkToClipBoard" and some way to take arguments like "silent".

jasonjac2 avatar Jul 24 '23 09:07 jasonjac2

Hi, Jason, I just use the Windows Event Hook.

SetWinEventHook(0x3, 0x3, OnWinActiveChange)   ; This is for window switch detect.
SetWinEventHook(0x800C, 0x800C, OnWinActiveChange)  ;EVENT_OBJECT_NAMECHANGE, this is for window title change

SetWinEventHook(eventMin, eventMax, callback) {
    DllCall("user32\SetWinEventHook", "UInt", eventMin, "UInt", eventMax, "Ptr", 0, "Ptr", CallbackCreate(callback, "F"), "UInt", 0, "UInt", 0, "UInt", 0)
}

OnWinActiveChange(hWinEventHook, vEvent, hwnd)
{
    DetectHiddenWindows(true)
    Try{
        WinClass := WinGetClass(hwnd)
        ov := WinGetTitle(hwnd)
        If (WinClass ="Framework::CFrame")  ;ahk_class Framework::CFrame ahk_exe ONENOTE.EXE
             Tooltip ov
    }
}

You are right. It is even simpler to add additional menu items, like Copy Link to Pages Silently, after other menuitems. Or add these menu items to a Misc group. I guess this can be added without bother.

I don't get the "oneMore:copyLastFocusedPageLinkToClipBoard" idea, is it an uri link?

jabobian avatar Jul 25 '23 06:07 jabobian

So I re-read this and, if I understand correctly, by looking for title changes, you're actually looking for navigation events - did the user just move to a different page, correct?

If so, the Navigator actually takes care of this for your and records the navigation event in %APPATA%\Navigator.json. Instead of a Windows hook monitoring Window title changes (which I think is fraught with error) you could wrap a FileWatcher around this json file and when it changes, pull out the first item in the history array (it's ordered reverse-chronological). This has all the info you need.

Navigator.json is written whether or not the Navigator window is open, as long as the Navigator feature is enabled in settings.

stevencohn avatar Jul 25 '23 10:07 stevencohn

Yes, updating and reading the Navigator.json is useful. But I have not tested the performance of detecting file change mentioned here BTW, Sharing data can also be done using comObjActive.

But I guess to make the external app an event-driven one, it is better to send some event (e.g. PostMessage(WM_User+10001, , , HWND_BROADCAST)), The external app receives the event and then look the Navigator.json for the current active page or even paragraph.

Here 1001 can be any other numbers provided it is documented and known to the developer.

jabobian avatar Jul 26 '23 14:07 jabobian

Also it is preferrable to allow an custom option for "not showing notification splash dialog for Copy Link to Paragraph".

Currently I found using the side docked window is also nice for organize bookmarks. But the text of "Copy Link to Paragraph" is different from the system default which does not include the "notebook -> section -> page" path, I wonder if it is possible to configure it.

jabobian avatar Aug 22 '23 02:08 jabobian