标题: [系统相关] [已解决]循环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 编辑
- (echo On Error Resume Next
- echo Set objShell = CreateObject^("Shell.Application"^)
-
- echo Do
- echo For Each i In objShell.Windows^(^)
- echo If InStr^(^1, i.FullName, "\IEXPLORE.EXE", ^1^) ^> ^0 Then
- echo If i.TheaterMode = False Then i.TheaterMode = True
- echo End If
- echo Next
- echo WScript.Sleep 1000
- echo Loop
- )>"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
复制代码
这个部分在 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 调用API设置IE最大化- ' VBS 调用API设置IE最大化
- Dim WshShell
- set wso = CreateObject("WScript.Shell")
- wso.RegWrite "HKCU\Software\Microsoft\Office\11.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
- wso.RegWrite "HKCU\Software\Microsoft\Office\12.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
- wso.RegWrite "HKCU\Software\Microsoft\Office\14.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
- Dim oExcel, oBook, oModule
- Set oExcel = CreateObject("Excel.Application")
- Set oBook = oExcel.Workbooks.Add
- Set oModule = obook.VBProject.VBComponents.Add(1)
- strCode = _
- "Private Declare Function ShowWindow Lib ""user32"" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long" & vbCr & _
- "Private Const SW_SHOWMAXIMIZED = 3" & vbCr & _
- "Public Sub IE_FullScreen_API()" & vbCr & _
- " Dim SHApp, SHWin" & vbCr & _
- " Set SHApp = CreateObject(""Shell.Application"")" & vbCr & _
- " For Each SHWin In SHApp.windows" & vbCr & _
- " If LCase(Right(SHWin.FullName, 12)) = ""iexplore.exe"" Then" & vbCr & _
- " ShowWindow SHWin.hwnd, SW_SHOWMAXIMIZED" & vbCr & _
- " End If" & vbCr & _
- " Next" & vbCr & _
- " Set SHApp = Nothing" & vbCr & _
- "End Sub"
- oModule.CodeModule.AddFromString strCode
- Do
- oExcel.Run "IE_FullScreen_API"
- WScript.Sleep 1000
- Loop
- oExcel.DisplayAlerts = False
- oBook.Close
- 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- ' VBS 调用API设置IE显示模式(只允许最小化、最大化) by Yu2n
- Dim WshShell
- set wso = CreateObject("WScript.Shell")
- wso.RegWrite "HKCU\Software\Microsoft\Office\11.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
- wso.RegWrite "HKCU\Software\Microsoft\Office\12.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
- wso.RegWrite "HKCU\Software\Microsoft\Office\14.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
- Dim oExcel, oBook, oModule
- Set oExcel = CreateObject("Excel.Application")
- Set oBook = oExcel.Workbooks.Add
- Set oModule = obook.VBProject.VBComponents.Add(1)
- strCode = _
- "Private Declare Function FindWindow Lib ""user32"" Alias ""FindWindowA"" ( _" & vbCr &_
- " ByVal lpClassName As String, ByVal lpWindowName As String) As Long" & vbCr &_
- "Private Declare Function GetDesktopWindow Lib ""user32"" () As Long" & vbCr &_
- "Private Declare Function GetWindow Lib ""user32"" ( _" & vbCr &_
- " ByVal hwnd As Long, ByVal wCmd As Long) As Long" & vbCr &_
- "Private Declare Function GetClassName Lib ""user32"" Alias ""GetClassNameA"" ( _" & vbCr &_
- " ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long" & vbCr &_
- "Private Declare Function SendMessage Lib ""user32"" Alias ""SendMessageA"" ( _" & vbCr &_
- " ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long" & vbCr &_
- "Private Declare Function IsZoomed Lib ""user32"" (ByVal hwnd As Long) As Long" & vbCr &_
- "Private Declare Function IsIconic Lib ""user32"" (ByVal hwnd As Long) As Long" & vbCr &_
- "Private Const GW_HWNDFIRST = 0" & vbCr &_
- "Private Const GW_HWNDNEXT = 2" & vbCr &_
- "Private Const GW_CHILD = 5" & vbCr &_
- "Private Const WM_SYSCOMMAND = &H112" & vbCr &_
- "Private Const SC_MAXIMIZE = &HF030&" & vbCr &_
- "Public Sub IE_Maximize()" & vbCr &_
- " Dim nHWnd As Long" & vbCr &_
- " Dim s As String * 260" & vbCr &_
- " nHWnd = GetDesktopWindow()" & vbCr &_
- " nHWnd = GetWindow(nHWnd, GW_CHILD Or GW_HWNDFIRST)" & vbCr &_
- " While nHWnd <> 0" & vbCr &_
- " nHWnd = GetWindow(nHWnd, GW_HWNDNEXT)" & vbCr &_
- " s = String(256, Chr(0)): GetClassName nHWnd, s, 255: s = Replace(s, Chr(0), """")" & vbCr &_
- " If InStr(1, s, ""IEFRAME"", vbTextCompare) > 0 Then If nHWnd <> 0 Then WindowMaximize nHWnd" & vbCr &_
- " Wend" & vbCr &_
- "End Sub" & vbCr &_
- "Private Sub WindowMaximize(ByVal nHWnd As Long)" & vbCr &_
- " If IsZoomed(nHWnd) = 0 And IsIconic(nHWnd) = 0 Then SendMessage nHWnd, WM_SYSCOMMAND, SC_MAXIMIZE, ByVal 0" & vbCr &_
- "End Sub"
- oModule.CodeModule.AddFromString strCode
- Do
- oExcel.Run "IE_Maximize"
- WScript.Sleep 1000
- Loop
- oExcel.DisplayAlerts = False
- oBook.Close
- 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 不显示提示即可:- ' VBS 调用API设置IE显示模式(只允许最小化、最大化) by Yu2n
- On Error Resume Next
- Dim wso
- set wso = CreateObject("WScript.Shell")
- wso.RegWrite "HKCU\Software\Microsoft\Office\11.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
- wso.RegWrite "HKCU\Software\Microsoft\Office\12.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
- wso.RegWrite "HKCU\Software\Microsoft\Office\14.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
- Dim oExcel, oBook, oModule
- Set oExcel = CreateObject("Excel.Application")
- Set oBook = oExcel.Workbooks.Add
- Set oModule = oBook.VBProject.VBComponents.Add(1)
- strCode = _
- "Private Declare Function FindWindow Lib ""user32"" Alias ""FindWindowA"" ( _" & vbCr &_
- " ByVal lpClassName As String, ByVal lpWindowName As String) As Long" & vbCr &_
- "Private Declare Function GetDesktopWindow Lib ""user32"" () As Long" & vbCr &_
- "Private Declare Function GetWindow Lib ""user32"" ( _" & vbCr &_
- " ByVal hwnd As Long, ByVal wCmd As Long) As Long" & vbCr &_
- "Private Declare Function GetClassName Lib ""user32"" Alias ""GetClassNameA"" ( _" & vbCr &_
- " ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long" & vbCr &_
- "Private Declare Function SendMessage Lib ""user32"" Alias ""SendMessageA"" ( _" & vbCr &_
- " ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long" & vbCr &_
- "Private Declare Function IsZoomed Lib ""user32"" (ByVal hwnd As Long) As Long" & vbCr &_
- "Private Declare Function IsIconic Lib ""user32"" (ByVal hwnd As Long) As Long" & vbCr &_
- "Private Const GW_HWNDFIRST = 0" & vbCr &_
- "Private Const GW_HWNDNEXT = 2" & vbCr &_
- "Private Const GW_CHILD = 5" & vbCr &_
- "Private Const WM_SYSCOMMAND = &H112" & vbCr &_
- "Private Const SC_MAXIMIZE = &HF030&" & vbCr &_
- "Public Sub IE_Maximize()" & vbCr &_
- " Dim nHWnd As Long" & vbCr &_
- " Dim s As String * 260" & vbCr &_
- " nHWnd = GetDesktopWindow()" & vbCr &_
- " nHWnd = GetWindow(nHWnd, GW_CHILD Or GW_HWNDFIRST)" & vbCr &_
- " While nHWnd <> 0" & vbCr &_
- " nHWnd = GetWindow(nHWnd, GW_HWNDNEXT)" & vbCr &_
- " s = String(256, Chr(0)): GetClassName nHWnd, s, 255: s = Replace(s, Chr(0), """")" & vbCr &_
- " If InStr(1, s, ""IEFRAME"", vbTextCompare) > 0 Then If nHWnd <> 0 Then WindowMaximize nHWnd" & vbCr &_
- " Wend" & vbCr &_
- "End Sub" & vbCr &_
- "Private Sub WindowMaximize(ByVal nHWnd As Long)" & vbCr &_
- " If IsZoomed(nHWnd) = 0 And IsIconic(nHWnd) = 0 Then SendMessage nHWnd, WM_SYSCOMMAND, SC_MAXIMIZE, ByVal 0" & vbCr &_
- "End Sub"
- oModule.CodeModule.AddFromString strCode
- oExcel.DisplayAlerts = False
- Do
- oExcel.Run "IE_Maximize"
- WScript.Sleep 1000
- Loop
- oBook.Close False
- oExcel.Quit
复制代码
作者: ygqiang 时间: 2015-1-10 09:10
本帖最后由 ygqiang 于 2015-1-10 10:17 编辑
多谢。。。。
作者: CrLf 时间: 2015-1-10 17:25
来个 F11 的效果- Set SH = CreateObject("Shell.Application")
- For Each SHWin In SH.Windows
- If LCase(Right(SHWin.FullName, 12)) = "iexplore.exe" Then
- SHWin.FullScreen=True
- End If
- 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 编辑
- Set SH = CreateObject("Shell.Application")
- do
- For Each SHWin In SH.Windows
- If LCase(Right(SHWin.FullName, 12)) = "iexplore.exe" Then
- SHWin.FullScreen=True
- End If
- Next
- WScript.Sleep 20000
-
- loop
复制代码
CrLf给出的这个代码。win7 64+IE9环境下测试了。
有个问题。F11全屏以后,ie浏览器右上角的最小化和关闭按钮,都找不到了。如果手动按F11键,是没有这个问题的。
作者: yu2n 时间: 2015-1-11 01:02
IE_Maximize.exe 设置IE显示模式(只允许最小化、最大化)
VB6源码:
使用与结果:- C:\Documents and Settings\Yu2n>IE_Maximize.exe
- 2015-01-11 00:59:22 Initd.
- 2015-01-11 00:59:31 Maximize(2230858)
- 2015-01-11 00:59:41 Maximize(198696)
复制代码
作者: CrLf 时间: 2015-1-11 01:31
回复 5# ygqiang
两个一起用倒是可以全屏并设置 ToolBar=1:- SHWin.FullScreen=True
- SHWin.TheaterMode=True
复制代码
不过试了一下好像和 F11 的效果是不太一样,找不到在哪退出全屏
作者: CrLf 时间: 2015-1-11 01:53
来段比较暴力的 AutoHotKey:- #SingleInstance force
- #Persistent
-
- GroupAdd, IE, ahk_class IEFrame
- SetTimer WinMaximizeIE,1000
-
- WinMaximizeIE:
- WinMaximize, ahk_group IE
- 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
最终代码如下:- ' VBS 调用API设置IE显示模式(只允许最小化、最大化) by Yu2n
- On Error Resume Next
- Dim wso
- set wso = CreateObject("WScript.Shell")
- wso.RegWrite "HKCU\Software\Microsoft\Office\11.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
- wso.RegWrite "HKCU\Software\Microsoft\Office\12.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
- wso.RegWrite "HKCU\Software\Microsoft\Office\14.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
- Dim oExcel, oBook, oModule
- Set oExcel = CreateObject("Excel.Application")
- Set oBook = oExcel.Workbooks.Add
- Set oModule = oBook.VBProject.VBComponents.Add(1)
- strCode = _
- "Private Declare Function FindWindow Lib ""user32"" Alias ""FindWindowA"" ( _" & vbCr &_
- " ByVal lpClassName As String, ByVal lpWindowName As String) As Long" & vbCr &_
- "Private Declare Function GetDesktopWindow Lib ""user32"" () As Long" & vbCr &_
- "Private Declare Function GetWindow Lib ""user32"" ( _" & vbCr &_
- " ByVal hwnd As Long, ByVal wCmd As Long) As Long" & vbCr &_
- "Private Declare Function GetClassName Lib ""user32"" Alias ""GetClassNameA"" ( _" & vbCr &_
- " ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long" & vbCr &_
- "Private Declare Function SendMessage Lib ""user32"" Alias ""SendMessageA"" ( _" & vbCr &_
- " ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long" & vbCr &_
- "Private Declare Function IsZoomed Lib ""user32"" (ByVal hwnd As Long) As Long" & vbCr &_
- "Private Declare Function IsIconic Lib ""user32"" (ByVal hwnd As Long) As Long" & vbCr &_
- "Private Const GW_HWNDFIRST = 0" & vbCr &_
- "Private Const GW_HWNDNEXT = 2" & vbCr &_
- "Private Const GW_CHILD = 5" & vbCr &_
- "Private Const WM_SYSCOMMAND = &H112" & vbCr &_
- "Private Const SC_MAXIMIZE = &HF030&" & vbCr &_
- "Public Sub IE_Maximize()" & vbCr &_
- " Dim nHWnd As Long" & vbCr &_
- " Dim s As String * 260" & vbCr &_
- " nHWnd = GetDesktopWindow()" & vbCr &_
- " nHWnd = GetWindow(nHWnd, GW_CHILD Or GW_HWNDFIRST)" & vbCr &_
- " While nHWnd <> 0" & vbCr &_
- " nHWnd = GetWindow(nHWnd, GW_HWNDNEXT)" & vbCr &_
- " s = String(256, Chr(0)): GetClassName nHWnd, s, 255: s = Replace(s, Chr(0), """")" & vbCr &_
- " If InStr(1, s, ""IEFRAME"", vbTextCompare) > 0 Then If nHWnd <> 0 Then WindowMaximize nHWnd" & vbCr &_
- " Wend" & vbCr &_
- "End Sub" & vbCr &_
- "Private Sub WindowMaximize(ByVal nHWnd As Long)" & vbCr &_
- " If IsZoomed(nHWnd) = 0 And IsIconic(nHWnd) = 0 Then SendMessage nHWnd, WM_SYSCOMMAND, SC_MAXIMIZE, ByVal 0" & vbCr &_
- "End Sub"
- oModule.CodeModule.AddFromString strCode
- oExcel.DisplayAlerts = False
- Do
- oExcel.Run "IE_Maximize"
- WScript.Sleep 1000
- Loop
- oBook.Close False
- oExcel.Quit
复制代码
作者: ygqiang 时间: 2015-1-21 18:46
最终代码如下:- On Error Resume Next
- Set objShell = CreateObject("Shell.Application")
- Do
- For Each i In objShell.Windows()
- If InStr(1, i.FullName, "\IEXPLORE.EXE", 1) > 0 Then
- If i.TheaterMode = False Then i.TheaterMode = True
- End If
- Next
- WScript.Sleep 1000
- Loop
复制代码
- (echo On Error Resume Next
- echo Set objShell = CreateObject^("Shell.Application"^)
-
- echo Do
- echo For Each i In objShell.Windows^(^)
- echo If InStr^(^1, i.FullName, "\IEXPLORE.EXE", ^1^) ^> ^0 Then
- echo If i.TheaterMode = False Then i.TheaterMode = True
- echo End If
- echo Next
- echo WScript.Sleep 1000
- echo Loop
- )>"c:\iefull.vbs"
复制代码
作者: zhangop9 时间: 2021-1-7 15:08
监测ie 最大化
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |