コード例 #1
0
ファイル: KeyboardHook.cs プロジェクト: Tyelpion/IronAHK
		private System.Windows.Forms.Keys StringToWFKey(XEvent Event)
		{
			Dummy.Remove(0, Dummy.Length);
			Dummy.Append(" "); // HACK: Somehow necessary

			Event.KeyEvent.state = 16; // Repair any shifting applied by control

			if (Xlib.XLookupString(ref Event, Dummy, 10, IntPtr.Zero, IntPtr.Zero) != 0)
			{
				string Lookup = Dummy.ToString();

				if (Dummy.Length == 1 && char.IsLetterOrDigit(Dummy[0]))
					Lookup = Dummy[0].ToString().ToUpper();

				if (string.IsNullOrEmpty(Lookup.Trim())) return System.Windows.Forms.Keys.None;

				try
				{
					return (System.Windows.Forms.Keys) Enum.Parse(typeof(System.Windows.Forms.Keys), Lookup);
				}
				catch (ArgumentException)
				{
					// TODO
					Console.Error.WriteLine("Warning, could not look up key: " + Lookup);
					return System.Windows.Forms.Keys.None;
				}
			}
			else return System.Windows.Forms.Keys.None;
		}
コード例 #2
0
ファイル: Xlib.cs プロジェクト: 1j01/node-ahk
 public static extern int XLookupString(ref XEvent Key, StringBuilder Buffer, int Count, IntPtr KeySym, IntPtr Useless);
コード例 #3
0
ファイル: Xlib.cs プロジェクト: 1j01/node-ahk
 public static extern void XNextEvent(IntPtr Display, ref XEvent Event);
コード例 #4
0
ファイル: KeyboardHook.cs プロジェクト: Tyelpion/IronAHK
		private System.Windows.Forms.Keys TranslateKey(XEvent Event)
		{
			if (Mapping.ContainsKey(Event.KeyEvent.keycode))
				return Mapping[Event.KeyEvent.keycode];
			else return StringToWFKey(Event);
		}
コード例 #5
0
ファイル: KeyboardHook.cs プロジェクト: Tyelpion/IronAHK
#pragma warning disable 612, 618
		private void HandleXEvent(XEvent Event)
		{
			if (Event.type == XEventName.KeyPress || Event.type == XEventName.KeyRelease)
				KeyReceived(TranslateKey(Event), Event.type == XEventName.KeyPress);
		}
コード例 #6
0
ファイル: XConnection.cs プロジェクト: nrnoble/IronAHK
        private void FishEvent()
        {
            var Event = new XEvent();
            Xlib.XNextEvent(Display, ref Event);

            if(OnEvent != null)
                OnEvent(Event);

            if (Event.type == XEventName.CreateNotify)
            {
                int Window = Event.CreateWindowEvent.window;
                Success = true;

                Windows.Add(Window);

                SurpressErrors = true;
                if(Success)
                    RecurseTree(Display, Window);

                SurpressErrors = false;
            }
            else if(Event.type == XEventName.DestroyNotify)
            {
                Windows.Remove(Event.DestroyWindowEvent.window);
            }
        }