Board logo

标题: [系统相关] [已解决]循环1秒,检测到当前打开IE浏览器,自动按F11键全屏。 [打印本页]

作者: ygqiang    时间: 2015-1-5 11:05     标题: [已解决]循环1秒,检测到当前打开IE浏览器,自动按F11键全屏。

本帖最后由 ygqiang 于 2015-1-21 18:41 编辑

[已解决]循环1秒,检测到当前打开IE浏览器,自动按F11键全屏。
用啥语言/或者脚本,可以实现?谢谢了。
作者: ygqiang    时间: 2015-1-5 12:02

本帖最后由 ygqiang 于 2015-1-5 12:17 编辑
  1. (echo On Error Resume Next
  2. echo Set objShell = CreateObject^("Shell.Application"^)
  3. echo Do
  4. echo   For Each i In objShell.Windows^(^)
  5. echo     If InStr^(^1, i.FullName, "\IEXPLORE.EXE", ^1^) ^> ^0 Then
  6. echo       If i.TheaterMode = False Then i.TheaterMode = True
  7. echo     End If
  8. echo   Next
  9. echo   WScript.Sleep 1000
  10. echo Loop
  11. )>"c:\iefull.vbs"
复制代码
解决了。xp下测试通过。

win7 64  ie9系统下,有点问题。
作者: ygqiang    时间: 2015-1-5 12:20     标题: [已解决]循环1秒,检测打开IE浏览器页面,自动按最大化按钮(不是按F11键全屏)

本帖最后由 ygqiang 于 2015-1-21 18:42 编辑

[已解决]循环1秒,检测打开IE浏览器页面,自动按最大化按钮(不是按F11键全屏)

无论什么时候,软件一直后台监控运行(不弹出窗口)。每次只要打开1个IE浏览器窗口(系统自带的IE浏览器),
1、如果是小窗口情况下,过2秒钟,就自动按最大化按钮,将IE窗口最大化/填满屏幕(注意不是按F11键全屏)。
注意:按f11键全屏窗口,与按最大化按钮,是不一样的效果。
2、如果用鼠标点击IE浏览器的最小化按钮,就保持IE最小化状态。

IE浏览器的打开/最小化,都是鼠标点击实现的。
IE浏览器的最大化,是软件/脚本后台自动判断实现的。


用计时器不断判断——当前打开ie窗口的大小,当它小于屏幕大小时让它最大化。
有个例外,当前ie窗口最小化的时候,就维持现状。
作者: yu2n    时间: 2015-1-5 12:33

  1. objItem.TheaterMode
复制代码
这个部分在 Win7x64 IE8 上会出问题:比如打开两个正常模式的IE窗口,最小化,执行代码后,一个IE窗口没有变化,另外一个IE窗口大小没有改变,但是边框不见了。
作者: ygqiang    时间: 2015-1-5 12:37

这个部分在 Win7x64 IE8 上会出问题:比如打开两个正常模式的IE窗口,最小化,执行代码后,一个IE窗口没有变 ...
yu2n 发表于 2015-1-5 12:33



对啊。。刚发现这个问题了。

可能是IE版本本身不支持的问题。
作者: ygqiang    时间: 2015-1-5 13:23

在VB中如何使IE窗口最大化
http://blog.csdn.net/lyserver/article/details/4635721
作者: yu2n    时间: 2015-1-5 21:35

本帖最后由 yu2n 于 2015-1-5 21:39 编辑
VBS调用Windows API函数
http://demon.tw/programming/vbs-excel-invoke-windows-api.html


VBS 调用API设置IE最大化
  1. ' VBS 调用API设置IE最大化
  2. Dim WshShell
  3. set wso = CreateObject("WScript.Shell")
  4. wso.RegWrite "HKCU\Software\Microsoft\Office\11.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
  5. wso.RegWrite "HKCU\Software\Microsoft\Office\12.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
  6. wso.RegWrite "HKCU\Software\Microsoft\Office\14.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
  7. Dim oExcel, oBook, oModule
  8. Set oExcel = CreateObject("Excel.Application")
  9. Set oBook = oExcel.Workbooks.Add
  10. Set oModule = obook.VBProject.VBComponents.Add(1)
  11. strCode = _
  12.   "Private Declare Function ShowWindow Lib ""user32"" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long" & vbCr & _
  13.   "Private Const SW_SHOWMAXIMIZED = 3" & vbCr & _
  14.   "Public Sub IE_FullScreen_API()" & vbCr & _
  15.   "  Dim SHApp, SHWin" & vbCr & _
  16.   "  Set SHApp = CreateObject(""Shell.Application"")" & vbCr & _
  17.   "  For Each SHWin In SHApp.windows" & vbCr & _
  18.   "    If LCase(Right(SHWin.FullName, 12)) = ""iexplore.exe"" Then" & vbCr & _
  19.   "      ShowWindow SHWin.hwnd, SW_SHOWMAXIMIZED" & vbCr & _
  20.   "    End If" & vbCr & _
  21.   "  Next" & vbCr & _
  22.   "  Set SHApp = Nothing" & vbCr & _
  23.   "End Sub"
  24. oModule.CodeModule.AddFromString strCode
  25. Do
  26.   oExcel.Run "IE_FullScreen_API"
  27.   WScript.Sleep 1000
  28. Loop
  29. oExcel.DisplayAlerts = False
  30. oBook.Close
  31. oExcel.Quit
