Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

User Image
Splat
21 discussion posts
I'm having trouble understanding how the MacroAPI.PasteText(string text) function works.

I have read the documentation at http://www.clipboardfusion.com/Macros/Function/?ID=356d469c-d2d6-49a7-ad05-930a623223bf, which says: This function sets the Clipboard to the given text, then pastes that text into the currently focused window.

I tried creating this Macro:
[pre]using System;

public static class ClipboardFusionHelper
{
public static string ProcessText(string text)
{
text = "1";
MacroAPI.PasteText("2");
return text;
}
}[/pre]

From this, I would expect that the value that is saved to the clipboard and is pasted is "2", but it saves and pastes "1" instead. It doesn't seem to matter what text I pass into the MacroAPI.PasteText function, it never seems to use this text.

Can you provide some more details on how this MacroAPI.PasteText function is supposed to work, perhaps with some examples?

Thanks
- Stephan
Jun 22, 2010  • #1
Jon Tackabury (BFS)'s profile on WallpaperFusion.com
Your Macro appears to work as I expect it to, perhaps I need to explain a bit better. :) The MacroAPI.PasteText function takes the given text ("2" in your example) and pastes it into the currently focused window. However, it can't do this until you release the ALT and CTRL keys. So, when you press "Alt + Ctrl + Q" (for example) to use your Macro, you need to release the keys before the "2" will be pasted. Then, whatever value you return from this function will be set to the clipboard but not pasted. I would recommend always returning the same value you are manually pasting. Does this help?
Jun 22, 2010  • #2
User Image
Splat
21 discussion posts
Thanks for the follow-up Jon.

To give you an idea of why I want to do this... I was hoping to be able to use the macros as a sort of smart snippet library, so when I press the HotKey for a given macro, the current clipboard value is temporarily saved, then a different string is created and pasted to the currently focused window, then the temporarily saved original string is put back on the clipboard. I do a lot of HTML editing in Notepad (sometimes nothing else is installed on the PCs that I use), and it would be good to be able to insert HTML snippets, so if I copy a string like "head" to the clipboard and run a macro, it will paste a framework of all the HTML elements that I need in the head of a document (head, title, meta, style, etc), then put the original string "head" back on the clipboard.

From what I understand of what you are saying, my example macro should be doing to following:
[list type=decimal]
  • I press (and hold) the HotKey (eg. Ctrl + Alt + Q)
  • Nothing happens until I release the keys
  • I release the HotKeys
  • The macro starts
  • The 'text' value is set to "1" (in this example macro) - effectively ignoring whatever was on the clipboard before I started the macro
  • The MacroAPI.PasteText function is called
  • The string "2" (in this example macro) is pasted to the currently focused window
  • The string "2" (in this example macro) is saved to the clipboard
  • The ProcessText function returns the value of 'text' (which, in this example macro, should return "1")
  • The return value of the ProcessText function is saved to the clipboard (which, in this example macro, should be "1")
  • [/ul]
    So at the end of this, the macro should have pasted the string "2" to the currently focused window, and then the string "1" should be saved to to the clipboard.

    If I used the standard paste command after this, it should just paste whatever is left on the clipboard after running the macro (in this example, it should be "1").

    But, what is happening is that the string "1" (not "2") is being pasted to the focused window, and the same string "1" is being saved to the clipboard. So it seems to be ignoring whatever string I pass to the MacroAPI.PasteText function.

    Or am I missing something here...? :?

    I'm just trying to get my head around this... thanks for any further insight that you can give me.

    Cheers,
    - Stephan
    Jun 23, 2010  • #3
    Jon Tackabury (BFS)'s profile on WallpaperFusion.com
    I have found a bug related to your example, thanks! :) I am pasting the clipboard text but not waiting for it to finish. As a result, sometimes you will get a "1" on the clipboard, sometimes a "2". I have fixed this for the upcoming 2.0.3 release. If you want to get this fix sooner, just enable the Beta update checking in the Settings window, as I'll probably put a Beta out next week. Thanks! :)
    Jun 24, 2010  • #4
    User Image
    Splat
    21 discussion posts
    Thanks Jon. :-D

    I thought that I was going crazy for a little while there. :|

    Good to know that it was an intermittent issue, and that you are aware of it now. I look forward to the next release.
    Jun 24, 2010  • #5
    Jon Tackabury (BFS)'s profile on WallpaperFusion.com
    Beta 1 is out now, can you give it a try and let me know if it works a bit better for you:
    http://www.clipboardfusion.com/Downloads/Windows/

    Thanks!
    Jun 26, 2010  • #6
    User Image
    Splat
    21 discussion posts
    I have just downloaded v2.0.2.101 Beat 1 and installed it, and tested my simple example macro again.

    It works as expected now :-D

    I am getting the string "2" pasted to the currently focussed window, and the string "1" left on the clipboard.

    Thanks Jon. I really appreciate that you take the time to investigate and address these issues, bugs and feature requests. :-)
    Jun 27, 2010  • #7
    Jon Tackabury (BFS)'s profile on WallpaperFusion.com
    Excellent, thanks for following-up. :)
    Jun 30, 2010  • #8
    Subscribe to this discussion topic using RSS
    Was this helpful?  Login to Vote(-)  Login to Vote(-)