|
It's not a key with any assigned value, but a modifier. You could P/Invoke GetKeyState that is used to determine the state of other modifier keys, or wait until a following key is pressed and mask the state of the modifier. Through some simple reverse engineering you could easily figure out what that virtual key code is.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Let me see if I understand. Here's a scenario. I press the Fn key and another key, say F10, and I have a program that will capture keystrokes using the SetWindowsHookEx, etc. I will get the virtual key code for the F10 and pass it to the GetKeyState method. The GetKeyState method will return me a value. That value will let me know whether the Fn key was pressed at the same time as the F10 key. Is that correct?
Question then becomes what is the return value from GetKeyState? MSDN says:
"If the high-order bit is 1, the key is down; otherwise, it is up.
If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled."
So could the value be somewhere inbetween?
Please forgive me if my questions are simple. I'm new to this type of programming and am just trying to have it make sense.
Thanks
|
|
|
|
|
No, you pass the keycode of the Fn key to GetKeyState . See the remarks about the Alt, Ctrl, and Shift keys, for example. Those are also modifier keys.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I've tried everything I can think of to write this troublesome character to a text file..
I'm writing a program to generate CSS files and I can write "{" and "}" to the console either directly or using its ascii code:
// These both work
Console.WriteLine("{");
Console.WriteLine(((char)123).ToString());
Now when I try to write to a streamwriter (or textwriter) I get an error saying:
"Additional information: Input string was not in a correct format."
This is even though I read in a template file (containing "{" and "}") and it reads it fine and displays to the console..
What am i doing wrong? Can i write "{" and "}" to a file at all? Is there an escape character i just dont know about?!
Thanks guys,
James
|
|
|
|
|
This worked fine for me....
StreamWriter SW = new StreamWriter("c:\\temp\\test.txt",false);
SW.Write("{");
SW.Close();
|
|
|
|
|
|
Does anybody know how to update listview subitems without redrawing the whole row?
Cheers.
|
|
|
|
|
Folks, I'm looking for an 'easy' answer here. The .Net 2.0 version of the TabControl doesn't have a 'no tabs' setting for Appearance. (I read elsewhere that it should. That may have been an MFC version of the control.) I'm using the Whidbey C# development environment and I would like to use a control similar to a TabControl, but I don't want to display any tabs. I want to switch the currently displayed 'tab page' from code. I'm trying to avoid having to develop the control from scratch. I could just use panels and flip between them, but many separate panels are difficult to manage in the IDE. It's just easier to use a control that flips them for you. (Anyone who has tried to place a lot of overlapping panels on a form will feel my pain. ;c)) If anyone can provide me with a suggestion, I'd be thankful.
Thanks,
Bob
|
|
|
|
|
How to initilize a textBox with background color that you want.
I tried this
"textBox25.BackColor=Color.Green;"
but the dropdown has predefine colors (e.g Red, Green, Gray...)
I want to use my own custom color.
|
|
|
|
|
Use Color.FromArgb method for using ur own custom color.
For example:
textBox25.BackColor = Color.FromArgb(255, 133 , 144);
//You need to know RGB values for your custom color
You can see Color.FromArgb in MSDN for more on this.
|
|
|
|
|
You can set the background color, provided you know the values of the different color elements. The following code sets the background to Yellow:
textBox25.BackColor = Color.FromArgb( 255,255,0 );
Color.FromArgb() can be used to set a color with different attributes. Check out the different calling options.
Bob
|
|
|
|
|
hello ,
I have created a Control array for a ComboBox to populate on a tabPage .
My concern is that I 'm using a List to populate the Combo Box like this ..
ComboArray[i].Items.Add(List[i)];
ComboArray[i].DataSource = List;
The Combo Box gets populated with all the values in the List ( Thats what I
wanted )
But when i select a value in the First Combo box the Changes reflects in all
the boxes created
Example
if if there were 6 values from 1,2,3 ..6 in the all Combo Dropdown list .
when I select 5 in the 3rd all the Combo's selected value changes to 5.
How do I get specifice values in different Combo According to my selection ?
Thanks
Sylesh Nair
|
|
|
|
|
I think your problem might be in assigning all the ComboBox's DataSource property to the same object. Is there a reason your are assigning the DataSource Property ?
|
|
|
|
|
object[] dest=new object[List.Items.Count];
List.Items.CopyTo(dest,0);
ComboArray[i].DataSource = dest;
This will solve ur problem
|
|
|
|
|
Thanks Ibraheem , for the code snippet you had send to me .
but the ComboArray[i].DatSource = dest still gives me the same problem .
So I tried a different way which was
ComboArray[i].items.AddRange(dest). This is working now as Addrange needs a an collection class which implements IList Interface .
Anyways thanks a lot
Sylesh
|
|
|
|
|
Well u welcome
However the same piece of code worked for me. Thats interesting i might have done something wrong.
Regards
Ibraheem
|
|
|
|
|
Here in your application you are using same datasource for all combo control. This is the reason for your issue. Here you can make a deep copy the datasource and bind it.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
All,
I am looking for a code which retrieves a HTML source for a given website. I got few but none of the code really works for all websites. Some has security issues, some has timeout issues, some has redirect issues, some has session management issues. I am looking for the code which works for all kinds of websites.
given a website say www.xyz.com/default.aspx I want to retrieve the HTML source(same as when this page get rendered). I want to achieve this without any UI.
Does anyone knows where I can get one?
Thanks,
Anand
|
|
|
|
|
Unless you have knowledge of the specific site, you're always going to run into problems with a secured site or one with complex session management. Implementations will differ from site to site, making a one-size-fits-all component very difficult.
For example, lets assume that have valid credentials to log into a secured site, how does that site manage them? Do you need to pass them in the form of a cookie, or do you have to post to a specific page? What happens if the site changes their implementation details?
Creating a component that could handle all of the different variations would most likely require a constantly updated data source with the implementation details for each non-public site. I can't imagine that anyone would argue that disclosing the inner workings of your authentication mechanism is a good security practice.
I don't think that you're going to find a component that meets your requirements. Your best bet would be to see if the desired sites offer an RSS or ATOM syndication, or perhaps a web service to supply details to your application.
Not the answer that you were looking for, but I hope it helps a bit.
--Jesse
|
|
|
|
|
Thanks Jesse. That really helps.
I guess there are two major things which need to be taken care of
1. Security/Credentials.
2. Session Management.
How about using AXWebBrowser or InternetBrowser to load the page and then retrieve the HTML Source (IHTMLDocument2), since it is as good as loading it in browser.
1. Assuming that for all the site we have only one credential. How about passing credentials in all possible ways(cookies, setting the credential property, and many (I don't know how many ). If we do that we can handle this. What you say?
2. Session Management - Might not be an issue if we use AXWebBrowser or InternetBrowser to load the page and then retrieve the HTML Source.
I am writing a WebSpider kind of application, which will parse HTML source and try to download each link in the HTML page (n - level).
Thanks,
Anand
|
|
|
|
|
Anand Mudliar wrote:
How about using AXWebBrowser or InternetBrowser to load the page and then retrieve the HTML Source (IHTMLDocument2), since it is as good as loading it in browser.
If you are looking for a non-UI solution there is no need to include this as it packages more overhead that what you really need. See my response for more detail.
- Nick Parker My Blog | My Articles
|
|
|
|
|
One thing that I failed to mention in my original response is that I'm looking at the problem from the perspective of crawling a public zone, with numerous sites that you know nothing about. If instead you're writing a crawler to work against sites that you know the details of, such as an intranet... it becomes a much more doable task. I'm still writing with the assumption that you're looking to implement a public crawler.
Assuming that you aren't displaying the UI, using the HttpWebRequest , as Nick suggests, will accomplish the same thing as the AXWebBrowser and be a good deal lighter.
The problem with security is that there isn't a standard way for it to be handled for a public site. Nick's example will work fantastic if you're crawling a site that uses NT security with an IIS web server. As far as passing authentication details in cookies and/or posting them... the problem is that the details will differ from site to site. Different authors will handle the details in different ways. For example, one site may have a cookie that stores the username and password in a cookie, then checks them against a database. Another site may store a hashed version of the password. And so on... Sadly, if there is a way that you could reliably automate every possible implementation, I'm not aware of it.
As for the session management issues, as far as I can figure, you're going to run into the same problem as security. The HttpWebRequest object makes the same requests as the AXWebBrowser, so there isn't an issue there. The problem area is going to be the case where the server expects some kind of persisted (cookies, etc) or supplied (post, querystring) state-related information. Just like with authentication/security, the implementation from site to site will vary.
Two final things that I think are worth mentioning. If a site is protected by some authentication/security or session verification method, then there is a very good chance that the owner does not wish to be crawled by an automated spider. Also, be sure to adhere to the wishes of the robots.txt file when it comes to crawling.
Hope that helps.
--Jesse
|
|
|
|
|
That really helped
I am writing a spider for the sites where I have access, but I am not aware of the kind of authentication mechanism/sesion management they use. I tried using HttpWebRequest with credentials but I was runningg into problems of multiple redirection, operation timeout, underlying connection closed.
When I access the sites from the IE browser it works fine but with my crawler it fails
Thanks,
Anand
|
|
|
|
|
Ahhh... so I've basically been spouting off under a false assumption. Sorry about that.
The HttpWebRequest can do anything that the AXWebBrowser can, it just sometimes requires a bit more code. I would definately recommend using the HttpWebRequest , as the difference in performance and resource consumption is worth it, IMHO.
As far as the timeouts and closed connections, they're usually due to network or remote site issues. I would think your best bet would simply be to trap the exception and retry. The redirections are where some work comes in.
Assuming that you retrieve a HttpWebResponse object from the request by calling the GetResponse method, redirection will cause the ContentLength property of the response to be set to -1. By parsing out the headers of the response, you can determine where the redirection was to, and use your HttpWebRequest to query the redirection URI. You can reference the headers here[^]. Search for the "10.3 Redirection 3xx" section.
I had some code that followed redirection using the HttpWebRequest , but, unfortunately I can't seem to find it at the moment. If I can remember where the heck I put it, I'll post it in another reply.
Hope that helps.
--Jesse
|
|
|
|
|
Here is a quick example, you should be able to fit this into your codebase and it requires no UI.
public string GetPageContent(string user, string pass, string url)
{
WebRequest wreq;
WebResponse wres;
WebProxy proxy;
StreamReader sr;
String content = string.Empty;
try
{
proxy = new WebProxy("someproxy", false);
NetworkCredential cred = new NetworkCredential(user, pass,
"somedomain");
wreq = HttpWebRequest.Create(url);
wreq.Proxy = proxy;
proxy.Credentials = cred;
wres = wreq.GetResponse();
sr = new StreamReader(wres.GetResponseStream());
content = sr.ReadToEnd();
sr.Close();
}
catch(Exception e)
{
Console.WriteLine("Error:" + e.Message);
}
return content;
}
- Nick Parker My Blog | My Articles
|
|
|
|