Utilities.CopyToClipboard(); does not work

5 posts, 0 answers
  1. David
    David avatar
    3 posts
    Member since:
    Mar 2019

    Posted 06 Mar Link to this post

    I wrote my simple fiddler script to automatically copy to clipboard but always getting error

    "The current wire must be set to STA mode (Single Thread Apartment) before calling to OLE. Make sure STAThreadAttribute is selected in the Main function."

    My workaround is to show dialog box and CTRL+C from there

    How do i fix it?

  2. Alexander
    Admin
    Alexander avatar
    383 posts

    Posted 08 Mar Link to this post

    Hi,

    Which version of Fiddler are you using? Also would it be possible to provide me with the code snippet which caused the problem?

    Regards,
    Alexander
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. David
    David avatar
    3 posts
    Member since:
    Mar 2019

    Posted 11 Mar in reply to Alexander Link to this post

    I'm using version 5.0.20182.28034

    Here is the code snippet

    I'm quite new to javascript. I just needed few lines to get it done hehe

    class Handlers
    {
        static function OnBeforeRequest(oSession: Session) 
        { //
            if(oSession.uriContains("string here"))
            {
                Utilities.CopyToClipboard("string here");
            }     
        } 
    }

  4. Simeon
    Admin
    Simeon avatar
    228 posts

    Posted 26 Mar Link to this post

    Hello David,

    Thank you for reporting this issue. I have logged and it will be fixed in a future version of Fiddler.

    Until then, I would like to propose you a work-around. Using the C# FiddlerScript language, which you could set from Tools\Options, Scripting tab and select the C# from the Language dropdown.
    Then you could call the CopyToClipboard method in an STA thread like this:
    using System.Threading;
    //
     
    namespace Fiddler
    {
        public static class Handlers
        { //
            public static void OnBeforeRequest(Session oSession)
            { //
                if (oSession.uriContains("string here"))
                {
                    Thread t = new Thread(() => Utilities.CopyToClipboard("string here"));
                    t.SetApartmentState(ApartmentState.STA);
                    t.Start();
                }
            }
        }
    }


    Regards,
    Simeon
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. David
    David avatar
    3 posts
    Member since:
    Mar 2019

    Posted 03 Apr in reply to Simeon Link to this post

    Thanks very much

    I better wait for update cause I'm more familar with JS and its regex system than C#

Back to Top