Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.IO;
  5. using System.Runtime.InteropServices;
  6. using System.Windows.Forms;
  7.  
  8. namespace LoLMacros{
  9.  
  10.     static class Smiley{
  11.  
  12.         private readonly static Dictionary<int, Image> smileys = new Dictionary<int, Image>();
  13.         private readonly static String BASE_FILE_PATH = ".\\";//"..\\..\\smileys\\";
  14.  
  15.         [STAThread]
  16.         static void Main(string[] args){
  17.             using(StreamReader sr = new StreamReader(BASE_FILE_PATH + "smileys.txt")){
  18.                 String line;
  19.                 while ((line = sr.ReadLine()) != null){
  20.                     String[] parts = line.Split(",".ToCharArray());
  21.                     int keyCode = Convert.ToInt32(parts[0]);
  22.                     String filePath = parts[1];
  23.                     AddSmiley(keyCode, filePath);
  24.                 }
  25.             }
  26.             while(true){
  27.                 if (IsKeyPressed(110))
  28.                 {
  29.                     SendKeys.SendWait("{BACKSPACE}");
  30.                     Environment.Exit(0);
  31.                 }
  32.                 foreach(KeyValuePair<int, Image> smiley in smileys){
  33.                     if(IsKeyPressed(smiley.Key)){
  34.                         PasteSmiley(smiley.Value);
  35.                     }
  36.                 }
  37.             }
  38.         }
  39.  
  40.         private static void AddSmiley(int keyCode, String filePath){
  41.             smileys.Add(keyCode, Image.FromFile(BASE_FILE_PATH + filePath));
  42.         }
  43.  
  44.         private static bool IsKeyPressed(int keyCode){
  45.             return (GetAsyncKeyState(keyCode) == -32767);
  46.         }
  47.  
  48.         [DllImport("User32.dll")]
  49.         private static extern short GetAsyncKeyState(int vKey);
  50.  
  51.         private static void PasteSmiley(Image image){
  52.             Clipboard.SetImage(image);
  53.             SendKeys.SendWait("{BACKSPACE}");
  54.             SendKeys.SendWait("^{v}");
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement