TextBox1.Text string on end of a link - visual-studio-2010

I wanted to make an application that checks if a link was blocked on steam.
I used the linkfilter page. (https://steamcommunity.com/linkfilter/?url=)
I tried doing it like this:
WebBrowser1.Url = https://steamcommunity.com/linkfilter/?url=(TextBox1.Text)
But I got two errors. Is there a way to do this?

Did you try setting your string values as actual strings?:
WebBrowser1.Url = new Uri("https://steamcommunity.com/linkfilter/?url=" + TextBox1.Text);
or:
WebBrowser1.Url = new Uri(string.Format("https://steamcommunity.com/linkfilter/?url={0}", TextBox1.Text));

Related

Cannot switch sender email when using ReplyAll via Outlook in Python Win32

I have multiple account associated to my outlook, i am trying to set the From field to this one specific email i own. Looking at https://learn.microsoft.com/en-gb/office/vba/api/outlook.mailitem I should be able to accomplish this by changing the SendUsingAccount property, however, i am running into ERROR:root:(-2147352571, 'Type mismatch.', None, 1). Does anyone know why?
pythoncom.CoInitialize()
outlook = win32.Dispatch("Outlook.Application")
selection = outlook.ActiveExplorer().Selection
count = selection.Count + 1
for i in range(1, count):
message = selection.Item(i)
reply = message.ReplyAll()
newBody = "test"
for myEmailAddress in outlook.Session.Accounts:
if "#test.com" in str(myEmailAddress):
From = myEmailAddress
break
print(From.DisplayName) #prints the email i want fine
reply.SendUsingAccount = From.DisplayName #this line is giving me the error. If I remove it , the email popups fine, but the From address is defaulting to one i dont want to use
reply.HTMLBody = newBody + reply.HTMLBody
reply.Display(False)
Application.Session.Accounts collection returns Account objects, not strings. And MailItem.SendUsingAccount property takes an Account object, not a string.
Replace the line
if "#test.com" in str(myEmailAddress):
with
if "#test.com" in str(myEmailAddress.SmtpAddress):
and
Reply.SendUsingAccount = From.DisplayName
with
Reply.SendUsingAccount = From

Replacing portion of a URL in HPE UFT / VBscript

So I am trying to get a script to work that will obtain the current URL of the open tab, replace a portion of the URL, and enter in/navigate to the new URL which has the replaced text.
I'm struggling with the replace function as well as how to launch the edited URL in the current tab.
Here a rough idea of how I think it should look. If this worked worked it would open up a new browser with the new URL but I'd like it to be on the tab I'm currently in.
Would I need to crate an object for the result of the replace function?
If I were currently at
abc123.UZ.com/xaxsxa
I'd like to go to the page
xyz789.UZ.com/xaxsxa
Code:
Browser("Edge").Page("Loan#").WebButton("LoanConditions").Click
Browser("Edge").Page("Loan#).GetROProperty("url")
Result = Browser("Edge").Page("Loan#").GetROProperty("url")
replace (Result,"abc123","xyz789")
Systemutil.Run "Chrome.exe", "Result"
Use the Navigate method of the Browser object.
You just need to replace the last 2 lines with:
Result = replace(Result,"abc123","xyz789")
Browser("Edge").Navigate Result
Update(Based on the issue mentioned in Comments):
Try this code. This is still untested by me. So, let me know if it works for you.
set odesc = Description.create
odesc("micclass").value = "Browser"
intBefore = Desktop.Childobjects(odesc).count
Browser("Edge").Page("Loan#").WebButton("LoanConditions").Click
Browser("Edge").Page("Loan#").Sync
intAfter = Desktop.Childobjects(odesc).count
if intAfter = intBefore + 1 then
intIndex = intAfter-1
set objBro = Desktop.Childobjects(odesc).item(intIndex)
Result = objBro.getRoProperty("url")
Result = replace(Result,"abc123","xyz789")
objBro.Navigate Result
end if

CodeIgniter Pagination with number in the middle of the query string

I searched the whole day for any solution but did not found any.
I have the same problem as this guy here: Codeigniter Pagination having page number in the middle of url but the "uri_segment" param doesn't work.
My Urls look like:
localhost/controller/0/some/filter/here/
The Pagination returns teh correct link for the next and 2. page.
But once I go there, I get a wrong link back to the first site.
I did something like this:
/*Paginartion Config*/
$pagconfig['base_url'] = base_url($this->uri->segment(1).'/0/'.$this->uri->segment(3).'/'.$this->uri->segment(4).'/'.$this->uri->segment(5).'/'.$this->uri->segment(6).'/'.$this->uri->segment(7).'/'.$this->uri->segment(8));
$pagconfig['total_rows'] = $ress->num_rows;
$pagconfig['per_page'] = 10;
$pagconfig['uri_segment'] = 2;
$pagconfig['prefix'] = '/'.$this->uri->segment(1).'/';
$pagconfig['suffix'] = '/'.$this->uri->segment(3).'/'.$this->uri->segment(4).'/'.$this->uri->segment(5).'/'.$this->uri->segment(6).'/'.$this->uri->segment(7).'/'.$this->uri->segment(8);
Also I just tried using the current_url() as base_url config param and of course I also just tried to use uri_segment = 2 without using pre- and sufix.
It never worked properly.
Routes look like this:
$route['map/(:num)/(:any)'] = 'map/index/$1/$2';
$route['map/(:num)/(:any)/(:any)'] = 'map/index/$1/$2/$3';
$route['map/(:num)/(:any)/(:any)/(:any)'] = 'map/index/$1/$2/$3/$4';
$route['karte/(:num)/(:any)'] = 'map/index/$1/$2';
$route['karte/(:num)/(:any)/(:any)'] = 'map/index/$1/$2/$3';
$route['karte/(:num)/(:any)/(:any)/(:any)'] = 'map/index/$1/$2/$3/$4';
As you can see I use two kind of routes, translates for google.
The routes and Controller also work!
If I type in by hand I get the correct paginated site content:
For Example: localhost/controller/10/some/filter/here returns every row beginning with 11 (it skips first 10 as it should).
Very important is that the number always appears even on the first page where it is 0 - as you can see above.
It would be so great to get any help in that one...
Best Regards

DisplayTool installation and usage

I am using Velocity 1.7 to format string and I had some trouble with default values. Velocity by itself has no special syntax for case when value is not set and we want to use some another, default value.
By the means of Velocity it looks like:
#if(!${name})Default John#else${name}#end
which is unconveniant for my case.
After googling I've found DisplayTool, according to documentation it will look like:
$display.alt($name,"Default John")
So I added maven dependency but not sure how to add DisplayTool to my method and it is hard to found instructions for this.
Maybe somebody can help with advice or give useful links?..
My method:
public String testVelocity(String url) throws Exception{
Velocity.init();
VelocityContext context = getVelocityContext();//gets simple VelocityContext object
Writer out = new StringWriter();
Velocity.evaluate(context, out, "testing", url);
logger.info("got first results "+out);
return out.toString();
}
When I send
String url = "http://www.test.com?withDefault=$display.alt(\"not null\",\"exampleDefaults\")&truncate=$display.truncate(\"This is a long string.\", 10)";
String result = testVelocity(url);
I get "http://www.test.com?withDefault=$display.alt(\"not null\",\"exampleDefaults\")&truncate=$display.truncate(\"This is a long string.\", 10)" without changes, but should get
"http://www.test.com?withDefault=not null&truncate=This is...
Please tell me what I am missing. Thanks.
The construction of the URL occurs in your Java code, before you invoke Velocity, so Velocity isn't going to evaluate $display.alt(\"not null\",\"exampleDefaults\"). That syntax will be valid only in a Velocity template (which typically have .vm extensions).
In the Java code, there's no need to use the $ notation, you can just call the DisplayTool methods directly. I've not worked with DisplayTool before, but it's probably something like this:
DisplayTool display = new DisplayTool();
String withDefault = display.alt("not null","exampleDefaults");
String truncate = display.truncate("This is a long string.", 10);
String url = "http://www.test.com?"
+ withDefault=" + withDefault
+ "&truncate=" + truncate;
It might be better, though, to call your DisplayTool methods directly from the Velocity template. That's what is shown in the example usage.

Windows Phone 7 WebBrowserTask problem

I'm trying to open this url using a WebBrowserTask in WP7, and it doesn't work (I get a custom error on our website), but when I type it in by hand, it works fine. Any ideas?
It also works perfectly fine in Google Chrome and IE7.
This is the url:
http://www.symfonee.com/Improv/addison/comedians/Bio.aspx?ShowDate=12/15/10&ShowTime=8:00p&Uid=54918a0d-1beb-4552-bdc8-2d474e3ea5ae
And this is my code:
string url = "http://www.symfonee.com/Improv/addison/comedians/Bio.aspx?ShowDate=12/15/10&ShowTime=8:00p&Uid=54918a0d-1beb-4552-bdc8-2d474e3ea5ae";
WebBrowserTask browser = new WebBrowserTask();
browser.URL = url;
browser.Show();
Thanks!
EDIT:
Without any of the solutions below, this code works fine:
WebBrowserTask browser = new WebBrowserTask();
browser.URL = "http://www.youtube.com/results?search_query=Windows+Phone+7&aq=f";
browser.Show();
I don't understand what is different?
There is a bug with the SDK. In URL that contains &, you need to escape it.
For example:
... Uri.EscapeDataString("&") + "ShowTime=8:00p"
This is most likely because your query string parameters are not URL-encoded. Modern web browsers will attempt to compensate when you paste that into the address bar because it's hard to URL-encode in your head. But when you're using an API, you should really URL-encode those pieces yourself.
Use the Uri.EscapeDataString method to encode each part of the query string individually. For example.
string url = "http://www.symfonee.com/Improv/addison/comedians/Bio.aspx" +
"?ShowDate=" + Uri.EscapeDataString("12/15/10") +
"&ShowTime=" + Uri.EscapeDataString("8:00p") +
"&Uid=" + Uri.EscapeDataString("54918a0d-1beb-4552-bdc8-2d474e3ea5ae");
The following code worked for me:
s = "www.. "; //url
s = Uri.EscapeUriString(s);
task.URL = HttpUtility.UrlEncode(s);
You're URI needs to be escaped indeed. As simpler way I think is :
string url = "http://www.symfonee.com/Improv/addison/comedians/Bio.aspx?ShowDate=12/15/10&ShowTime=8:00p&Uid=54918a0d-1beb-4552-bdc8-2d474e3ea5ae";
WebBrowserTask browser = new WebBrowserTask();
browser.URL = Uri.EscapeUriString(url);
browser.Show();

Resources