这听起来很有趣......只是一个小实验.
我想使用发送消息模拟应用程序/窗口上文件的拖放.可能吗?
我没有应用程序的代码,但在可执行文件上.
该应用程序是IP Messenger.
我想要做的是使用"发送到"功能将文件发送到.exe,它将
找到IPMessenger窗口并模拟拖放thr代码.
用户将选择该文件,然后右键单击"发送到".exe,它将从代码中拖放.
**注意:IP Messenger支持文件的拖放操作
thx
amit
我有一个程序需要将BM_CLICK消息发送到另一个应用程序按钮.我可以获得父窗口句柄,但是当我尝试获取按钮句柄时,如果总是返回0
我从Spy ++获得了按钮标题名称和按钮类型,这似乎是对的,但我知道我一定有错.下面是我的代码
public const Int BM_CLICK = 0x00F5;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr SendMessage(IntPtr hwnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
private void button1_Click(object sender, EventArgs e)
{
Process[] processes = Process.GetProcessesByName("QSXer");
foreach (Process p in processes)
{
////the Button's Caption is "Send" and it is a "Button".
IntPtr ButtonHandle = FindWindowEx(p.MainWindowHandle, IntPtr.Zero, "Button", "Send"); …Run Code Online (Sandbox Code Playgroud) 到目前为止,我已经完成了所有句柄捕获和gui设置.我很难过如何执行实际步骤.
我有这个代码:
SendMessage(New IntPtr(CurrentHandle), WHAT,GOES,HERE?)
Run Code Online (Sandbox Code Playgroud)
我一直在看:http: //msdn.microsoft.com/en-us/library/ms644950(VS.85).aspx 和 http://msdn.microsoft.com/en-us/library/ms644927( v = VS.85)的.aspx#SYSTEM_DEFINED
但是,这些都没有提供我需要学习如何操作的"代码示例"方法.我只需要发送关键事件,如按"/"或"w"等.不,我不能使用sendkeys.
谢谢,如果你能帮忙!
我正在StackOverflow上搜索,找到了C#中静音音量的答案.我不明白答案是怎么回事.我从来没有深入到Marshaling或P/Invoke.我之前使用过它们但从未明白我在做什么.
所以这就是我困惑的事情:
private const int APPCOMMAND_VOLUME_MUTE = 0x80000;
private const int WM_APPCOMMAND = 0x319;
Run Code Online (Sandbox Code Playgroud)
在声明这些内容时,它们的名称是否重要,或者它们只是被视为任何整数,无论它们被称为什么?
你在哪里的价值观0x80000和0x319从何而来?
我正在尝试为chrome扩展程序创建一个弹出界面.我似乎无法从popup.html/popup.js向content.js脚本发送消息.这是我到目前为止所拥有的.当我点击扩展图标时,我会看到一个说clickme的按钮.我点击它没有任何反应,chrome javascript控制台没有错误,也没有发送到content.js的消息.
表现
{
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"manifest_version": 2,
"name": "extensiontest",
"version": "0.2",
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": ["content.js"]
}
],
"browser_action": {
"default_icon": "Beaker.png",
"default_popup":"popup.html"
},
"background": {
"scripts": ["background.js"]
},
"permissions": [
"tabs"
]
}
Run Code Online (Sandbox Code Playgroud)
popup.html
<html>
<head></head>
<script src="popup.js"></script>
<body>
<input id="button1" type=button value=clickme>
</body></html>
Run Code Online (Sandbox Code Playgroud)
popup.js
function popup(){
alert(1);
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
var activeTab = tabs[0];
chrome.tabs.sendMessage(activeTab.id, {"message": "start"});
});
button1=document.getElementById("button1");
button1.addEventListener('click', popup)
}
Run Code Online (Sandbox Code Playgroud)
content.js
chrome.runtime.onMessage.addListener(
function(request, sender, …Run Code Online (Sandbox Code Playgroud) 是SetWindowSubClass()应该改变的ANSI窗口为UNICODE寡妇?我没有在文档或网络上找到有关此行为的任何内容.
我创建了一个测试应用程序(完整源代码),只是为了说明SetWindowSubclass(我相信)如何将受影响窗口的类型从ANSI更改为UNICODE,因为它不应该!IsWindowUnicode()确认了变化.
program TwoWaySubclassing;
{$apptype gui}
{$R Generic.res}
{
{ I created this test application just to illustrate how SetWindowSubclass()
{ changes -- I believe -- the type of the affected window from ANSI to UNICODE,
{ as it shouldn't! IsWindowUnicode() confirms that.
{
{ The Delphi 7 (all ANSI) application has 2 edit controls:
{ 1. The smaller, which is subclassed in 2 switchable ways (called Modes).
{ 2. …Run Code Online (Sandbox Code Playgroud) 所以我试图从选项卡中捕获网络音频并将其传递到另一个与页面上的 DOM 元素一起使用的脚本中。
扩展脚本
在 中background.js,我使用以下脚本:
chrome.tabCapture.capture(constraints, function(stream) {
console.log("\ngot stream");
console.log(stream);
chrome.tabs.sendMessage(tabID, {
"message": "stream",
"stream": stream
});
});
Run Code Online (Sandbox Code Playgroud)
Developer Toolkit 向我展示了创建的对象确实是一个 MediaStream 对象。(我想要并且似乎工作正常)。
扩展控制台:
MediaStream {onremovetrack: null, onaddtrack: null, onended: null, ended: false, id: "c0jm4lYJus3XCwQgesUGT9lpyPQiWlGKHb7q"…}
内容脚本
我在页面本身上使用内容脚本(注入),然后将 JSON 序列化对象拉回:
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request.message === "stream") {
var thisStream = request.stream;
console.log(thisStream);
if (!thisStream) {
console.log("stream is null");
return;
}
loadStream(thisStream);
}
else if (request.message === "statusChanged") {
console.log("statusChanged");
}
});
Run Code Online (Sandbox Code Playgroud)
页面控制台
不幸的是,由于 JSON 序列化,对象类型丢失了: …
当我创建一个新的 Win32 应用程序时,我注意到了这个函数:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Run Code Online (Sandbox Code Playgroud)
当某处调用函数PostMessage或 SendMessage时会收到消息,我注意到函数 WndProc 可以接收消息,因为有一个函数注册它:
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SCREENCAPTURE));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_SCREENCAPTURE);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex);
}
Run Code Online (Sandbox Code Playgroud)
注意: wcex.lpfnWndProc = WndProc;
我想了解 PostMessage() 的机制以及如何接收它,所以我创建了一个 C++ 控制台应用程序,看看我是否可以注册函数 WndProc,这是我的尝试代码:
LRESULT …Run Code Online (Sandbox Code Playgroud) 我正在制作我的第一个 chrome 扩展,并注意到从我的 popup.html 页面发送的消息在我的 content.js 消息事件侦听器中被复制。我在每条消息发送之前控制台记录了“发送消息”,在每条消息之前记录了“消息接收”,我不明白这些消息是如何被复制的。我还检查了sendMessage和onMessage的 chrome 开发文档,它指定 onMessage 侦听器应该只在每个 sendMessage 事件触发一次。
任何帮助,将不胜感激。
弹出窗口.html
<!DOCTYPE html>
<html>
<head>
<title>Messaging Practice</title>
</head>
<body>
<h1>Messaging Practice</h1>
<input type="button" id="send-message" value="Button">
<script src="popup.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
内容.js
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
console.log('message received')
console.log(request);
}
);
Run Code Online (Sandbox Code Playgroud)
弹出窗口.js
var messageButton = document.querySelector("#send-message");
messageButton.onclick = function() {
chrome.tabs.query({currentWindow: true, active: true},
function(tabs) {
chrome.tabs.executeScript(
tabs[0].id, {file: "content.js"}
)
console.log("sending message")
chrome.tabs.sendMessage(tabs[0].id, "string message")
});
}
Run Code Online (Sandbox Code Playgroud)
背景.js
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{ …Run Code Online (Sandbox Code Playgroud) javascript google-chrome sendmessage google-chrome-extension
我有两个电报机器人,上次我注意到,第二个机器人变慢了.
我的研究表明,sendMessage调用有两个不同的时间.
curl "https://api.telegram.org/bot123456789:AAAAAAAAABBBBBBBBCCCCCCC/sendMessage?chat_id=987654321&text=HI"
Run Code Online (Sandbox Code Playgroud)
这是两个不同机器人的输出:
拨打第一个(快速)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 224 100 224 0 0 491 0 --:--:-- --:--:-- --:--:-- 492
Run Code Online (Sandbox Code Playgroud)
呼叫第二个机器人(慢)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 227 100 227 0 0 43 0 0:00:05 0:00:05 --:--:-- 59
Run Code Online (Sandbox Code Playgroud)
第一个sendMessage立即运行.
第二个时间花费= 5秒!
它总是2-6秒.有谁知道原因?
对不起我的英语不好.
sendmessage ×10
c# ×3
winapi ×3
c++ ×2
javascript ×2
casting ×1
curl ×1
delphi ×1
json ×1
keystrokes ×1
pinvoke ×1
popup ×1
postmessage ×1
subclassing ×1
telegram ×1
telegram-bot ×1
unicode ×1
vb.net ×1
windows ×1