Advertisement
Sk1llsT3R

Faking a Skype quote

May 1st, 2013
1,925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. Hello and welcome to this tutorial. This is an expansion on my other Skype quote tutorial, and this will show you how to generate a new one and put it correctly back onto your clipboard.
  2.  
  3. So, I have a project for checking the Clipboard contents, I will run through this first.
  4. [code]
  5. var dataObj = Clipboard.GetDataObject();
  6. var formats = dataObj.GetFormats();
  7. [/code]
  8.  
  9. Okay, so I set a break-point on formats, this is so we can get all formats which are being used at the current time. This is what we should get if we have a Skype quote on our clipboard.
  10. [img]http://i.imgur.com/rEutAkl.png[/img]
  11. Now we know the formats which are being used.
  12.  
  13. Now we would like to see what is stored in format (we are ignoring locale) Oh, and I'm using this quote:
  14.  
  15. "[18/02/2013 21:43:30] Konloch: (heart)"
  16. [img]http://i.imgur.com/KHNjvwz.png[/img]
  17.  
  18. [code]
  19. var sysString = dataObj.GetData("System.String");
  20. var unicode = dataObj.GetData("UnicodeText");
  21. var text = dataObj.GetData("Text");
  22. var oemText = dataObj.GetData("OEMText");
  23. var msgFragment = dataObj.GetData("SkypeMessageFragment") as MemoryStream;
  24. var msg = new StreamReader(msgFragment).ReadToEnd();
  25. [/code]
  26.  
  27. This is what each variable should equal to:
  28. [code]
  29. sysString = "[18/02/2013 21:43:30] Konloch: (heart)"
  30. unicode = "[18/02/2013 21:43:30] Konloch: (heart)"
  31. text = "[18/02/2013 21:43:30] Konloch: (heart)"
  32. oemText = "[18/02/2013 21:43:30] Konloch: (heart)"
  33. msg = "<quote author=\"konloch.me\" authorname=\"Konloch\" conversation=\"konloch.me\" guid=\"x5916e074bd00b8dc1491fd77ad6c4ef8151a6259a3b687313fc6e56b8116b377\" timestamp=\"1361223810\"><legacyquote>[18/02/2013 21:43:30] Konloch: </legacyquote>(heart)<legacyquote>\r\n\r\n&lt;&lt;&lt; </legacyquote></quote>"
  34. [/code]
  35.  
  36. Now we have what they're equal to we can manipulate the quote and create our own. Feel free to delete the code above now, we have all we need from it.
  37.  
  38. We're going to create a new DataObject with all of the types so we can set the clipboard data to it. We are also going to create a DateTime so we can change the time of the quote. I have left the custom part out of it, but you can just parse the values (hint).
  39. [code]
  40. DataObject dataObj = new DataObject();
  41. DateTime time = DateTime.UtcNow;
  42. [/code]
  43.  
  44. Now to set the quote up:
  45. [code]
  46. string msg = "This is a Konloch message";
  47. string msgInText = string.Format("[{0}] {1}: {2}", time.ToString("0:hh:mm:ss"), "konloch.me", msg);
  48. string msgInXml = string.Format("<quote author=\"{0}\" timestamp=\"{1}\">{2}</quote>", "konloch.me", time, msg);
  49.  
  50. dataObj.SetData("System.String", msgInText);
  51. dataObj.SetData("UnicodeText", msgInText);
  52. dataObj.SetData("Text", msgInText);
  53. dataObj.SetData("OEMText", msgInText);
  54. dataObj.SetData("SkypeMessageFragment", new MemoryStream(Encoding.UTF8.GetBytes(msgInXml)));
  55. Clipboard.SetDataObject(dataObj, true);
  56. [/code]
  57.  
  58. And what that does is set all of the data onto a DataObject and then puts it on the Clipboard.
  59.  
  60. Here is our result:
  61. [img]http://i.imgur.com/pNFJTLz.png[/img]
  62.  
  63. Thank you for reading, and post if this was useful
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement