Paste from clipboard when clipboard changes mid script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • melvynm@gmail.com

    Paste from clipboard when clipboard changes mid script

    In the middle of my script the clipboard contents change (I'm opening a
    site which immediately copies a variable to the clipboard). How do I
    use this variable in my script?

    If I declare:
    var p = window.clipboar dData.getData(' text');
    at the beginning, then:
    p = clipboard at start of script
    and does not take note of changes.

  • Ivo

    #2
    Re: Paste from clipboard when clipboard changes mid script

    <melvynm@gmail. com> wrote[color=blue]
    > In the middle of my script the clipboard contents change (I'm opening a
    > site which immediately copies a variable to the clipboard).[/color]

    That is not going to be a popular site then. The clipboard is generally seen
    as a very private thing, and the fact that jscript can tinker with it so
    easily is not OK.
    [color=blue]
    > How do I use this variable in my script?
    >
    > If I declare:
    > var p = window.clipboar dData.getData(' text');
    > at the beginning, then:
    > p = clipboard at start of script
    > and does not take note of changes.[/color]

    Not sure what you mean. The variable is a variable like any other. You may
    even assume it is of type string. Try:

    alert( 'Look what I found on your clipboard:\n\n' + p );

    --
    Ivo


    Comment

    • melvynm@gmail.com

      #3
      Re: Paste from clipboard when clipboard changes mid script

      Actually, it's a very popular site. The site is www.tinyurl.com. Users
      of this free service go there to convert very long URLs into more
      memorable/emailable ones by receiving pointers from them. When the
      pointer is created it is automatically copied to the clipboard as that
      is the only logical thing a user is going to want to do with it.
      Also, those of us using clipboard managers aren't too bothered if a new
      entry is made as it doesn't wipe out the existing one.
      To return to the topic I'm trying to create a script which opens
      tinyurl.com and then takes the new clipboard item as the message body
      of an email. The problem is that the only way I know to use the
      clipboard contents is to use:
      var p = window.clipboar dData.getData(' text');
      then use 'p' as my clipboard contents. When I do so I only get the
      clipboard data that was there at the start of the script and not that
      which gets written halfway through.

      Comment

      • Ivo

        #4
        Re: Paste from clipboard when clipboard changes mid script

        <melvynm@gmail. com> wrote[color=blue]
        > Actually, it's a very popular site. The site is www.tinyurl.com. Users
        > of this free service go there to convert very long URLs into more
        > memorable/emailable ones by receiving pointers from them. When the
        > pointer is created it is automatically copied to the clipboard as that
        > is the only logical thing a user is going to want to do with it.
        > Also, those of us using clipboard managers aren't too bothered if a new
        > entry is made as it doesn't wipe out the existing one.[/color]

        Don't know what a clipboard manager is, sounds disturbing.
        [color=blue]
        > To return to the topic I'm trying to create a script which opens
        > tinyurl.com and then takes the new clipboard item as the message body
        > of an email.
        > The problem is that the only way I know to use the
        > clipboard contents is to use:
        > var p = window.clipboar dData.getData(' text');
        > then use 'p' as my clipboard contents. When I do so I only get the
        > clipboard data that was there at the start of the script and not that
        > which gets written halfway through.[/color]

        So I understand your script is not going to come from the same domain>
        scripts like reading the clipboad periodically (using setInterval) so you
        can find out when it's changed by tinyurl.com, are going to suffer from
        cross-domain security issues.
        --
        Ivo


        Comment

        • Randy Webb

          #5
          Re: Paste from clipboard when clipboard changes mid script

          melvynm@gmail.c om wrote:
          [color=blue]
          > Actually, it's a very popular site. The site is www.tinyurl.com. Users
          > of this free service go there to convert very long URLs into more
          > memorable/emailable ones by receiving pointers from them. When the
          > pointer is created it is automatically copied to the clipboard as that
          > is the only logical thing a user is going to want to do with it.[/color]

          Correction:

          It is only copied to the clipboard if the user is using IE4+ on Windows.

          To quote the tinyURL site:

          <quote>
          Note: For IE 4+ on Windows, the TinyURL is automatically copied to your
          clipboard and is ready for pasting (using Ctrl-V).
          </quote>

          --
          Randy
          comp.lang.javas cript FAQ - http://jibbering.com/faq

          Comment

          Working...