postmessage

Send string data from Thread to main form

旧街凉风 提交于 2019-11-29 03:07:53
问题 In Dephi, I create a thread, like this, which will send message to main form from time to time Procedure TMyThread.SendLog(I: Integer); Var Log: array[0..255] of Char; Begin strcopy(@Log,PChar('Log: current stag is ' + IntToStr(I))); PostMessage(Form1.Handle,WM_UPDATEDATA,Integer(PChar(@Log)),0); End; procedure TMyThread.Execute; var I: Integer; begin for I := 0 to 1024 * 65536 do begin if (I mod 65536) == 0 then begin SendLog(I); End; End; end; where WM_UPDATEDATA is a custom message,

web跨域解决方案

余生长醉 提交于 2019-11-29 01:02:38
目录 什么是跨域 常用的几种跨域处理方法: 跨域的原理解析及实现方法 1、JSONP(JSON with padding) 2、CORS策略 3、document.domain+iframe的设置 (只有在主域相同的时候才能使用该方法) 4、HTML5的postMessage 5、使用window.name来进行跨域(相对比较完美的方法) 总结 摘要: 跨域问题,无论是面试还是平时的工作中,都会遇到,本文总结处理跨域问题的几种方法以及其原理,也让自己搞懂这方面的知识,走起。 回到顶部 什么是跨域      在JavaScript中,有一个很重要的安全性限制,被称为“Same-Origin Policy”( 同源策略 =》当且仅当它们源自的页面共享相同的协议,端口号和主机时,允许不同页面上的脚本相互访问 )。这一策略对于JavaScript代码能够访问的页面内容做了很重要的限制,即JavaScript只能访问与包含它的文档在同一域下的内容。   JavaScript这个安全策略在进行多iframe或多窗口编程、以及Ajax编程时显得尤为重要。根据这个策略,在baidu.com下的页面中包含的JavaScript代码,不能访问在google.com域名下的页面内容;甚至不同的子域名之间的页面也不能通过JavaScript代码互相访问。对于Ajax的影响在于

Why do some applications not accept some sendkeys at some times

梦想与她 提交于 2019-11-28 06:54:01
问题 This is an issue I've ran into before, but I've always given up solving the problem and worked out a work around. Not today (hopefully). I'm trying to make a bot for the classic Doom II. I want my bot to have access to the main menu which is accessed via the escape key. Naturally I tried: sendkeys.send("{ESC}") No luck. But then something weird happened. I accidently ran the code when I was already on the menu... and it closed the menu (which is normal if you press escape on the menu). So

How do I postMessage to a sibling iFrame

醉酒当歌 提交于 2019-11-28 05:48:25
问题 I'm looking for a way to postMessage to a sibling iFrame without any javascript in the parent page. The difficulty I'm having is trying to get the window object for the other iFrame from the first iFrame The page would be laid out something like this: html body (http://host.com/) iFrame#a (http://me.com/a) iFrame#b (http://me.com/b) From iFrame#a I'm trying to do: (iFrame#b window).postMessage(...) The problem is I don't know how to get the window object for iFrame#b from within iFrame#a .

Uncaught DOMException: Failed to execute 'postMessage' on 'Window': An object could not be cloned

偶尔善良 提交于 2019-11-28 05:46:17
I'm trying to call parent.postMessage(obj, 'whatever'); from within an iframe and I'm getting this error: Uncaught DOMException: Failed to execute 'postMessage' on 'Window': An object could not be cloned. It turns out the object I passed had methods, which is why the error message said An object could not be cloned . In order to fix this, you can do the following: obj = JSON.parse(JSON.stringify(obj)); parent.postMessage(obj, 'whatever'); 来源: https://stackoverflow.com/questions/42376464/uncaught-domexception-failed-to-execute-postmessage-on-window-an-object-co

PostMessage from WorkerThread to Main Window in MFC

拈花ヽ惹草 提交于 2019-11-28 03:53:03
问题 I have a MFC application, which has a worker thread, what I want to do is to post message from worker thread to the Main GUI thread to update some status messages on GUI. What I have done so far is Registered a new window message //custom messages static UINT FTP_APP_STATUS_UPDATE = ::RegisterWindowMessageA("FTP_APP_STATUS_UPDATE"); Added this message to the message map of dialog class ON_MESSAGE(FTP_APP_STATUS_UPDATE, &CMFC_TestApplicationDlg::OnStatusUpdate) The prototype of OnStatusUpdate

C# - How to PostMessage to a flash window embedded in a WebBrowser?

两盒软妹~` 提交于 2019-11-28 01:18:50
问题 I would like to know if there was any way to lock onto a Flash window and post a message to it? Another person here had the answer to it, his name is Spencer K. His question was: Sending simulated click via WebBrowser in C# to flash object embedded in HTML Unfortunately, Mr. K wasn't very specific, and all he left behind for people reading his question was that he "got the handle and then iterated through the handles." I'm not extremely sure what he meant by that. I iterated through all

PostMessage WM_KEYDOWN send multiply keys?

 ̄綄美尐妖づ 提交于 2019-11-27 15:51:44
I have this code: public static void Next() { Process[] processes = Process.GetProcessesByName("test"); foreach (Process proc in processes) PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_RIGHT, 0); } This code sents the Right Arrow key, i want to sent ALT+CTRL+RIGHT i tried this: public static void Forward() { Process[] processes = Process.GetProcessesByName("test"); foreach (Process proc in processes) { PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_CONTROL, 0); PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_ALT, 0); PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_RIGHT, 0); } }

Any good debugger for HTML5 Javascript postMessage API? [closed]

為{幸葍}努か 提交于 2019-11-27 15:43:02
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 11 months ago . Is there any good tool out there that allows developers to correctly debug messages sent between windows with postMessage? Or maybe a plugin for Firebug? 回答1: Firebug (as of 1.11 beta 1) supports this with monitorEvents() . You can do something like this: $("iframe").each(function(i, e) { console.log(

使用postMessage实现跨窗口消息传递

不问归期 提交于 2019-11-27 14:35:56
检测浏览器支持 不同版本的浏览器对postMessage的支持可能不同,因此使用前需要检测。在chrome浏览器中的一种比较简单的方法就是直接在开发者工具中输入window.postMessage,如果结果如下,说明支持 使用postMessage 发送消息 postMessage的语法 :window.postMessage(data,url) data:发送的消息,通常为字符串 url:指定允许通信的域名。注意,不是接受消息的目标域名。使用该参数的主要作用是出于安全考虑,接受消息的窗口可以根据此消息来判断信息来源是否可靠,避免恶意攻击。如果不对访问的域进行判断可以使用‘*’。 跨窗口消息传递实例 1.目标:使用框架实现左边发送消息,右边显示发送的消息 2.效果图: 3.代码实现 1)index.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>跨框架发送消息</title> </head> <frameset framespacing="1" border="1" bordercolor=#333339 frameborder="yes"> <frameset cols="500,*"> <frame name="left" target="main" src="left.html"