17951.html
来自「以电子书的形式收集了VB一些常见问题解决方法,可以很方便的查找自己需要解决的问题」· HTML 代码 · 共 27 行
HTML
27 行
<html> <head> <title>其实麻烦啦</title> </head> <body bgcolor="#FFFFFF" vlink="#808080"> <center> <h1>其实麻烦啦</h1> </center><hr size=7 width=75%><hr size=7 width=75%><p>Posted by <a href="mailto:cww5@mail.ncku.edu.tw">cww</a> on August 27, 1999 at 08:46:44:<p>In Reply to: <a href="17923.html">又是 SendKeys 的问题</a> posted by 阿千 on August 26, 1999 at 16:28:57:<p>用sendkeys送字串或键盘讯息给其他的Window时,最重<br>要是得确定该Window是否已得到keyboard Focus<br>前面许多位网友有的提出DoEvents,那是不成的,它<br>Delay了一下后面sendkeys的执行,所以有可能让接<br>收Focus的window真的取得keyboard focus而成功,但<br>是亦有可能还来不及有keyboard focus便执行后面的<br>sendkeys了,而用Sleep()亦是如此,所以可以用<br>GetForegroundWindow的API来Testing,一直Testing<br>到传回的hWnd就是您要的那一个Window的hWnd便成了,<br>但是如何取得该Window的hWnd,又是另一件麻烦的事<br>不同情况有不同方法(如:FindWindow,EnumWindows<br>等等)。<br>另外,也可以先想办法取得该Window的hWnd再使用<br>SetForeGroundWindow的API设定其Focus,只要设定成功<br>才能用Sendkeys<br>所以说,麻烦啦<p><br><br><hr size=7 width=75%><p><a name="followups">Follow Ups:</a><br><ul><!--insert: 17951--><!--top: 17978--><li><a href="17978.html">不怕麻烦, 请给我范例, 我是自修的新手, API 根本没用过....</a> <b>阿千</b> <i>13:09:57 8/27/99</i>(<!--responses: 17978-->0)<ul><!--insert: 17978--></ul><!--end: 17978--></ul><!--end: 17951--><br><hr size=7 width=75%><p></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?