将鼠标移动锁定在目标非活动窗口中 [英] Lock Mouse Movement In the target inactive window

查看:88
本文介绍了将鼠标移动锁定在目标非活动窗口中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AutoIt在窗口上工作;)

目标:
假设我的目标窗口是Mozilla浏览器.我在该窗口上单击了一组坐标和填充物,然后在该窗口上工作了一组代码.但是我希望此窗口在我在另一个窗口上工作时最小化或处于非活动状态.我想在最小化的窗口中进行一系列的鼠标单击.

我在互联网上搜索了线索,并遇到了ControlClick(AutoIt),SendMessage,Postmessage,Mouse_Event等,但Postmessage,Mouse_Event没有窗口句柄的参数,该句柄可能仅适用于当前活动窗口,并且sendmessage或ControlClick(AutiIt)似乎可以即使我将我的坐标放置在x10 y10上,该坐标应在最小化窗口的左上角某处执行鼠标单击,结果仍将显示它确实单击了最小化窗口,但在协调我的鼠标指针所在的位置.

另外,我的目标窗口也不完全是mozilla,它的应用程序会弹出一个子窗口(无句柄"),并且即使该窗口已最小化,该窗口也会在您的鼠标指针下方弹出.
所以我发现自己在使用替代品.如果我可以获得以下任何解决方案,它将使其正常工作.

1.)如果我能找到一种方法来防止鼠标仅在目标窗口中移动,并允许其在可行的目标窗口之外自由移动.我可以使用捕鼠器将其捕获在中心,但是捕鼠器会将鼠标捕获在屏幕中.捕获是我不是那个创建目标窗口的人,所以我没有在其中放置代码的奢侈鼠标.

2.)如果我只能使用正确的坐标而不依赖于鼠标当前位置来获取Sendmessage WM_LBUTTONDOWN或UP .

有人可以给我提供一个简单的Windows API调用示例吗?先感谢您. ; P

Im working on a window using AutoIt ;)

Target :
Say for example my target window is a Mozilla Browser. I have a set of codes working on that window clicking sets of coordinates and stuffs.. but i want this window Minimized or inactive while im working on another window. I want to perform a series of mouse clicks to a minimized window.

I searched the internet for clues and came across ControlClick(AutoIt),SendMessage,Postmessage,Mouse_Event etc but Postmessage,Mouse_Event doesnt have an argument for a Window Handle which probably only works for the current active window and sendmessage or ControlClick(AutiIt) seems to be dependent still on the Current Mouse Position, even if i place my coordinates at x10 y10 which should perform a mouseclick somewhere to the upper left corner of the minimized window the result would still show it did click on the minimized window but did it on the coordinates where my mouse pointer is.

also , my target window is not exactly mozilla its an application that will pop up a child window ( Has no Handle ) and this window pops up underneath your mouse pointer, and even if the window is minimized.
so i find myself using alternatives. if i can get any of the following solutions that would make it work.

1.) If I can find a way to prevent the mouse from moving ONLY in the target window and allow it to move freely outside of the target window that would work. i can use Mousetrap to trap it in the center but mouse trap will trap the mouse in the screen.. the catch is i wasnt the one who made the target window so i haven''t got the luxury of placing codes in there to trap the mouse.

2.) if i can only get Sendmessage WM_LBUTTONDOWN or UP working with the right coordinates and not dependent on the mouse current position.

Can someone provide me with a simple standalone example of a windows API call that would do just that? thank you in advance. ;P

推荐答案

通过完全阻止鼠标,您可以锁定用户,使其无法输入所有窗口的输入.

您可以使用BlockInput来阻止所有输入(请谨慎操作).

http://msdn.microsoft.com/en-us/library/ms646290.aspx [ ^ ]

您可以使用下面的方法和一个简单的计时器来检查鼠标的位置,并在输入表单时重新定位它.每次都只需存储鼠标位置(仅当它在表单外部时),然后将其移动到该点,以防它进入表单.这样,您可以恢复"它的先前位置.

使用SendInput来控制鼠标(或键盘).
http://msdn.microsoft.com/en-us/library/ms646310.aspx [ ^ ]


使用GetAsyncKeyState可以随时获取鼠标/键盘状态.
http://msdn.microsoft.com/en-us/library/ms646293.aspx [ ^ ]

祝你好运!
By blocking the mouse completely you would lock the user from entering input to all windows.

You could use BlockInput to block all input (be carefull with this).

http://msdn.microsoft.com/en-us/library/ms646290.aspx[^]

You could use the methods below and a simple timer to check the mouse position and reposition it in case it enters your form. Simply store the mouse position each time (only if it is outside your form) and move it to that point in case it enters your form. This way you can ''restore'' it''s previous position.

Use SendInput to control the mouse (or keyboard).
http://msdn.microsoft.com/en-us/library/ms646310.aspx[^]


Use GetAsyncKeyState to get mouse/keyboard state at any time.
http://msdn.microsoft.com/en-us/library/ms646293.aspx[^]

Good luck!


这篇关于将鼠标移动锁定在目标非活动窗口中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