复制代码

作者: ygqiang    时间: 2015-1-5 21:56

VBS 调用API设置IE最大化
yu2n 发表于 2015-1-5 21:35



    多谢  win7 64系统 IE9环境下测试了。
有个小问题。

如果点击IE浏览器的最小化按钮,IE窗口又会自动恢复到最大化!需要关闭所有IE窗口,才能访问桌面文件。
这个感觉有点别扭。
能否保持这种情况下IE浏览器最小化状态(不让其恢复最大化)?
作者: yu2n    时间: 2015-1-6 12:24

回复 4# ygqiang
VBS 调用API设置IE显示模式(只允许最小化、最大化) by Yu2n
  1. ' VBS 调用API设置IE显示模式(只允许最小化、最大化) by Yu2n
  2. Dim WshShell
  3. set wso = CreateObject("WScript.Shell")
  4. wso.RegWrite "HKCU\Software\Microsoft\Office\11.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
  5. wso.RegWrite "HKCU\Software\Microsoft\Office\12.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
  6. wso.RegWrite "HKCU\Software\Microsoft\Office\14.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
  7. Dim oExcel, oBook, oModule
  8. Set oExcel = CreateObject("Excel.Application")
  9. Set oBook = oExcel.Workbooks.Add
  10. Set oModule = obook.VBProject.VBComponents.Add(1)
  11. strCode = _
  12.   "Private Declare Function FindWindow Lib ""user32"" Alias ""FindWindowA"" ( _" & vbCr &_
  13.   "  ByVal lpClassName As String, ByVal lpWindowName As String) As Long" & vbCr &_
  14.   "Private Declare Function GetDesktopWindow Lib ""user32"" () As Long" & vbCr &_
  15.   "Private Declare Function GetWindow Lib ""user32"" ( _" & vbCr &_
  16.   "  ByVal hwnd As Long, ByVal wCmd As Long) As Long" & vbCr &_
  17.   "Private Declare Function GetClassName Lib ""user32"" Alias ""GetClassNameA"" ( _" & vbCr &_
  18.   "  ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long" & vbCr &_
  19.   "Private Declare Function SendMessage Lib ""user32"" Alias ""SendMessageA"" ( _" & vbCr &_
  20.   "  ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long" & vbCr &_
  21.   "Private Declare Function IsZoomed Lib ""user32"" (ByVal hwnd As Long) As Long" & vbCr &_
  22.   "Private Declare Function IsIconic Lib ""user32"" (ByVal hwnd As Long) As Long" & vbCr &_
  23.   "Private Const GW_HWNDFIRST = 0" & vbCr &_
  24.   "Private Const GW_HWNDNEXT = 2" & vbCr &_
  25.   "Private Const GW_CHILD = 5" & vbCr &_
  26.   "Private Const WM_SYSCOMMAND = &H112" & vbCr &_
  27.   "Private Const SC_MAXIMIZE = &HF030&" & vbCr &_
  28.   "Public Sub IE_Maximize()" & vbCr &_
  29.   "  Dim nHWnd As Long" & vbCr &_
  30.   "  Dim s As String * 260" & vbCr &_
  31.   "  nHWnd = GetDesktopWindow()" & vbCr &_
  32.   "  nHWnd = GetWindow(nHWnd, GW_CHILD Or GW_HWNDFIRST)" & vbCr &_
  33.   "  While nHWnd <> 0" & vbCr &_
  34.   "    nHWnd = GetWindow(nHWnd, GW_HWNDNEXT)" & vbCr &_
  35.   "    s = String(256, Chr(0)): GetClassName nHWnd, s, 255: s = Replace(s, Chr(0), """")" & vbCr &_
  36.   "    If InStr(1, s, ""IEFRAME"", vbTextCompare) > 0 Then If nHWnd <> 0 Then WindowMaximize nHWnd" & vbCr &_
  37.   "  Wend" & vbCr &_
  38.   "End Sub" & vbCr &_
  39.   "Private Sub WindowMaximize(ByVal nHWnd As Long)" & vbCr &_
  40.   "  If IsZoomed(nHWnd) = 0 And IsIconic(nHWnd) = 0 Then SendMessage nHWnd, WM_SYSCOMMAND, SC_MAXIMIZE, ByVal 0" & vbCr &_
  41.   "End Sub"
  42. oModule.CodeModule.AddFromString strCode
  43. Do
  44.   oExcel.Run "IE_Maximize"
  45.   WScript.Sleep 1000
  46. Loop
  47. oExcel.DisplayAlerts = False
  48. oBook.Close
  49. oExcel.Quit
复制代码

作者: ygqiang    时间: 2015-1-6 19:43

回复  ygqiang
VBS 调用API设置IE显示模式(只允许最小化、最大化) by Yu2n
yu2n 发表于 2015-1-6 12:24



    多谢。

win7 64  IE9环境下,初步测试了下。好用
作者: ygqiang    时间: 2015-1-10 04:34

回复  ygqiang
VBS 调用API设置IE显示模式(只允许最小化、最大化) by Yu2n
yu2n 发表于 2015-1-6 12:24



    关机-弹出的2个窗口提示-能否不提示?
作者: yu2n    时间: 2015-1-10 07:40

回复 7# ygqiang
设置 EXCEL 不显示提示即可:
  1. ' VBS 调用API设置IE显示模式(只允许最小化、最大化) by Yu2n
  2. On Error Resume Next
  3. Dim wso
  4. set wso = CreateObject("WScript.Shell")
  5. wso.RegWrite "HKCU\Software\Microsoft\Office\11.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
  6. wso.RegWrite "HKCU\Software\Microsoft\Office\12.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
  7. wso.RegWrite "HKCU\Software\Microsoft\Office\14.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
  8. Dim oExcel, oBook, oModule
  9. Set oExcel = CreateObject("Excel.Application")
  10. Set oBook = oExcel.Workbooks.Add
  11. Set oModule = oBook.VBProject.VBComponents.Add(1)
  12. strCode = _
  13.   "Private Declare Function FindWindow Lib ""user32"" Alias ""FindWindowA"" ( _" & vbCr &_
  14.   "  ByVal lpClassName As String, ByVal lpWindowName As String) As Long" & vbCr &_
  15.   "Private Declare Function GetDesktopWindow Lib ""user32"" () As Long" & vbCr &_
  16.   "Private Declare Function GetWindow Lib ""user32"" ( _" & vbCr &_
  17.   "  ByVal hwnd As Long, ByVal wCmd As Long) As Long" & vbCr &_
  18.   "Private Declare Function GetClassName Lib ""user32"" Alias ""GetClassNameA"" ( _" & vbCr &_
  19.   "  ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long" & vbCr &_
  20.   "Private Declare Function SendMessage Lib ""user32"" Alias ""SendMessageA"" ( _" & vbCr &_
  21.   "  ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long" & vbCr &_
  22.   "Private Declare Function IsZoomed Lib ""user32"" (ByVal hwnd As Long) As Long" & vbCr &_
  23.   "Private Declare Function IsIconic Lib ""user32"" (ByVal hwnd As Long) As Long" & vbCr &_
  24.   "Private Const GW_HWNDFIRST = 0" & vbCr &_
  25.   "Private Const GW_HWNDNEXT = 2" & vbCr &_
  26.   "Private Const GW_CHILD = 5" & vbCr &_
  27.   "Private Const WM_SYSCOMMAND = &H112" & vbCr &_
  28.   "Private Const SC_MAXIMIZE = &HF030&" & vbCr &_
  29.   "Public Sub IE_Maximize()" & vbCr &_
  30.   "  Dim nHWnd As Long" & vbCr &_
  31.   "  Dim s As String * 260" & vbCr &_
  32.   "  nHWnd = GetDesktopWindow()" & vbCr &_
  33.   "  nHWnd = GetWindow(nHWnd, GW_CHILD Or GW_HWNDFIRST)" & vbCr &_
  34.   "  While nHWnd <> 0" & vbCr &_
  35.   "    nHWnd = GetWindow(nHWnd, GW_HWNDNEXT)" & vbCr &_
  36.   "    s = String(256, Chr(0)): GetClassName nHWnd, s, 255: s = Replace(s, Chr(0), """")" & vbCr &_
  37.   "    If InStr(1, s, ""IEFRAME"", vbTextCompare) > 0 Then If nHWnd <> 0 Then WindowMaximize nHWnd" & vbCr &_
  38.   "  Wend" & vbCr &_
  39.   "End Sub" & vbCr &_
  40.   "Private Sub WindowMaximize(ByVal nHWnd As Long)" & vbCr &_
  41.   "  If IsZoomed(nHWnd) = 0 And IsIconic(nHWnd) = 0 Then SendMessage nHWnd, WM_SYSCOMMAND, SC_MAXIMIZE, ByVal 0" & vbCr &_
  42.   "End Sub"
  43. oModule.CodeModule.AddFromString strCode
  44. oExcel.DisplayAlerts = False
  45. Do
  46.   oExcel.Run "IE_Maximize"
  47.   WScript.Sleep 1000
  48. Loop
  49. oBook.Close False
  50. oExcel.Quit
