public static System.Drawing.Point GetCursorLocation() { POINTAPI pnt = new POINTAPI(); GetCursorPos(ref pnt); return(new System.Drawing.Point(pnt.x, pnt.y)); }
public static Point GetCursorLocation() { POINTAPI pnt = new POINTAPI(); GetCursorPos(ref pnt); return(new Point(pnt.x, pnt.y)); }
public static RECTAPI calClientToScreen() { RECTAPI ClientRectHwnd = new RECTAPI(); //下面代码限制鼠标在窗口 //RECTAPI rectHwnd = new RECTAPI(); //bool resultWindowRect = GameLogicAPI.GetWindowRect(m_WindowHwnd, ref rectHwnd); //下面代码限制鼠标在窗口客户区 bool resultGetClientRect = GameLogicAPI.GetClientRect(Initialize.m_WindowHwnd, out ClientRectHwnd); //编辑器下要减去顶部工具栏高度 #if !UNITY_STANDALONE_WIN ClientRectHwnd.top += 24; #endif POINTAPI pointCTS = new POINTAPI(); pointCTS.x = ClientRectHwnd.left; pointCTS.y = ClientRectHwnd.top; bool resultCTS = GameLogicAPI.ClientToScreen(Initialize.m_WindowHwnd, ref pointCTS); ClientRectHwnd.left = pointCTS.x; ClientRectHwnd.top = pointCTS.y; pointCTS.x = ClientRectHwnd.right - 1; pointCTS.y = ClientRectHwnd.bottom - 1; resultCTS = GameLogicAPI.ClientToScreen(Initialize.m_WindowHwnd, ref pointCTS); ClientRectHwnd.right = pointCTS.x; ClientRectHwnd.bottom = pointCTS.y; return(ClientRectHwnd); }
static public int get_handle() { POINTAPI point = new POINTAPI();//必须用与之相兼容的结构体,类也可以 //add some wait time GetCursorPos(ref point); //获取当前鼠标坐标 int hwnd = WindowFromPoint(point.X, point.Y); //获取指定坐标处窗口的句柄 //StringBuilder window_name = new StringBuilder(256); //StringBuilder handle_name = new StringBuilder(256); //MessageBox.Show(hwnd.ToString()); //GetWindowText(hwnd, window_name, 256); //MessageBox.Show(name.ToString()); //GetClassName(hwnd, handle_name, 256); //MessageBox.Show(name.ToString()); //string[] s = { handle_name.ToString(), window_name.ToString() }; Rect rect = new Rect(); GetWindowRect(new IntPtr(hwnd), out rect); Store.w_left = rect.Left; Store.w_right = rect.Right; Store.w_top = rect.Top; Store.w_bottom = rect.Bottom; return(hwnd); }
public static void GetSmartInfo(ref int wHdl, ref StringBuilder clsName, ref StringBuilder wndText) { POINTAPI pnt = new POINTAPI(); GetCursorPos(ref pnt); wHdl = WindowFromPoint(pnt.x, pnt.y); GetClassName(wHdl, clsName, 128); GetWindowText(wHdl, wndText, 128); }
public static void TryParse(String parseit, out POINTAPI result) { //format: (X,Y) //strip out parens. String[] parsed = parseit.Replace("(", "").Replace(")", "").Split(new char[] { ',' }); int kx = int.Parse(parsed[0]); int ky = int.Parse(parsed[1]); result = new POINTAPI(kx, ky); }
private void MoveMousePosition(Vector offsetDelta) { POINTAPI point = new POINTAPI(); if (GetCursorPos(ref point)) { point.X += (int)offsetDelta.X; point.Y += (int)offsetDelta.Y; SetCursorPos(point.X, point.Y); } }
public static int getWinUnderMouse() { POINTAPI point = new POINTAPI(); //必须用与之相兼容的结构体,类也可以 GetCursorPos(ref point); //获取当前鼠标坐标 int hwnd = WindowFromPoint(point.X, point.Y); //获取指定坐标处窗口的句柄 Console.Out.WriteLine(" hwnd=" + hwnd.ToString()); return(hwnd); //this.label1.Text = point.X.ToString() + ":" + point.Y.ToString() + "-" + hwnd.ToString();//显示效果,此时窗口已经嵌入桌面了 }
private static Color GetColorByMousePos() { POINTAPI pos = new POINTAPI(); GetCursorPos(ref pos); int dc = GetDC(0); int intColor = GetPixel(dc, pos.x, pos.y); int b = intColor / (256 * 256); int g = (intColor - b * 256 * 256) / 256; int r = (intColor - b * 256 * 256 - g * 256); return(Color.FromArgb(r, g, b)); }
// Add either new record or increment existing record counter public void AddClipBoardRecord(string content) { POINTAPI point = new POINTAPI(); // 必须用与之相兼容的结构体,类也可以 Thread.Sleep(8000); //add some wait time GetCursorPos(ref point); // 获取当前鼠标坐标 int handle = WindowFromPoint(point.X, point.Y); // 获取指定坐标处窗口的句柄 // Record the resource from the acitivated window title StringBuilder rsc = new StringBuilder(256); // int handle = GetForegroundWindow(); GetWindowText(handle, rsc, 256); string resource = rsc.ToString(); // MessageBox.Show(name.ToString()); Log.Verbose().Write("Add content to clipboard."); ClipBoardRecord rec; //accept content only of not empty and not too big if (content.Length != 0 && content.Length < _maxCopyTextLength) { rec = GetClipBoardRecordViaContent(content); if (rec == null) // this is a new content { // add a new record to the list rec = new ClipBoardRecord(content, resource, 1, 0); _recentItems.Insert(0, rec); } else { // increment the existing matching record rec.CoppiedCount++; } //limit number of recent items if (_recentItems.Count > 25) { Log.Debug().Write("Recent items exceeded max size. Remove last item."); _recentItems.RemoveAt(_recentItems.Count - 1); } } else { Log.Warn().Write("Content emtpy or longer than defined max length."); } }
public static void TryParse(String parsestr, out RECT result) { //strip out braces... parsestr = parsestr.Replace("{", "").Replace("}", ""); //split at ")-("... String[] Pointstrings = parsestr.Split(new string[] { ")-(" }, StringSplitOptions.RemoveEmptyEntries); POINTAPI firstpoint, secondpoint; //parse the resulting values. re-add the parens that were removed by the split. POINTAPI.TryParse(Pointstrings[0] + ")", out firstpoint); POINTAPI.TryParse("(" + Pointstrings[1], out secondpoint); result = new RECT(firstpoint.y, firstpoint.y, secondpoint.x, secondpoint.y); }
public void ShowOneElement() { Thread.Sleep(3000); POINTAPI point = new POINTAPI(); WinAPI.GetCursorPos(ref point); this.ShowElementText.Text = string.Format("X:{0},Y:{1}\n", point.X.ToString(), point.Y.ToString()); IntPtr intPtr = WinAPI.WindowFromPoint(point.X, point.Y); AutomationElement startElement = AutomationElement.FromHandle(intPtr); List <UIAutomationElement> list = FindElement.GetElementList(startElement, point.X, point.Y); for (int i = 0; i < list.Count; i++) { AppendText(list[i], i); } }
private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { POINTAPI point = new POINTAPI();//必须用与之相兼容的结构体,类也可以 //add some wait time //System.Threading.Thread.Sleep(8000); GetCursorPos(ref point); //获取当前鼠标坐标 int hwnd = WindowFromPoint(point.X, point.Y); //获取指定坐标处窗口的句柄 this.Dispatcher.Invoke(() => { AddNewWindow(new IntPtr(hwnd)); sview.ScrollToEnd(); }); }
static public int get_handle() { POINTAPI point = new POINTAPI();//必须用与之相兼容的结构体,类也可以 //add some wait time GetCursorPos(ref point); //获取当前鼠标坐标 int hwnd = WindowFromPoint(point.X, point.Y); //获取指定坐标处窗口的句柄 //StringBuilder window_name = new StringBuilder(256); //StringBuilder handle_name = new StringBuilder(256); //MessageBox.Show(hwnd.ToString()); //GetWindowText(hwnd, window_name, 256); //MessageBox.Show(name.ToString()); //GetClassName(hwnd, handle_name, 256); //MessageBox.Show(name.ToString()); //string[] s = { handle_name.ToString(), window_name.ToString() }; return(hwnd); }
/// <summary> /// 左键 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { var point = e.GetPosition(this); var p = PointToScreen(point); Hide(); var pp = new POINTAPI(); pp.X = (int)p.X; pp.Y = (int)p.Y; var w = WindowFromPoint(pp); if (w != null) { action?.Invoke(true, w); } else { action?.Invoke(true, IntPtr.Zero); } Close(); }
internal static extern int SendMessagePoint(IntPtr handle, Messages msg, int wParam, ref POINTAPI point);
internal static extern int GetCaretPos(out POINTAPI point);
public static extern int ClientToScreen(IntPtr hwnd, [MarshalAs(UnmanagedType.Struct)] ref POINTAPI lpPoint);
static extern int GetCursorPos(out POINTAPI papi);
public static extern int MapWindowPoints(IntPtr hwndFrom, IntPtr hwndTo, ref POINTAPI lppt, int cPoints);
public static extern bool GetCursorPos([In] ref POINTAPI pos);
public static extern int GetCursorPos(ref POINTAPI lpPoint);
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { // 드래그 if (m_bOnMove) { POINTAPI cursorPos = new POINTAPI(); GetCursorPos(ref cursorPos); this.Location = new Point(cursorPos.x - m_pathPos.x, cursorPos.y - m_pathPos.y); } }
private static extern int ImageList_GetDragImage( ref POINTAPI ppt, ref POINTAPI pptHotspot);
public static extern int GetCursorPos([MarshalAs(UnmanagedType.Struct)] ref POINTAPI lpPoint);
public extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINTAPI pptDst, ref ST_SIZE psize, IntPtr hdcSrc, ref POINTAPI pptSrc, uint crKey, [In] ref BLENDFUNCTION pblend, int dwFlags);
private static extern IntPtr WindowFromPoint(POINTAPI Point);
public static extern bool ClientToScreen(IntPtr hWnd, ref POINTAPI lpPoint);
public static extern bool GetWindowOrgEx(IntPtr hdc, out POINTAPI lpPoint);
public static extern int ClientToScreen(IntPtr hWnd, ref POINTAPI lpPoint);
public static extern IntPtr WindowFromPoint(POINTAPI point);
public static void TryParse(String parseit, out POINTAPI result) { //format: (X,Y) //strip out parens. String[] parsed = parseit.Replace("(", "").Replace(")", "").Split(new char[] {','}); int kx = int.Parse(parsed[0]); int ky = int.Parse(parsed[1]); result = new POINTAPI(kx, ky); }
private static extern int GetDCOrgEx(IntPtr hdc, out POINTAPI lpPoint);
[DllImport("user32.dll", EntryPoint = "GetCursorPos")]//获取鼠标坐标 public static extern int GetCursorPos( ref POINTAPI lpPoint );
public Dictionary <string, List <ClipBoardRecord> > LoadFromFile(string FileName) { char[] delimiterChars = { ',' }; string[] fileFields; string[] lines = File.Exists(FileName) ? File.ReadAllLines(FileName) : new string[] { }; string type; List <ClipBoardRecord> savedItems = new List <ClipBoardRecord>(); List <ClipBoardRecord> recentItems = new List <ClipBoardRecord>(); POINTAPI point = new POINTAPI(); // 必须用与之相兼容的结构体,类也可以 Thread.Sleep(8000); //add some wait time GetCursorPos(ref point); // 获取当前鼠标坐标 int handle = WindowFromPoint(point.X, point.Y); // 获取指定坐标处窗口的句柄 foreach (string s in lines) { // Record the resource from the acitivated window title ClipBoardRecord rec = new ClipBoardRecord(); StringBuilder name = new StringBuilder(256); // int handle = GetForegroundWindow(); GetWindowText(handle, name, 256); // MessageBox.Show(name.ToString()); // Find out if we have a saved file containing counts if (s.StartsWith("|")) // then new file format { fileFields = s.Split(delimiterChars, 5); rec.CoppiedCount = int.Parse(fileFields[1]); rec.PastedCount = int.Parse(fileFields[2]); rec.Content = Regex.Unescape(fileFields[3].Substring(7)); rec.Resource = Regex.Unescape(fileFields[4].Substring(5)); type = fileFields[3].Substring(0, 7); } else // handle previous file format { rec.Content = Regex.Unescape(s.Substring(7)); rec.Resource = Regex.Unescape(s.Substring(5)); rec.CoppiedCount = 0; rec.PastedCount = 0; type = s.Substring(0, 7); } // now have have the data add it to the relevent list if (type.StartsWith("saved:")) { savedItems.Add(rec); } else if (type.StartsWith("recent:")) { recentItems.Add(rec); } } var items = new Dictionary <string, List <ClipBoardRecord> >(); items.Add("saved", savedItems); items.Add("recent", recentItems); return(items); }
private static extern int GetCursorPos( ref POINTAPI lpPoint );
public static extern int ScreenToClient(int hwnd, ref POINTAPI lpPoint);
public static extern int PtInRect( ref RECT lpRect, ref POINTAPI pt );