C++怎么发送给网页游戏的对话框

C++语言 码拜 8年前 (2016-04-21) 1004次浏览
想做个网页自动喊话的功能,本人的想法是获取网页中文本编辑框的句柄,然后发送文本信息过去。但是发现获取不了文本编辑框的句柄,有什么好的解决方法吗?
解决方案

2

这个应该是c++层到js层之间的交互了吧,可以去试试node.js    基于chrome v8

2

2

在MSDN里面搜SendInput

2

在百度搜“CPP源代码 WebBrowser控件”

2

模拟键盘输入可以使用Windows API:
SendInput
keybd_event

2

引用:

模拟键盘输入可以使用Windows API:
SendInput
keybd_event

SendInput也可以模拟鼠标输入。
不知道能否可以模拟触摸屏输入。

2

网页游戏用按键不太现实,可以考虑抓包分析一下,你也可以用C++套接字通信!本人还没成功。

2

网页游戏一般是FLASH,用C++提供的对键盘的操作功能是没办法达到的

2

引用:
Quote: 引用:

模拟键盘输入可以使用Windows API:
SendInput
keybd_event

SendInput也可以模拟鼠标输入。
不知道能否可以模拟触摸屏输入。

好像不行

2

SetFocus
The SetFocus function sets the keyboard focus to the specified window. The window must be associated with the calling thread”s message queue.
HWND SetFocus(
HWND hWnd   // handle to window to receive focus
);

Parameters
hWnd
Handle to the window that will receive the keyboard input. If this parameter is NULL, keystrokes are ignored.
Return Values
If the function succeeds, the return value is the handle to the window that previously had the keyboard focus. If the hWnd parameter is invalid or the window is not associated with the calling thread”s message queue, the return value is NULL. To get extended error information, callGetLastError.
Remarks
The SetFocus function sends a WM_KILLFOCUS message to the window that loses the keyboard focus and a WM_SETFOCUS message to the window that receives the keyboard focus. It also activates either the window that receives the focus or the parent of the window that receives the focus.
If a window is active but does not have the focus, any key pressed will produce the WM_SYSCHAR, WM_SYSKEYDOWN, or WM_SYSKEYUP message. If the VK_MENU key is also pressed, the lParam parameter of the message will have bit 30 set. Otherwise, the messages produced do not have this bit set.
By using the AttachThreadInput function, a thread can attach its input processing to another thread. This allows a thread to call SetFocus to set the keyboard focus to a window associated with another thread”s message queue.
Windows CE: Do not use the SetFocus function to set the keyboard focus to a window associated with another thread”s message queue. There is one exception. If a window on one thread is the child of the window on the other thread, or if the windows are siblings of the same parent, the thread associated with one window can set the focus to the other window even though it belongs to a different thread. In this case, there is no need to call AttachThreadInput first.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
Import Library: Use user32.lib.
See Also
Keyboard Input Overview, Keyboard Input Functions,AttachThreadInput, GetFocus, WM_KILLFOCUS, WM_SETFOCUS, WM_SYSCHAR, WM_SYSKEYDOWN, WM_SYSKEYUP

2

引用:

本人现在可以实现鼠标事件,把鼠标点击事件发送到flash指定地点。但是文本信息不知道哪有有问题,发送不过去。本人在想是不是光标设置的问题,该怎么样设置光标。本人发送光标事件过去,但是感觉没反应,不知道哪里出问题了。

有很多游戏利用传说中的DX驱动,例如说赛车类的游戏,直接从键盘鼠标接收消息,不从操作系统接收消息,FLASH是怎么实现的,不清楚,本人也想找个师傅,网上也没找到相关的文章,只凭空猜的!

2

ScreenToClient
The ScreenToClient function converts the screen coordinates of a specified point on the screen to client coordinates.
BOOL ScreenToClient(
HWND hWnd,        // window handle for source coordinates
LPPOINT lpPoint   // address of structure containing coordinates
);

Parameters
hWnd
Handle to the window whose client area will be used for the conversion.
lpPoint
Pointer to a POINT structure that contains the screen coordinates to be converted.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
Windows NT: To get extended error information, callGetLastError.
Remarks
The function uses the window identified by the hWnd parameter and the screen coordinates given in the POINT structure to compute client coordinates. It then replaces the screen coordinates with the client coordinates. The new coordinates are relative to the upper-left corner of the specified window”s client area.
The ScreenToClient function assumes the specified point is in screen coordinates.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
Import Library: Use user32.lib.
See Also
Coordinate Spaces and Transformations Overview, Coordinate Space and Transformation Functions, ClientToScreen, MapWindowPoints, POINT

2

ScreenToClient
赵老师这个经典

8

大致文本编辑框从一开始就不存在,只不过是浏览器画出来,看起来跟真的文本框一模一样罢了,想取不存在的控件的句柄,是取不到的。

2

flash按钮没有句柄,整个flash控件只有一个句柄,而且控件属性里没有给出句柄的值,但可以通过分析类,得出其句柄。
或试试这个API
AccessibleObjectFromWindow

2

应该用web自动化测试工具去做。
例如WEBDRIVER

2

CreateDesktop

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明C++怎么发送给网页游戏的对话框
喜欢 (0)
[1034331897@qq.com]
分享 (0)