Send selected txt to mindmamager, can this?

This forum is for plugins used in the PDF-XChange Editor only.

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
krstoevan
User
Posts: 61
Joined: Thu Jan 12, 2023 3:00 pm

Send selected txt to mindmamager, can this?

Post by krstoevan »

hi, a preminary idea:

is this possible?


my friend:
Sure, I'd be happy to explain in more detail how you can use JavaScript and WinWrap Basic scripting to send highlighted text from PDF-XChange Editor to MindManager.

First, let me give you an overview of how this process works. When you highlight text in PDF-XChange Editor and run a JavaScript action, the JavaScript code selects the highlighted text and copies it to the clipboard. Then, in MindManager, you use a WinWrap Basic macro to retrieve the text from the clipboard and insert it into your map.

Here are the step-by-step instructions:

1. In PDF-XChange Editor, open the PDF document containing the text you want to send to MindManager.

2. Highlight the text you want to send to MindManager.

3. In PDF-XChange Editor, go to the "Tools" tab and select "JavaScript".

4. Click on "Create new Action" to create a new JavaScript action.

5. In the "Action Properties" dialog box, give your action a name, such as "Copy to MindManager", and click "Add".

6. In the "JavaScript Editor" dialog box, enter the following code:

```
var sel = this.getSelectedText();
this.setClipboard(sel);
```

This code uses the "getSelectedText()" method to select the highlighted text, and the "setClipboard()" method to copy the text to the clipboard.

7. Save your JavaScript action and close the "JavaScript Editor" dialog box.8. In MindManager, create a new map or open an existing map.

9. Go to the "Developer" tab and click on "Visual Basic" to open the WinWrap Basic editor.

10. In the WinWrap Basic editor, create a new macro and give it a name, such as "Paste from PDF-XChange Editor".

11. In the macro code, enter the following code:

```
' Create a new instance of PDF-XChange Editor
Set pdfApp = CreateObject("PDFXCview.PDFXCview")

' Invoke the JavaScript action to copy the selected text to the clipboard
pdfApp.InvokeScript("Copy to MindManager")

' Retrieve the text from the clipboard
Set clipboard = CreateObject("Clipboard")
sel = clipboard.GetText()

' Insert the text into the MindManager map
ActiveDocument.InsertTopic sel
```

This code uses the WinWrap Basic "CreateObject" method to create a new instance of PDF-XChange Editor. It then uses the "InvokeScript" method to run the JavaScript action you created earlier, which copies the selected text to the clipboard. The code then retrieves the text from the clipboard using the "GetText()" method of the WinWrap Basic "Clipboard" object. Finally, the code inserts the text into the MindManager map using the "InsertTopic" method.

12. Save your macro and close the WinWrap Basic editor.

Now, when you highlight text in PDF-XChange Editor and run the "Copyto MindManager" JavaScript action, the text will be copied to the clipboard and inserted into your MindManager map when you run the "Paste from PDF-XChange Editor" WinWrap Basic macro.

Note that you may need to modify the code to suit your specific requirements, as well as ensure that PDF-XChange Editor and MindManager are both running and have the necessary permissions to access the clipboard.
krstoevan
User
Posts: 61
Joined: Thu Jan 12, 2023 3:00 pm

Re: Send selected txt to mindmamager, can this?

Post by krstoevan »

but this like main program used is mm.

so i asked

me:
but this solutions works like: i highlight text in pdfxchange editor (pdfxce), then i start macro in mindmanager(mm). could it be reverse? i hight some text in pdfxce and it trigger mm to add it.

frd:
Yes, it is possible to reverse the process and have the highlighted text in PDF-XChange Editor trigger a macro in MindManager to add it to the map.

To achieve this, you can use PDF-XChange Editor's built-in JavaScript capabilities to send a message to MindManager using the Windows "SendMessage" API. MindManager can then use a WinWrap Basic macro with a Windows "MessageFilter" object to listen for the message and retrieve the text from PDF-XChange Editor.