复制代码

作者: ygqiang    时间: 2015-1-10 09:10

本帖最后由 ygqiang 于 2015-1-10 10:17 编辑

多谢。。。。
作者: CrLf    时间: 2015-1-10 17:25

来个 F11 的效果
  1. Set SH = CreateObject("Shell.Application")
  2. For Each SHWin In SH.Windows
  3. If  LCase(Right(SHWin.FullName, 12)) = "iexplore.exe" Then
  4. SHWin.FullScreen=True
  5. End If
  6. Next
复制代码

作者: ygqiang    时间: 2015-1-11 00:07

回复 10# CrLf


    http://www.bathome.net/thread-33661-1-1.html

按f11的话,xp+ie环境好用。
win7 64+ie9环境,就不好用了。
作者: CrLf    时间: 2015-1-11 00:12

回复 11# ygqiang


    那个帖子用的是 TheaterMode,我用的是 FullScreen,实测好像没有问题
作者: ygqiang    时间: 2015-1-11 00:42

本帖最后由 ygqiang 于 2015-1-11 00:43 编辑
  1. Set SH = CreateObject("Shell.Application")
  2. do
  3. For Each SHWin In SH.Windows
  4.         If  LCase(Right(SHWin.FullName, 12)) = "iexplore.exe" Then
  5.                 SHWin.FullScreen=True
  6.         End If
  7. Next
  8. WScript.Sleep 20000
  9. loop
