Jibrohni
Avatar/Signature-
Posts
28 -
Joined
-
Last visited
About Jibrohni
- Birthday 08/08/1982
Jibrohni's Achievements
Newbie (1/14)
0
Reputation
-
SOLVED: var Index = from LinkIcon in xmlDoc.Descendants("LinkIcon") where (string)LinkIcon.Parent.Attribute("ID").Value == item.LinkID.ToString() select LinkIcon.Attribute("Index").Value; item.IconIndex = Index.First<string>(); var Path = from LinkCollection in xmlDoc.Descendants("LinkIcon") where (string)LinkCollection.Parent.Attribute("ID").Value == item.LinkID.ToString() select LinkCollection.Attribute("Path").Value; item.IconPath = Path.First<string>();
-
Hi all, I'm trying to retrieve some specific data from an XML file I have attached. The data is in <LinkCollection> I have a semi populated class object that contains an ID that directly relates to the LinkItem ID. Matching these values I then want to populate the rest of the class with the other data - Path, Index and any DescriptiveText held under that ID. My attempt is here but I'm returning dodgy string values and getting nowhere slowly. //gets icon path and index foreach (LinkItem item in linkItems) { var Index = from LinkIcon in xmlDoc.Descendants("LinkIcon") where (string)LinkIcon.Parent.Attribute("ID") == item.LinkID select LinkIcon.Attribute("Index").Value; item.IconIndex = Index.ToString(); var Path = from LinkCollection in xmlDoc.Descendants("LinkItem") where LinkCollection.Attribute("ID").Value == item.LinkID select LinkCollection.Descendants("LinkIcon").Attributes("Path"); item.IconPath = Path.ToString(); } example.txt
-
Good day one and all, Apologies if I'm not in the most suitable topic area for this. Can someone tell me why I'm getting a bad data error when I try using this decryption method? The encryption part works fine, but when decrypting the file I get the error: CryptographicExcpetion was unhandled Bad Data on the line fsDecrypted.Write(sr.ReadToEnd()) please see the code I'm trying to use: /// <summary> /// Encrypts a file - Not implemented /// </summary> /// <param name="sInputFilename">File to encrypt</param> /// <param name="sOutputFilename">Encrypted file name</param> /// <param name="sKey">Encryption Key</param> private void EncryptFile(string sInputFilename, string sOutputFilename, string sKey) { FileStream fsInput = new FileStream(sInputFilename, FileMode.Open, FileAccess.Read); FileStream fsEncrypted = new FileStream(sOutputFilename, FileMode.Create, FileAccess.Write); DESCryptoServiceProvider DES = new DESCryptoServiceProvider(); DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey); DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey); ICryptoTransform desencrypt = DES.CreateEncryptor(); CryptoStream cryptostream = new CryptoStream(fsEncrypted, desencrypt, CryptoStreamMode.Write); byte[] bytearrayinput = new byte[fsInput.Length - 1]; fsInput.Read(bytearrayinput, 0, bytearrayinput.Length); cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length); fsEncrypted.Close(); } /// <summary> /// Decrypts a file - Not implemented /// </summary> /// <param name="sInputFilename">File to decrypt</param> /// <param name="sOutputFilename">Decrypted file name</param> /// <param name="sKey">Decryption Key</param> static void DecryptFile(string sInputFilename, string sOutputFilename, string sKey) { DESCryptoServiceProvider DES = new DESCryptoServiceProvider(); //A 64 bit key and IV is required for this provider. //Set secret key For DES algorithm. DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey); //Set initialization vector. DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey); //Create a file stream to read the encrypted file back. FileStream fsread = new FileStream(sInputFilename, FileMode.Open, FileAccess.Read); //Create a DES decryptor from the DES instance. ICryptoTransform desdecrypt = DES.CreateDecryptor(); //Create crypto stream set to read and do a //DES decryption transform on incoming bytes. CryptoStream cryptostreamDecr = new CryptoStream(fsread, desdecrypt, CryptoStreamMode.Read); StreamReader sr = new StreamReader(cryptostreamDecr); //Print the contents of the decrypted file. StreamWriter fsDecrypted = new StreamWriter(sOutputFilename); fsDecrypted.Write(sr.ReadToEnd()); fsDecrypted.Flush(); fsDecrypted.Close(); } I'm using the same key for both "m43%gj&^", and the fact that it encrypts suggests that that is fine to use. Thanks in advance for your time. Jib
-
Well to be honest the actual target application is likely to change a lot more than Calc, so it will be a life's work once I get to that point. I'll be running it on my computer to start with, so there will be less variables, however I hope to run it elsewhere eventually. I just want to take a robust approach that requires as few alterations to the code as possible really.
-
Hmm, perhaps Calc isn't the best starter project. I'm using Windows Detective and it's results are somewhat irregular. Sometimes the buttons appear with WindowText such as "2", other times they contain nothing. I'm automating an application and need to reproduce mouse clicks and text entries. I can do this by taking a screen dump and mapping out the button positions dependant on a pre-known pixel set. I thought the window-handle approach might be a little more robust though..?
-
Anyone?
-
Hey all, I'm trying to use FindWindowEx() to get a handle to the Calculator buttons. I'm using this code to drill down through the levels, which works fine until I get to the button level: hwndFrame = FindWindowEx((IntPtr)hwnd, IntPtr.Zero, "CalcFrame", ""); hwndDialog = FindWindowEx(hwndFrame, IntPtr.Zero, "#32770", ""); hwndButton = FindWindowEx(hwndDialog, IntPtr.Zero, "Button", "2"); The top two lines populate the handles just fine, but the third does not. Anyone got a clue as to why it's returning nothing for the button handle? I'm using Window Detective to obtain the UI information and it lists "Button" as the class type, however it doesn't list anything for WindowTitle. I've tried it with "" and "2". I've seen "2" in a supposedly working example on the net. My declaration is: [DllImport("user32.dll", SetLastError = true)] public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle); Help, thanks. Jib.
-
Indeed it does - thank you. Slowly getting the hang of this...
-
Hey there, I'm using API's to get the handle to a specific button in an external app. How can I derive the screen position of this child window in order to direct a send click there? Thanks, Jib.
-
Hi all, I'm hoping someone can point me in the direction of a good place to start learning about API calls using C#. I want to work towards obtaining handles to external programs and retrieving various bits of information. Ideally I want to be able to watch a window and act everytime a WM_PAINT message is triggered. I'm just finding it a tough topic for a beginner to understand with all the complex looking parameters and all. Any good advice is welcomed. Jib.
-
That's what I was doing before - but the change frequency of my seed value was lower than my random number iteration frequency - therefore it was repeating the same deck of cards 5 or 6 times before the seed value had a chance to change. Using the high resolution timer meant that the seed value I was using was changing much more rapidly, beating the next iteration of my algorithm, and thus providing a completely new random deck. Basically the tick rate was moving at a slower pace than my iterating algorithm.
-
Ok guys, so I've managed to solve the problem by incorporating a high performance/high resolution timer. I used the class at the destination below: http://www.codeproject.com/KB/cs/highperformancetimercshar.aspx I then took the .Duration value after starting the timer and used a Right function to take the 7 digits (the farthest right being the numbers changing most frequently). I then used these as my seed value. HiPerfTimer ht = new HiPerfTimer(); ht.Start(); Random rnd = new Random(Convert.ToInt32(Right(ht.Duration.ToString(),7))); I hope this helps others out. Thanks again!