15,895,746 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Trapper-Hell (Top 52 by date)
Trapper-Hell
19-Nov-13 10:22am
View
Thank you for the more informative response.
0. I didn't downvote, honestly. To prove it I'll just rate you a 4.
1. At first I couldn't understand the importance of the ^ $ sign because I was overly used to greedy-expressions (which evaluated as much of the text as possible).
2. That makes more sense. Thank you.
3. I don't intend to use that regular expression, I was just trying to understand why it was acting that slow.
Trapper-Hell
19-Nov-13 10:19am
View
Deleted
Thank you for the more informative response.
0. I didn't downvote, honestly. To prove it I'll just rate you a 3.
1. At first I couldn't understand the importance of the ^ $ sign because I was overly used to greedy-expressions (which evaluated as much of the text as possible).
2. That makes more sense. Thank you.
3. I don't intend to use that regular expression, I was just trying to understand why it was acting that slow.
Trapper-Hell
19-Nov-13 10:13am
View
Thank you for the link, it has been insightful :) But can you please attempt to answer the questions I posted? Specifically how does the parser try to evaluate the expression (such that it becomes so slow?)
Trapper-Hell
19-Nov-13 10:03am
View
Thank you for the reply. And yes I am aware that the ^ $ signs indicate that it must match from the beginning to the end. But why does the $ sign in the end turns the Regex from instantaneous to extremely slow?
And how will the Regex engine parse the Regex I pasted? (Consider the Questions section within my question). Thanks!
Trapper-Hell
28-Oct-13 6:42am
View
Deleted
If this has solved your question, kindly mark it as Accepted Answer, otherwise provide more detail so that we may be able to assist you further. Thanks.
Trapper-Hell
28-Oct-13 6:42am
View
If this has solved your question, kindly mark it as Accepted Answer, otherwise provide more detail so that we may be able to assist you further. Thanks.
Trapper-Hell
24-Oct-13 11:03am
View
Deleted
If this has solved your question, kindly mark it as Accepted Answer, otherwise provide more detail so that we may be able to assist you further. Thanks.
Trapper-Hell
24-Oct-13 11:02am
View
Deleted
If this has solved your question, kindly mark it as Accepted Answer, otherwise provide more detail so that we may be able to assist you further. Thanks.
Trapper-Hell
24-Oct-13 6:07am
View
Deleted
If this has solved your question, kindly mark it as Accepted Answer, otherwise provide more detail so that we may be able to assist you further. Thanks.
Trapper-Hell
24-Oct-13 3:38am
View
Deleted
If this has solved your question, kindly mark it as Accepted Answer, otherwise provide more detail so that we may be able to assist you further. Thanks.
Trapper-Hell
24-Oct-13 3:37am
View
Deleted
If this has solved your question, kindly mark it as Accepted Answer, otherwise provide more detail so that we may be able to assist you further. Thanks.
Trapper-Hell
23-Oct-13 11:27am
View
Deleted
If this has solved your question, kindly mark it as Accepted Answer, otherwise provide more detail so that we may be able to assist you further. Thanks.
Trapper-Hell
23-Oct-13 10:00am
View
Deleted
...
Trapper-Hell
23-Oct-13 7:13am
View
Deleted
If this has solved your question, kindly mark it as Accepted Solution, otherwise provide more detail so that we may be able to assist you further. Thanks.
Trapper-Hell
23-Oct-13 6:54am
View
Yes I am aware of that function. But how does that help me in loading the DLLs to the same assembly that I am about to load / or in such a way that the loaded assembly can access them?
Trapper-Hell
23-Oct-13 6:40am
View
Posting a screenshot link might help us identify the application responsible for this. However do not worry, this button is visible on your machine due to an application that you are using. If you distribute your application, that button should not be present on other machines :)
Trapper-Hell
23-Oct-13 6:38am
View
Deleted
Test Test Test
Trapper-Hell
23-Oct-13 6:36am
View
I am not too familiar with the CodeProject rules that may go against this, but there are many image hosting sites, such as TinyPic and many more. Upload to one of these and paste the link to the image...
Trapper-Hell
23-Oct-13 6:34am
View
Yeah a screenshot would definitely help. However I am thinking that this is not related to the form you are developing itself, but to a theme / application that is interfering / adjusting the form handle. Is the same button visible on other machines (if you can test it on other PCs)?
Trapper-Hell
15-Oct-13 10:08am
View
I know I could have searched, but I asked you to form a complete solution. That still didn't answer whether you consider that CPU-expensive or efficient. I have however taken the liberty to test it myself (with code I had found through a Google-search in the mean time) and yes it does appear to work well, even though I believe I'll have to take a couple of readings before determining whether CPU usage has really been reduced.
Nonetheless, I'm going to accept yourself for taking the time to reply, and for suggesting a relatively good idea.
Trapper-Hell
15-Oct-13 8:28am
View
You are correct. I meant to say user logon. My bad.
Can you provide any sample code for the CPU polling? And will the polling itself be expensive?
Trapper-Hell
2-Sep-13 18:58pm
View
I'm going to go head and assume that you don't know the rest - either because of my lack of description or idk. In any case, I guess you did a really good job in answering my original question (I guess) and providing sample code - thus you are awarded the accepted solution. Thanks.
Trapper-Hell
2-Sep-13 18:52pm
View
I am fully aware that this is not the best approach to pursue, but alas, there is not much choice given the circumstances. I was hoping for a more complete answer, since I may not have phrased it so well originally. If you have no idea as to how the rest of the bytes are becoming as such, you can simply say so. You already did a great job in explaining the rest - I was just wondering if you had any idea about this part of the mystery...
Trapper-Hell
2-Sep-13 18:08pm
View
I don't know if this is a flaw in the current implementation or not then, but as I understand the end functionality is well. What this is all about is getting a different type of key from a supplied key - so I really don't know if all this is coincidentally working or just intended, but I'm trying to achieve the same functionality (i.e. result-wise).
As I understand, k.W is able to contain 80 bytes is because the struct sha1_key is declared to contain an array of size 80. However as to how it is getting those values, I really don't know...
Trapper-Hell
2-Sep-13 13:58pm
View
Hi Philippe,
Thanks for your comment. To be honest, I have no idea why it's declared as unsigned long but filled with char instead. However it is performing the required results (even if internally if code-wise it wasn't created through the best approach. No point in fixing the C++ code now since the idea is to implement it in C#.
Trapper-Hell
2-Sep-13 10:17am
View
Yes I have. Basically the method (and the link you provided) seem to convert four bytes as a 32-bit unsigned integer.
And this works well for setting the value of k.W[0] = 875581507. This also works for k.W[3] getting value 128 from BitConverter.ToUint32(buffer, 12).
But what about k.W index 16+ ? What values are they getting?
- Worth noting, that when the buffer gets cast to type sha1_key, the 'k.W' unsigned long array is 80 elements long.
Trapper-Hell
2-Sep-13 10:16am
View
Deleted
Yes I have. Basically the method (and the link you provided) seem to convert four bytes as a 32-bit unsigned integer.
And this works well for setting the value of k.W[0] = 875581507, but then, how did k.W[3] get the value of 128? And what about k.W index 16+ ? What values are they getting?
Trapper-Hell
2-Sep-13 9:50am
View
Wow! Thanks pwasser. As for the 1st element, it works exactly as I wanted it to!
But what has happened to the rest of the elements in the array? For example buffer[3] = '4' (byte 52), but k.W[3] = 128 etc.
Trapper-Hell
2-Sep-13 9:20am
View
I'm trying to port the original C++ code to C#. The code shown in my question is mostly in C++ (only after the Edit: tag is my C# code).
The answer helps answer one of my queries, but I think it is not sufficient for me to solve the problem I'm encountering.
Thanks for pointing out that in C# chars are Unicode, but what changes shall I make then to match the C++ functionality?
Trapper-Hell
2-Sep-13 9:17am
View
Deleted
Edit: Included my C# equivalent code (so far).
Trapper-Hell
2-Sep-13 8:50am
View
Thank you for your prompt response!
So this means that the 0th element contains the original chars appended (as hex)? What about the rest of the elements?
How can I achieve something similar in C# ?
I have edited my question to reflect my C# code so far.
Thanks :)
Trapper-Hell
7-Feb-13 3:14am
View
Great insight and descriptive answer. Also thanks for your thoughts about how the textbox might actually work, and for suggesting FCL.
Trapper-Hell
5-Feb-13 3:51am
View
Researching on what you have said, I can create a custom Textbox (inheriting the base Textbox) and be able to handle the WndProc events then. So yes, that definitely does answer the question.
If you would like, for the sake of being thorough, can you kindly provide more insight on which P/Invoke entry points to use through the alternative methods mentioned - and how the GetMessage / DispatchMessage differs from the the WndProc message?
I will accept your solution though for the time taken on this issue and the thoroughness in your answers. Thank you so much :)
Trapper-Hell
4-Feb-13 5:27am
View
The reason why I want to handle the key events through the WndProc is to get the Scan Codes and Virtual Key codes, and it seems to be far more practical to retrieve those values through the WndProc. However, ideally I would be able to display the characters being typed anyway (besides tracking their scan & virtual key codes).
If you come up with any idea on how this can be established let me know. I am however willing to accept your answer as the solution.
Trapper-Hell
4-Feb-13 3:41am
View
Correct! I removed the textbox and the WndProc started working correctly (showing the 'Test' message box).
I have then re-inserted the textbox and enabled the form's KeyPreview property, however it is still not capturing the keys in the WndProc. Is there a way to capture the keys in WndProc while having the textbox focused?
Thanks a lot!
Trapper-Hell
4-Feb-13 3:01am
View
I updated the question to include the complete code of the class (form). There is nothing much to it really, since it's just meant as a simple test. I will use your application, since it seems really useful, but for now I'm just trying to understand why the WndProc is never having a Msg equal to the set of integers I defined.
Thanks
Trapper-Hell
3-Feb-13 15:11pm
View
Your project seems really detailed and should also prove to be helpful for my application. However, can you kindly point out what I have done wrong or why this is not working? Thanks
Trapper-Hell
30-Jan-13 4:03am
View
If you had told me earlier that you do not have enough information I would have gladly provided you with more.
Simply create a stub that calls the SendInput method through P/Invoke and supply Scan Code: 43 Virtual Key Code: 222. On EN-UK it should display # while on EN-US it would probably display \.
Thanks,
Trapper-Hell
30-Jan-13 3:13am
View
Good morning,
Thank you for the time you have taken on this matter. And I am glad that you understand the nature of my problem, and have accepted it as a problem - rather than an abuse of UI. However I do not think this has actually solved my problem, since I am still none-the-wiser on how I can remedy this problem.
What kind of "keyboard replacement" can we use? The use of a virtual / on-screen keyboard would not be acceptable due to its lack of constant usability.
Thanks,
Trapper-Hell
29-Jan-13 18:28pm
View
I'm glad you understand my point, and yes you mention some valid points about the keyboard layouts and keyboard states. Let us assume that I am able to set both keyboard states as identical (ensuring that Caps Lock is off on both computers and Num Lock is on on both etc etc) and that these won't change while the process is running, how can I go about ensuring that the output on the remote computer is the same as the character input on the local computer? (Even if the keyboard layouts are different). I can set the remote keyboard layout the same as the local keyboard layout, but I was hoping for a less dirty approach.
Another idea that during startup, the server simulates some key codes (and determines the actual output character) and then sends these results to the client so that it may be able to perform some mapping of these key codes to its key codes that can match the original output characters). So, for example if the server was able to generate # with Virtual Key Code 222, the Client also generates a number of Virtual Key Codes and checks which one of those was able to produce #, so that it may then interpret the 222 Virtual Key Code as necessary for it to produce #. (I hope I have been able to explain myself well - although this feels like overkill).
[P.S. I am going to sleep, so I will see your response first thing in the morning, and reply accordingly]
Thanks and good night.
Trapper-Hell
29-Jan-13 18:01pm
View
Maybe I did not explain myself well enough or maybe SendInput is not the way to go.
Imagine this, you are using this application I made to remote-control another computer. Now you are pressing keys on your computer (through this application) so that these are then sent to the remote computer (and another application running remotely) which is able to simulate these key presses.
Therefore if I was to press "This is a test", I would see "This is a test" on the remote computer. This works fine. The problem is with certain keys that vary according to keyboard layouts / regions, such that if I were to type "C# is great!", it would appear as "C\ is great!" on the remote computer. This is not a chat application, so I do not want to send strings, I want to send commands so that these keys are then simulated on the remote computer to emulate the actual keys / characters.
Trapper-Hell
29-Jan-13 17:47pm
View
Dear Sergey,
That's actually what I'm using at the moment. I had used the SendKeys method in C# earlier, however this sample app I am using to monitor the keys being pressed and simulate them again uses the SendInput entry point in the user32.dll and I have tried passing in both the captured Scan Codes and Virtual Key Codes / the Scan Code only / the Virtual Key Code only, but the resultant character being displayed is not the original character. The demonstration I have mentioned above of the # and the / characters were simulated using the SendInput method.
Thank you for the note with regards to P/Invoke and APIs being platform-specific, but I have no problems running this on Windows only. Ideally I could do without having to use P/Invokes and stuff, but if that's the way to do it, so be it. I just want the pressed characters to appear exactly as pressed on the remote computer.
Thanks again.
Trapper-Hell
3-Dec-12 9:18am
View
That totally passed me - I can't get used to it yet. *Feels dumb* Sorry and thanks for all the support :)
Trapper-Hell
3-Dec-12 8:38am
View
XmlDocument doc = new XmlDocument();
doc.Load("C:\\\\xml.xml");
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("x", "urn:schemas-upnp-org:device-1-0");
string deviceType = doc.DocumentElement.SelectSingleNode("./x:device/x:deviceType", nsmgr).InnerText;
int deviceCounter = doc.DocumentElement.SelectNodes("./x:device//x:deviceType").Count;
That's the code I'm using the XML I submitted. It throws an XPath Exception with the following message: "Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function."
Trapper-Hell
3-Dec-12 8:15am
View
Sorry to be bothering you again, but I tried the following code:
int deviceCounter = doc.DocumentElement.SelectNodes("./x:device//x:deviceType").Count;
However that gives an XPathException. What am I doing wrong here?
Trapper-Hell
3-Dec-12 8:09am
View
That about sums it all up :) Thank you for your time!
Trapper-Hell
3-Dec-12 6:50am
View
Great observation! I wrote the end tags myself since the true XML was too long, and I just extracted the important aspects of it. Please ignore the erroneous tag in the end (I revised it in the original post).
With regards to your proposed solution, it worked :D So I'm quite glad! Before I accept the solution, can you kindly explain why you had to add the namespace (and its importance)?
And finally, there are other <deviceType> tags that are children of other tags (under some branch under the <service> tag). Is it possible that I search for all <deviceType> tags irrelevant of their position within the document?
Trapper-Hell
3-Dec-12 4:56am
View
Can you possibly try the provided sample XML yourself to see if you can extract the text?
Trapper-Hell
3-Dec-12 4:47am
View
I am not getting any errors on the lines posted. It all seems to work fine, however the node variable remains null. So if I were to add a line like this afterwards:
string extension = node.ChildNodes[0].InnerText;
I'd get a NullReferenceExecption since the node variable remains null.
Trapper-Hell
3-Dec-12 4:44am
View
I did place a breakpoint to go through the process but I'm not sure what I'm supposed to notice.
The code thus far is fairly simple:
------------
XmlDocument doc = new XmlDocument();
doc.Load("C:\\\\IGD.xml");
XmlNode node = doc.SelectSingleNode("deviceType");
------------
After going over the third line, the node variable remains null. I've tested that the doc is loaded fine and it would seem so, but it cannot select the tag. Could it be because the first line of the XML is non-standard XML ?
Trapper-Hell
3-Dec-12 4:43am
View
Deleted
I did place a breakpoint to go through the process but I'm not sure what I'm supposed to notice.
The code thus far is fairly simple:
<pre lang="c#">XmlDocument doc = new XmlDocument();
doc.Load("C:\\\\IGD.xml");
XmlNode node = doc.SelectSingleNode("deviceType");</pre>
After going over the third line, the node variable remains null. I've tested that the doc is loaded fine and it would seem so, but it cannot select the tag. Could it be because the first line of the XML is non-standard XML ?
Trapper-Hell
3-Dec-12 4:04am
View
I'd have preferred a more tailored solution rather than a link, however I have considered the submitted link and tried the following line of code:
XmlNode node = doc.SelectSingleNode("deviceType");
However the node variable is null.
Show More