复制代码
CrLf给出的这个代码。win7 64+IE9环境下测试了。
有个问题。F11全屏以后,ie浏览器右上角的最小化和关闭按钮,都找不到了。如果手动按F11键,是没有这个问题的。
作者: yu2n    时间: 2015-1-11 01:02

IE_Maximize.exe 设置IE显示模式(只允许最小化、最大化)

VB6源码:

使用与结果:
  1. C:\Documents and Settings\Yu2n>IE_Maximize.exe
  2. 2015-01-11 00:59:22     Initd.
  3. 2015-01-11 00:59:31     Maximize(2230858)
  4. 2015-01-11 00:59:41     Maximize(198696)
复制代码

作者: CrLf    时间: 2015-1-11 01:31

回复 5# ygqiang


    两个一起用倒是可以全屏并设置 ToolBar=1:
  1. SHWin.FullScreen=True
  2. SHWin.TheaterMode=True
复制代码
不过试了一下好像和 F11 的效果是不太一样,找不到在哪退出全屏
作者: CrLf    时间: 2015-1-11 01:53

来段比较暴力的 AutoHotKey:
  1. #SingleInstance force
  2. #Persistent
  3. GroupAdd, IE, ahk_class IEFrame
  4. SetTimer WinMaximizeIE,1000
  5. WinMaximizeIE:
  6. WinMaximize, ahk_group IE
  7. Return
复制代码

作者: ygqiang    时间: 2015-1-11 02:11

IE_Maximize.exe 设置IE显示模式(只允许最小化、最大化)

VB6源码:


使用与结果:
yu2n 发表于 2015-1-11 01:02



   
这个也测试过,确实也好用。。。win7 64+ie9浏览器环境。
作者: ygqiang    时间: 2015-1-21 18:43

