D 1.0 (Tango) 移动鼠标;模拟键盘按下等
嘿,我正在使用 D 1.041 和 Tango 0.99.8,我想知道我将如何移动鼠标并模拟键盘按下并从屏幕获取信息,例如特定坐标上特定像素的颜色。我正在使用 Windows。
任何帮助将不胜感激。我想编写一个基于类的库,其功能类似于 AutoIt。例如:
mouse.move(100, 200);
mouse.click(2); // 2 = Middle Mouse Click
keyboard.type('abc');
import tango.sys.win32.UserGdi;
class Mouse{
alias SetCursorPos set_pos;
alias GetCursorPos get_pos;
void left_click(){
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0);
}
void right_click(){
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0);
}
}
这段代码给我以下错误:
错误 42:符号未定义 _mouse_event@16 --- 错误级别 1
有什么帮助吗?我仍在使用版本。
Hey, I'm using D 1.041 with Tango 0.99.8 and was wondering how I would go about moving the mouse and simulating keyboard presses and getting infos from the screen, for example the color of a specific pixel on a specific coordinate. I'm using Windows.
Any help would be greatly appreciated. I want to program a class-based library with functionality that resembles AutoIt's. For example:
mouse.move(100, 200);
mouse.click(2); // 2 = Middle Mouse Click
keyboard.type('abc');
import tango.sys.win32.UserGdi;
class Mouse{
alias SetCursorPos set_pos;
alias GetCursorPos get_pos;
void left_click(){
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0);
}
void right_click(){
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0);
}
}
This code gives me the following error:
Error 42: Symbol Undefined
_mouse_event@16
--- errorlevel 1
Any help on that? I'm still using version.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 Tango 中的一个错误。
Tango 将 mouse_event 声明为:
而 MSDN 显示它需要 5 个参数,而不是 4 个。
对于严肃的 Win32 开发,您应该查看 Windows API 绑定 项目。
This is a bug in Tango.
Tango declares mouse_event as:
while MSDN shows that it takes 5 parameters, not 4.
For serious Win32 development you should take a look at the Windows API bindings project.