定时关闭所有的IE窗口并打开一个新的ie窗口,遇到的问题(100分)

  • 主题发起人 nowloading
  • 开始时间
N

nowloading

Unregistered / Unconfirmed
GUEST, unregistred user!
程序想按照timer.interval的时间间隔实现一段时间内鼠标位置不动,<br>定时关闭所有的IE窗口并打开一个新的ie窗口<br>遇到的问题:时间间隔不确定,当关闭所有IE窗口后,打开一个新的IE窗口并非马上打开,<br>好象要等一个周期<br>代码如下:<br>var<br>&nbsp; Form1: TForm1;<br>&nbsp; point2:Tpoint;<br>implementation<br><br>{$R *.DFM}<br>function EnumWindowsProc(AHWnd: HWnd;<br>&nbsp; LPARAM: lParam): boolean; stdcall;<br>var<br>&nbsp; WndClassName: array[0..254] of char;<br>begin<br>&nbsp; GetClassName(AHWnd, @WndClassName, 254);<br>&nbsp; if StrPas(WndClassName)='IEFrame' then<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;postmessage(AHWnd,wm_close,0,0) ;<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; Result := true;<br>end;<br><br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var<br>point1:Tpoint;<br>begin<br>GetCursorPos(point1);<br>if (point1.x = point2.x) or (point1.y=point2.y) then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; EnumWindows(@EnumWindowsProc, 0);<br>&nbsp; &nbsp; &nbsp; ShellExecute(0,'open',PChar('http://www.sohu.com'),nil,nil,SW_MAXIMIZE);<br>&nbsp; &nbsp;end;<br>GetCursorPos(point2);<br><br>end;<br>请给位高手指点<br>
 
试试在执行完了 EnumWindows(@EnumWindowsProc, 0); 后等待一下再执行<br>ShellExecute(0,'open',PChar('http://www.sohu.com'),nil,nil,SW_MAXIMIZE);<br><br><br>或者把postmessage换成sendmessage(不过这样好像不太好)
 
还有一个问题,怎样才能让IE打开就全屏,不是最大化是全屏
 
在time事件开始处加入:timer1.enable:=false;<br>在time事件结束时加入timer1.enable:=true;<br>试一试行不行
 
给IE加上启动参数-k<br>如<br>winexec('IEXPLORE.EXE -k http://www.sohu.com',SW_MAXIMIZE);<br>
 
&gt;&gt;怎样才能让IE打开就全屏<br>sendmessage(iehandle,WM_KEYDOWN,VK_F11,0);
 
多人接受答案了。
 
顶部