最终代码如下:
  1. ' VBS 调用API设置IE显示模式(只允许最小化、最大化) by Yu2n
  2. On Error Resume Next
  3. Dim wso
  4. set wso = CreateObject("WScript.Shell")
  5. wso.RegWrite "HKCU\Software\Microsoft\Office\11.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
  6. wso.RegWrite "HKCU\Software\Microsoft\Office\12.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
  7. wso.RegWrite "HKCU\Software\Microsoft\Office\14.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
  8. Dim oExcel, oBook, oModule
  9. Set oExcel = CreateObject("Excel.Application")
  10. Set oBook = oExcel.Workbooks.Add
  11. Set oModule = oBook.VBProject.VBComponents.Add(1)
  12. strCode = _
  13.   "Private Declare Function FindWindow Lib ""user32"" Alias ""FindWindowA"" ( _" & vbCr &_
  14.   "  ByVal lpClassName As String, ByVal lpWindowName As String) As Long" & vbCr &_
  15.   "Private Declare Function GetDesktopWindow Lib ""user32"" () As Long" & vbCr &_
  16.   "Private Declare Function GetWindow Lib ""user32"" ( _" & vbCr &_
  17.   "  ByVal hwnd As Long, ByVal wCmd As Long) As Long" & vbCr &_
  18.   "Private Declare Function GetClassName Lib ""user32"" Alias ""GetClassNameA"" ( _" & vbCr &_
  19.   "  ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long" & vbCr &_
  20.   "Private Declare Function SendMessage Lib ""user32"" Alias ""SendMessageA"" ( _" & vbCr &_
  21.   "  ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long" & vbCr &_
  22.   "Private Declare Function IsZoomed Lib ""user32"" (ByVal hwnd As Long) As Long" & vbCr &_
  23.   "Private Declare Function IsIconic Lib ""user32"" (ByVal hwnd As Long) As Long" & vbCr &_
  24.   "Private Const GW_HWNDFIRST = 0" & vbCr &_
  25.   "Private Const GW_HWNDNEXT = 2" & vbCr &_
  26.   "Private Const GW_CHILD = 5" & vbCr &_
  27.   "Private Const WM_SYSCOMMAND = &H112" & vbCr &_
  28.   "Private Const SC_MAXIMIZE = &HF030&" & vbCr &_
  29.   "Public Sub IE_Maximize()" & vbCr &_
  30.   "  Dim nHWnd As Long" & vbCr &_
  31.   "  Dim s As String * 260" & vbCr &_
  32.   "  nHWnd = GetDesktopWindow()" & vbCr &_
  33.   "  nHWnd = GetWindow(nHWnd, GW_CHILD Or GW_HWNDFIRST)" & vbCr &_
  34.   "  While nHWnd <> 0" & vbCr &_
  35.   "    nHWnd = GetWindow(nHWnd, GW_HWNDNEXT)" & vbCr &_
  36.   "    s = String(256, Chr(0)): GetClassName nHWnd, s, 255: s = Replace(s, Chr(0), """")" & vbCr &_
  37.   "    If InStr(1, s, ""IEFRAME"", vbTextCompare) > 0 Then If nHWnd <> 0 Then WindowMaximize nHWnd" & vbCr &_
  38.   "  Wend" & vbCr &_
  39.   "End Sub" & vbCr &_
  40.   "Private Sub WindowMaximize(ByVal nHWnd As Long)" & vbCr &_
  41.   "  If IsZoomed(nHWnd) = 0 And IsIconic(nHWnd) = 0 Then SendMessage nHWnd, WM_SYSCOMMAND, SC_MAXIMIZE, ByVal 0" & vbCr &_
  42.   "End Sub"
  43. oModule.CodeModule.AddFromString strCode
  44. oExcel.DisplayAlerts = False
  45. Do
  46.   oExcel.Run "IE_Maximize"
  47.   WScript.Sleep 1000
  48. Loop
  49. oBook.Close False
  50. oExcel.Quit
复制代码

作者: ygqiang    时间: 2015-1-21 18:46

最终代码如下:
  1. On Error Resume Next
  2. Set objShell = CreateObject("Shell.Application")
  3. Do
  4.   For Each i In objShell.Windows()
  5.     If InStr(1, i.FullName, "\IEXPLORE.EXE", 1) > 0 Then
  6.       If i.TheaterMode = False Then i.TheaterMode = True
  7.     End If
  8.   Next
  9.   WScript.Sleep 1000
  10. Loop
复制代码
  1. (echo On Error Resume Next
  2. echo Set objShell = CreateObject^("Shell.Application"^)
  3. echo Do
  4. echo   For Each i In objShell.Windows^(^)
  5. echo     If InStr^(^1, i.FullName, "\IEXPLORE.EXE", ^1^) ^> ^0 Then
  6. echo       If i.TheaterMode = False Then i.TheaterMode = True
  7. echo     End If
  8. echo   Next
  9. echo   WScript.Sleep 1000
  10. echo Loop
  11. )>"c:\iefull.vbs"
复制代码

作者: zhangop9    时间: 2021-1-7 15:08

监测ie 最大化




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2