Here are the step-by-step instructions:

1. In PDF-XChange Editor, open the PDF document containing the text you want to send to MindManager.

2. Highlight the text you want to send to MindManager.

3. In PDF-XChange Editor, go to the "Tools" tab and select "JavaScript".

4. Click on "Create new Action" to create a new JavaScript action.

5. In the "Action Properties" dialog box, give your action a name, such as "Send to MindManager", and click "Add".

6. In the "JavaScript Editor" dialog box, enter the following code:

```
var sel = this.getSelectedText();
var msg = new ActiveXObject("WScript.Shell").SendMessage(0xFFFF, 0, sel);
```

This code uses the "getSelectedText()" method to select the highlighted text in PDF-XChange Editor. It then creates a new Windows "WScript.Shell" object and sends a message toWindows using the SendMessage API with the selected text as the message. The message is sent to all top-level windows in the system, including MindManager.

7. Save your JavaScript action and close the "JavaScript Editor" dialog box.

8. In MindManager, create a new map or open an existing map.

9. Go to the "Developer" tab and click on "Visual Basic" to open the WinWrap Basic editor.

10. In the WinWrap Basic editor, create a new macro and give it a name, such as "Receive from PDF-XChange Editor".

11. In the macro code, enter the following code:

```
Dim MessageFilter As Object
Set MessageFilter = CreateObject("MessageFilter")

Do While True
' Wait for a message from PDF-XChange Editor
Dim msg As String
msg = MessageFilter.FilterMessage(WM_COPYDATA)

' Extract the text from the message
Dim sel As String
sel = Mid(msg, 5)

' Insert the text into the MindManager map
ActiveDocument.InsertTopic sel
Loop
```

This code creates a new WinWrap Basic "MessageFilter" object and uses its "FilterMessage" method to wait for a message from PDF-XChange Editor. When a message is received, the code extracts the text from the message and inserts it into the MindManager map using the "InsertTopic" method. The "Do While True" loop ensures that the macro continues tolisten for messages indefinitely.

12. Save your macro and close the WinWrap Basic editor.

Now, when you highlight text in PDF-XChange Editor, the "Send to MindManager" JavaScript action will send a message to MindManager containing the selected text. The "Receive from PDF-XChange Editor" WinWrap Basic macro will listen for the message and insert the text into the MindManager map automatically.

Note that you may need to modify the code to suit your specific requirements, as well as ensure that PDF-XChange Editor and MindManager are both running and have the necessary permissions to send and receive messages.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Send selected txt to mindmamager, can this?

Post by Tracker Supp-Stefan »

Hello krstoevan,

Thanks for the above posts. Those Chats are getting quite smart :)
Did you have a chance to try that? Is it working for you (I am not sure if the JS can communicate outside of the Editor - might be limited for security purposes).

Also - you should be able to make a button for your custom JS code - and use that:
How can I create a button to start a java script?

Kind regards,
Stefan
krstoevan
User
Posts: 61
Joined: Thu Jan 12, 2023 3:00 pm

Re: Send selected txt to mindmamager, can this?

Post by krstoevan »

gpt4 helped me to wrote several macro for mindmanager,
also some python script.
the backbone/data flow work but sometimes the syntax is wrong,
they made up, reallly made up a fake, non existing .method or .properties.

i'll try to make a plugin later

lot's to do.

thanks
Tracker Supp-Stefan wrote: Mon May 22, 2023 12:24 pm Hello krstoevan,

Thanks for the above posts. Those Chats are getting quite smart :)
Did you have a chance to try that? Is it working for you (I am not sure if the JS can communicate outside of the Editor - might be limited for security purposes).

Also - you should be able to make a button for your custom JS code - and use that:
How can I create a button to start a java script?

Kind regards,
Stefan
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Send selected txt to mindmamager, can this?

Post by Tracker Supp-Stefan »

:)
Post Reply