sendmessage

WinAPI EM_STREAMOUT crash

喜你入骨 提交于 2020-01-14 04:08:08
问题 I'm trying to get the text of a Richedit Control from another program. So I found EM_STREAMOUT for SendMessage. This is my code so far (also from another Stackoverflow topic): DWORD CALLBACK EditStreamOutCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { std::stringstream *rtf = (std::stringstream*) dwCookie; rtf->write((char*)pbBuff, cb); *pcb = cb; return 0; } int main() { std::stringstream rtf; EDITSTREAM es = {0}; es.dwCookie = (DWORD_PTR) &rtf; es.pfnCallback =

Write text to notepad with C#/Win32

*爱你&永不变心* 提交于 2020-01-12 04:41:21
问题 I'm messing around with Win32 API and windows messaging trying to figure out how things work and I found this question very helpful. I'd like to improve upon the solution provided there so that it appends the text instead of just replacing the text in notepad via WM_SETTEXT. My question is, how would I use WM_GETTEXTLENGHT, followed by WM_GETTEXT, to get the current text in the notepad window so I could then append new text to it before using WM_SETTEXT? Does using WM_XXXTEXT work on both 32

C#调用Win32 的API函数--User32.dll

☆樱花仙子☆ 提交于 2020-01-11 08:31:37
Win32的API函数是微软自己的东西,可以直接在C#中直接调用,在做WinForm时还是很有帮助的。有时候我们之直接调用Win32 的API,可以很高效的实现想要的效果。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace WindowsAPI { class CSharp_Win32Api { #region User32.dll 函数 /// <summary> /// 该函数检索一指定窗口的客户区域或整个屏幕的显示设备上下文环境的句柄,以后可以在GDI函数中使用该句柄来在设备上下文环境中绘图。hWnd:设备上下文环境被检索的窗口的句柄 /// </summary> [DllImport( " user32.dll " , CharSet = CharSet.Auto)] public static extern IntPtr GetDC(IntPtr hWnd); /// <summary> /// 函数释放设备上下文环境(DC)供其他应用程序使用。 /// </summary> public static extern int ReleaseDC(IntPtr

Android: Sending a Mail/SMS/Tweet with Intent.ACTION_SEND / requestCode / resultCode?

ε祈祈猫儿з 提交于 2020-01-11 03:37:06
问题 I'm using the following code : Intent sendMailIntent = new Intent(Intent.ACTION_SEND); sendMailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.Share_Mail_Subject)); sendMailIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.Share_Mail_Text)); sendMailIntent.setType("text/plain"); startActivity(Intent.createChooser(sendMailIntent, "Email / SMS / Tweet ?")); Then I would like to be able to make the difference between: 1. my user has indeed sent en email/SMS ... OR 2. my user has in

C语言Windows程序设计 -> 第十三天 -> 按钮类控件

我是研究僧i 提交于 2020-01-10 19:03:39
C语言Windows程序设计 -> 第十三天 -> 按钮类控件 终于到了令人激动的时刻, 尽管在前一阶段的学习中我们已经学习了如何在客户区中绘制简单的图形以及如何使用键盘和鼠标, 但是距离 Windows意义上的软件 似乎还是有点遥远, 而今天, 我们要做的就是将这个距离再缩短一大步! 这阶段要学习的就是 子窗口控件 的使用。 在其他一些 Windows应用软件上我们经常能够看到一些大致相同的按钮、复选框、组合框、列表框等控件, 这些控件很有可能就是使用 标准子窗口控件 来实现的。 一、子窗口的创建 在讲解 "标准子窗口控件" 的使用之前我们首先应该知道如何去创建一个子窗口, 因为这些 "子窗口控件" 实际上都是通过创建一个子窗口的形式来进行创建的, 因此我们应该把理解的重点放在 "子窗口" 上, 而不是 "控件" 上。 子窗口的创建可以将整个客户区划分为多个矩形区域, 并且每个子窗口都可以有自己的句柄、窗口过程和客户区, 每个子窗口过程只接收与自身窗口有关的鼠标消息、鼠标消息的参数 lParam 中包含的坐标是相对于 子窗口 客户区的左上角的。简单的说, 子窗口具有一个普通窗口的一切特性。 子窗口的创建同样是使用 CreateWindow 函数进行创建的, 下面我们通过一个示例来认识这个过程: 代码已折叠, 点击展开: View Code 1 #include<windows.h

