Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
512 views
in Technique[技术] by (71.8m points)

c# - SendMessage,尝试发送F4(SendMessage, Trying to send F4)

My SendMessage signature:

(我的SendMessage签名:)

[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);

To get the window handle, I find the MainWindowHandle from the process I want to send messages to:

(为了获取窗口句柄,我从要将消息发送到的进程中找到MainWindowHandle:)

whandle = MemClass.Process.MainWindowHandle;

Here I'm trying to SendMessage to that process window: (0x73 = F4 key)

(在这里,我尝试将SendMessage发送到该进程窗口:(0x73 = F4键))

SendMessage(whandle, 0x73, 0, 0);

And It's obviously giving error, because I'm sending last 2 params as int instead of IntPtr:

(而且这显然是错误的,因为我将最后两个参数作为int而不是IntPtr发送:)

IntPtr wParam, IntPtr lParam

Tested with this call:

(通过此调用进行了测试:)

SendMessage(whandle, 0x73, IntPtr.Zero, IntPtr.Zero);

0 errors but it's not sending F4 to the window

(0个错误,但未将F4发送到窗口)

How do I call this function correctly?

(如何正确调用此函数?)

I want to send F4 to a process window.

(我想将F4发送到过程窗口。)

  ask by kuhi translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...