#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=C:\WINDOWS\system32\SHELL32.dll|-131
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
;IE用……快速保存网页为文本……热键……^s
;;;;;测试环境:IE8;;;;;;;;;;;;;;;;;
;
;~ #CS 加入任务栏控制菜单
Opt("TrayMenuMode",1)
Dim $Pause=1
$KillIEitem = TrayCreateItem("I`E`") ;IE被冻……KILL了重启
TrayCreateItem("")
TrayCreateItem("")
$NetTransportitem = TrayCreateItem("流量")
TrayCreateItem("")
$prefsitem = TrayCreateItem("暂停")
TrayCreateItem("")
$restart = TrayCreateItem("重启")
TrayCreateItem("")
$exititem = TrayCreateItem("退出")
TraySetState()
TraySetToolTip("IE用:快速保存网页为文本-热键…Ctrl+s…")
;~ #CE
;~ #CS
$mycfg = StringReplace(@ScriptName,".au3","",-1,0)
$mycfg = StringReplace($mycfg,".exe","",-1,0)
$mycfg = @ScriptDir&""&$mycfg&".ini"
;Exit ( MsgBox(0,"",$mycfg) )
If Not FileExists($mycfg) Then ;生成配置文件
iniWrite ($mycfg, "流量","显示", 1)
FileWrite ($mycfg, ""&@CRLF)
iniWrite ($mycfg, "关于软件","例行说明","IE用:快速保存网页为文本。热键:Ctrl+s")
iniWrite ($mycfg, "关于软件","配置日期",@YEAR&"年"&@MON&"月"&@MDAY&"日 "&@HOUR&":"&@MIN&":"&@SEC)
FileWrite ($mycfg, ""&@CRLF)
EndIf
$ToolTip = IniRead($mycfg, "流量","显示","")
;Exit ( MsgBox(0,"",$ToolTip) )
;~ #CE
Opt("WinTitleMatchMode", 2) ;宽松匹配 ;WinActivate("Windows Internet Explorer")
Opt("SendAttachMode", 1) ;绑定模式(应该是后续的字符操作相当是之前按键盘的延续……现时是这样理解的,如是,则不会出现由于之前键按久了的字符连发乱发,要发也等操作完再去发..)
HotKeySet("^s","_cs")
;~
AdlibRegister("HKSet");;;;----自动设置热键
Func HKSet()
; If WinActive("Windows Internet Explorer") Or isIE() Then
If isIE() Then
; If WinActive("Windows Internet Explorer") Then
If $Pause Then HotKeySet("^s","_cs") ;启用
Return
Else
HotKeySet("^s") ;取消
Return
EndIf
EndFunc
;~
Func _cs()
$Pause = 0 ;自动函数用
HotKeySet("^s") ;解除热键,必须的,防止操作没完成之前被再次重复调用
If Not WinActive("Windows Internet Explorer") Then ;如果当前非IE则不执行以下操作,以避免与其他发生窗口冲突
Sleep(2000); 挂起!以兼容其他软件的快捷键(须连续按2次Ctrl+s才起作用)——最好注册自动函数进行自动检测(上面已使用)
$Pause = 1
HotKeySet("^s","_cs") ;启用热键
Return
;~ ElseIf Not isIE() Then
;~ Sleep(2000);
;~ $Pause = 1
;~ HotKeySet("^s","_cs")
;~ Return
EndIf
ControlSend ( "Windows Internet Explorer","", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "!fa" , 0 ) ;
; Send("!fa")
; WinActivate("保存网页")
; MsgBox(0,"","ok")
$exitloop=0
While Not WinActive("保存网页")
If $exitloop > 9 Then ExitLoop ;5秒钟内操作不成功则退出!(有些窗口会限制)
Sleep(500) ;如果窗口还没出现则挂起
If Not WinActive("保存网页") Then Send("!fa");循环内发送……用于除错,保证不被系统遗留键击影响以致被挂起……使用键盘整合还是有点不兼容!
$exitloop += 1
WEnd
; WinActivate("保存网页")
; If WinActive("保存网页") Then ;安全发送
;~ Send("{tab}")
;~ Send("{down 3}")
;~ Send("{ENTER 2}")
;~ Send("!t") ;反应慢
;~ Send("{down 3}")
;~ Send("!s")
; EndIf
; ControlSend ( "窗口标题", "窗口文本", 控件ID, "字符串" [, 标志] )
; ControlSend ( "保存网页","", "[CLASS:Edit; INSTANCE:1]", "{TAB}" , 0 ) ;, 1148
ControlSend ( "保存网页","", "[CLASS:ComboBox; INSTANCE:3]", "{down 3}" , 0 ) ;1136,
ControlSend ( "保存网页","", "[CLASS:Button; INSTANCE:2]", "{enter}" , 0 ) ;1,
While WinActive("保存网页")
Sleep(1000) ;如果当前窗口还在则挂起,原来用于挂起外循环,改用函数了应该也有点作用!
WEnd
$Pause = 1
HotKeySet("^s","_cs") ;启用热键
EndFunc
;~ #CS ;;;;----网络流量
Dim $s[2] = [0,0] ;$s[0] = 0 ;$s[1] = 0
$strComputer = "."
$wbemServices = ObjGet("winmgmts:\" & $strComputer & "\root\cimv2")
If $ToolTip = 1 Then AdlibRegister("NetTransport",1000)
;~ While 1
;~ NetTransport()
;~ Sleep(1000) ;每秒取值
;~ WEnd
Func NetTransport()
$wbemObjectSet = $wbemServices.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface")
For $wbemObject In $wbemObjectSet
$s[0] = $s[0] + $wbemObject.BytesReceivedPerSec
Next
$NetTransport = $s[0] - $s[1]
;<\\---加入(显示流量时:同时提示快捷键状态)
Switch $Pause
Case 1
$Kset="快捷键已启用"&@CRLF
Case 0
$Kset="快捷键未启用"&@CRLF
EndSwitch
;---//>
If $s[1] Then ToolTip($Kset&"网络流量:" & $NetTransport & " Bytes/s", @DesktopWidth - 170, @DesktopHeight - 80,"",1,0)
$s[1] = $s[0]
$s[0] = 0
EndFunc
;~ #CE
While 1
;~ #CS 任务栏菜单控制
$msg = TrayGetMsg()
Select
Case $msg = 0
ContinueLoop
Case $msg = $prefsitem
If $Pause Then
$Pause = 0
HotKeySet("^s")
Else
$Pause = 1
HotKeySet("^s","_cs")
EndIf
Case $msg = $restart
Exit( Run(@ScriptFullPath) ) ;必须编译
Case $msg = $exititem
Exit ;Loop
Case $msg = $NetTransportitem ;查看流量
If $s[1] Then
ToolTip("", @DesktopWidth - 170, @DesktopHeight - 80,"",1,0)
AdlibUnRegister("NetTransport")
$s[1] = 0
iniWrite ($mycfg, "流量","显示", 0)
Else
AdlibRegister("NetTransport",1000)
iniWrite ($mycfg, "流量","显示", 1)
EndIf
Case $msg = $KillIEitem ;IE被冻……KILL了重启
$YES = MsgBox(262144+292,"警告","你将要重启IE"&@CRLF&@CRLF&"IE没反应了吗") ;4+32+256+262144
If $YES="YES" Or $YES=6 Then
While ProcessExists("iexplore.exe")
ProcessClose("iexplore.exe")
WEnd
ShellExecute(@ProgramFilesDir&"\Internet Explorer\iexplore.exe","",@HomeDrive&@HOMEPATH,"open",@SW_MAXIMIZE)
EndIf
EndSelect
;~ #CE
; Sleep(500)
WEnd
Func isIE()
Local $states[6] = [1,2,4,8,16,32]
Local $aWList = WinList(), $iWList = ProcessList ("IExplore.exe") ;$iPID = ProcessExists("IExplore.exe")
For $iec = 1 To $iWList[0][0]
For $iCC = 1 To $aWList[0][0]
If $aWList[$iCC][0] <>"" And WinGetProcess($aWList[$iCC][1]) = $iWList[$iec][1] Then
; If BitAND(WinGetState($aWList[$iCC][1]),8) Then Return 1
For $isa=0 To 5
If BitAND(WinGetState($aWList[$iCC][1]),8) = $states[$isa] Then Return 1
Next
EndIf
Next
Next
Return 0
EndFunc
#CS
;~ ;
;~ ;</-- test - 不知所以,当然不知其所以然 //->
;~ ;
#CE
Exit
#CS
;~ ;
;~ ;</-- test - 不知所以,当然不知其所以然 //->
;~ ;
#CE