SendMessage WM_LBUTTONDOWN/UP works on buttons but not window

十年热恋 提交于 2020-01-06 06:09:15
问题 I am trying to send some simple mouse down/up messages to Windows Calculator using SendMessage. I have been able to press the buttons by sending the messages to the buttons directly. However, I have not been able to successfully send the same messages to the main calculator window handle. Given that hWnd is the window handle to calculator, this is my code. IntPtr fiveKey = FindWindowEx(hWnd, IntPtr.Zero, "Button", "5"); int x = 5; // X coordinate of the click int y = 5; // Y coordinate of the

Send keys without SendMessage and PostMessage

匆匆过客 提交于 2020-01-03 03:08:05
问题 Is it possible to send keys to a program without SendMessage and PostMessage API? 回答1: The official way to fake input does not involve sending or posting Windows messages directly. Instead you are meant to call SendInput. When you use SendInput it is indistinguishable from actually pressing the real keys. When you call SendInput to fake keyboard input, the system ultimately posts messages to the message queue of the foreground thread that created the window with the keyboard focus. 来源: https:

Can I get a bitmap of an arbitrary window in another application process?

☆樱花仙子☆ 提交于 2020-01-02 19:27:11
问题 I am trying to automate a third-party Win32 application where I want to capture the graphics content of a particular window at defined time intervals. I am in the early phases of this, and I'm currently trying to use the Microsoft UI Automation API via C# to do most of the interaction between my client app and the external app. I can now get the external app to do what I want it to do, but now I want to capture the graphics from a specific window that seems to be some third-party owner-drawn

android Handler post sendMessage

本小妞迷上赌 提交于 2020-01-01 21:04:14
Handler 为Android操作系统中的线程通信工具,包为android.os.Handler。 与Handler绑定的有两个队列,一个为消息队列,另一个为线程队列。Handler可以通过这两个队列来分别: 发送、接受、处理消息–消息队列; 启动、结束、休眠线程–线程队列; Android OS中,一个进程被创建之后,主线程(可理解为当前Activity)创建一个消息队列,这个消息队列维护所有顶层应用对象(Activities, Broadcast receivers等)以及主线程创建的窗口。你可以在主线程中创建新的线程,这些新的线程都通过Handler与主线程进行通信。通信通过新线程调用 Handler的post()方法和sendMessage()方法实现,分别对应功能: post() 将一个线程加入线程队列; sendMessage() 发送一个消息对象到消息队列; 当然,post()方法还有一些变体,比如postDelayed()、postAtTime()分别用来延迟发送、定时发送; 消息的处理,在主线程的Handler对象中进行;具体处理过程,需要在new Handler对象时使用匿名内部类重写Handler的handleMessage(Message msg)方法; 线程加入线程队列可以在主线程中也可以在子线程中进行,但都要通过主线程的Handler对象调用post(

How can I send a message to a specific process by process id rather than by window handle?

五迷三道 提交于 2020-01-01 00:48:25
问题 To work around the limitations of GenerateConsoleCtrlEvent, I have to create an intermediate "middle-man" process to handle launching some console applications. The process's main purpose is to call GenerateConsoleCtrlEvent on itself, causing itself and all child process to close cleanly in response to a ctrl+break signal (rather than using Process.Kill). This need arises from the fact that GenerateConsoelCtrlEvent basically has no effect unless the process group id is zero, which means it is