求大神帮忙,帮我添加一个IE
帮我把按钮添加成分页面 就是网站页面#include <ButtonConstants.au3>
#include "GUIConstantsEx.au3"
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <IE.au3>
#include <Misc.au3>
Opt("GUIOnEventMode", 1)
Local $Button2,$Form80,$Form,$r = 1,$i = 0 ,$t = 0, $n = 0,$b = 0,$Form2,$Text,$Text2="",$URL = "http://www.scjj.gov.cn:8635/"
$dll = DllOpen("user32.dll")
$WebBrowser2=ObjCreate("Shell.Explorer.2")
$Form0 = GUICreate("驾考专业工具 QQ群20160452 声明:本软件只方便测试研究之用,禁止非法使用", 1024, 768, 192, 114,$WS_OVERLAPPEDWINDOW) ;主窗体
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ;GUIOnEventMode 模式下添加窗口关闭
$Graphic1 = GUICtrlCreateGraphic(0, 0, @DesktopWidth, 0) ;(左 顶 宽 高) 添加绘图控件
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, 30) ; 移位 绘图控件坐标0原点,移动起点到新坐标,下移30
GUICtrlSetGraphic(-1, $GUI_GR_LINE, @DesktopWidth, 30) ; 横线 从新起点画一横线
;GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 5) ; 定义此点画线粗细
$Button1 = GUICtrlCreateButton("四川驾校报考网站", 0, 36, 110, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$Button75 = GUICtrlCreateButton("第一界面", 0, 0, 75, 30) ;定义主窗口基本功能按钮
GUICtrlSetResizing (-1, $GUI_DOCKALL) ;
$Button76 = GUICtrlCreateButton("第二界面", 80, 0, 75, 30)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$Button77 = GUICtrlCreateButton("第三界面", 160, 0, 75, 30)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$Button78 = GUICtrlCreateButton("约考界面", 240, 0, 75, 30)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$Button79 = GUICtrlCreateButton("打印界面", 320, 0, 75, 30)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$Button81 = GUICtrlCreateButton("退出", 400, 0, 75, 30)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$Button80 = GUICtrlCreateButton("帮助", 480, 0, 75, 30)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
GUICtrlSetOnEvent($Button1, "Activate1")
GUICtrlSetOnEvent($Button75, "Activate75")
GUICtrlSetOnEvent($Button76, "Activate76")
GUICtrlSetOnEvent($Button77, "Activate77")
GUICtrlSetOnEvent($Button78, "Activate78")
GUICtrlSetOnEvent($Button79, "Activate79")
GUICtrlSetOnEvent($Button80, "Activate80")
GUICtrlSetOnEvent($Button81, "Activate81") ; 设置按钮控件单击事件
GUISetState(@SW_SHOW)
;------------------------------------------------
$Form1 = GUICreate("首窗", 1024, 650, 0, 60,$WS_POPUP) ;设置初载的首页窗体Form1
DllCall("user32.dll","hwnd","SetParent","hwnd",$Form1,"hwnd",$Form0) ;设置Form1yl为Form0的子窗口.
;_WinAPI_SetParent与DllCall-"SetParent"等效。对比学习两者的关系。
;_WinAPI_SetParent($Form1,$Form0)
$WebBrowser1=ObjCreate("Shell.Explorer.2") ;等效 _IECreateEmbedded()
GUICtrlCreateObj($WebBrowser1,0, 0, 1024, 750) ;设置WebBrowser1对象大小
$EventObject=ObjEvent($WebBrowser1,"IEEvent_","DWebBrowserEvents") ;设置接收windows事件
if @error then exit Msgbox(0,"错误!","不可使用COM接口 'DWebBrowserEvents'. 错误代码: " & hex(@error,8))
$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword") ;设置Timer控件
$TimerDLL = DllCall($dll, "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 10, "ptr", DllCallbackGetPtr($Timer))
;函数SetTimer,用WM_TIMER来设置定时器。每隔10毫秒自动执行一次DllCallbackRegister,创建自定义回调函数Timer
;参看后面的Timer()事件
$WebBrowser1.Navigate( $URL) ;自定义首页
GUISetState(@SW_SHOW)
GUISwitch ($Form0) ;切换当前窗口到主窗口
;-------------------------------------------------------------
While 1
Sleep (1)
$cursor = _WinAPI_GetCursorInfo() ;获取鼠标状态
If $cursor=65581 And _IsPressed("1", $dll) Then
WinSetOnTop($Form1,"",1)
MsgBox(0,"IE内嵌不新建IE窗口", "0",1,WinGetHandle("Program Manager"))
WinSetOnTop($Form1,"",0)
If $Text2<>"" Then
WebBrowser1_Navigate() ;自定义打开新页事件
EndIf
EndIf
$msg = GUIGetMsg()
Wend
;-------------------------------------------------------------
Func WebBrowser1_Navigate()
GUISwitch($Form0)
$r = $r + 1
$Form[$r] = GUICreate($Text2, 1024, 650, 0, 60,$WS_POPUP);设置$Form[$r]作为装载IE新页面的窗体
_WinAPI_SetParent($Form[$r],$Form0) ;设置Form[$r]为Form0的子窗口.
$WebBrowser2=ObjCreate("Shell.Explorer.2")
GUICtrlCreateObj($WebBrowser2, -12, 0, 1024, 750)
$EventObject=ObjEvent($WebBrowser2,"IEEvent_","DWebBrowserEvents")
if @error then exit Msgbox(0,"错误!","不可使用COM接口 'DWebBrowserEvents'. 错误代码: " & hex(@error,8))
$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$TimerDLL = DllCall($dll, "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 10, "ptr", DllCallbackGetPtr($Timer))
$WebBrowser2.Navigate( $Text2 )
GUISetState(@SW_SHOW)
EndFunc
;--------------------------------------------
Func IEEvent_TitleChange($URL) ; 接收IE的TitleChange事件。获取网页标题。在可以获取title时发生,较晚。
If StringInStr($URL, "_") ="_" Then ; 将$URL标题中含有_的标题剔除wwwTab()
$i = $i + 1
IniWrite("title.ini", "title"&$i,"", $URL) ; 将所获得的URL标题写入配置ini文件
EndIf
EndFunc
;----------------------------------------
Func IEEvent_StatusTextChange ($Text) ; 接收IE的IEEvent_StatusTextChange事件。
If $Text<>'' And StringLeft($Text,4)="http" Then $Text2=$Text
EndFunc
;====================================================================================
Func wwwTab()
GUISwitch ($Form0)
$var2 = IniRead("title.ini", "title4", "", "no")
$var3 = IniRead("title.ini", "title6", "", "no")
$var4 = IniRead("title.ini", "title8", "", "no")
$var5 = IniRead("title.ini", "title10", "", "no")
$Button2 = GUICtrlCreateButton($var2, 110, 36, 110, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$contextmenu = GUICtrlCreateContextMenu ($Button2) ; 创建右键菜单
$FormCLOSE2 = GUICtrlCreateMenuitem ("关闭",$contextmenu) ; 关闭此窗口
GUICtrlSetOnEvent($FormCLOSE2, "FormCLOSE2")
$Button3 = GUICtrlCreateButton($var3, 220, 36, 110, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$Button4 = GUICtrlCreateButton($var4, 330, 36, 110, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
$Button5 = GUICtrlCreateButton($var5, 440, 36, 110, 25)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
GUICtrlSetOnEvent($Button2, "Activate2")
GUICtrlSetOnEvent($Button3, "Activate3")
GUICtrlSetOnEvent($Button4, "Activate4")
GUICtrlSetOnEvent($Button5, "Activate5")
If $var2 = "no" Then
GUICtrlSetState ( $Button2, $GUI_HIDE); 控件隐藏$GUI_HIDE
Else ; 否则
GUICtrlSetState ( $Button2, $GUI_SHOW); 控件显示$GUI_SHOW
EndIf
If $var3 = "no" Then
GUICtrlSetState ( $Button3, $GUI_HIDE)
Else
GUICtrlSetState ( $Button3, $GUI_SHOW)
EndIf
If $var4 = "no" Then
GUICtrlSetState ( $Button4, $GUI_HIDE)
Else
GUICtrlSetState ( $Button4, $GUI_SHOW)
EndIf
If $var5 = "no" Then
GUICtrlSetState ( $Button5, $GUI_HIDE)
Else
GUICtrlSetState ( $Button5, $GUI_SHOW)
EndIf
EndFunc ;==>wwwTab()自定义的窗体按钮标签事件
;=================================================================
Func Activate1()
_WinAPI_SetParent($Form1,$Form0) ;用重设子窗口的方式来激活指定窗口。在SetParent之后,WinActivate,PostMessage都失效。
EndFunc ;==>Activate1
Func Activate2()
_WinAPI_SetParent($Form,$Form0)
EndFunc ;==>Activate2
Func Activate3()
_WinAPI_SetParent($Form,$Form0)
EndFunc ;==>Activate3
Func Activate4()
_WinAPI_SetParent($Form,$Form0)
EndFunc ;==>Activate4
Func Activate5()
_WinAPI_SetParent($Form,$Form0)
EndFunc ;==>Activate5
;----------------------------------------------------------------
Func Activate75()
_IEAction ($WebBrowser2, "stop")
EndFunc ;==>Activate81
Func Activate76()
_IEAction ($WebBrowser2, "forward")
EndFunc ;==>Activate81
Func Activate77()
_IEAction ($WebBrowser2, "back")
EndFunc ;==>Activate81
Func Activate78()
_IEAction ($WebBrowser2, "refresh")
EndFunc ;==>Activate81
Func Activate79()
_IEAction ($WebBrowser2, "home")
EndFunc ;==>Activate81
Func Activate80()
GUISwitch ($Form0)
$Form80 = GUICreate("帮助", 400, 300, 250, 214)
$Button801 = GUICtrlCreateButton("关闭",165,267,88, 30)
GUICtrlSetOnEvent($Button801, "CLOSEActivate80")
GUISetState(@SW_SHOW)
EndFunc ;==>Activate80
Func CLOSEActivate80()
_WinAPI_SetParent($Form80,$Form0)
_WinAPI_MoveWindow($Form80, 0, 0, 0, 0, True)
EndFunc ;==>Activate81
Func FormCLOSE2()
_WinAPI_MoveWindow($Form, 0, 0, 0, 0, True)
GUICtrlSetData ($Button2,"")
GUICtrlSetState ($Button2, $GUI_HIDE)
EndFunc
;----------------------------------------------------------------
Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
If WinExists("IE内嵌不新建IE窗口") Then
WinMove("IE内嵌不新建IE窗口","",@DesktopWidth,@DesktopHeight,0,0,1)
Send("{Enter}")
EndIf
EndFunc
Func CLOSE()
$EventObject.Stop ; 不再接收事件
$EventObject=0 ; 关闭Event Object
$WebBrowser1=0 ; 清除内存
GUIDelete ()
DllCall($dll, "int", "KillTimer", "hwnd", 0, "uint", $TimerDLL)
DllCallbackFree($Timer)
DllClose($dll)
FileDelete("title.ini");直接删除
;MsgBox(0, "谢谢", "报歉!学做的东西!...",3)
Exit
EndFunc
Func Activate81()
CLOSE()
EndFunc ;==>Activate81
Func CLOSEClicked()
CLOSE()
EndFunc
谢谢 我搞了2天就是没搞出来{:face (319):}
页:
[1]