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?
4 Answers, 1 is accepted
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
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");
}
}
}
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
Thanks very much
I better wait for update cause I'm more familar with JS and its regex system than C#