Blame | Last modification | View Log | Download
; *******************************************************; Example 1 - Trap COM errors so that 'Back' and 'Forward'; outside of history bounds does not abort script; (expect COM errors to be sent to the console); *******************************************************;#include <GUIConstantsEx.au3>#include <WindowsConstants.au3>#include <SendMessage.au3>#include <IE.au3>;initialize the command line parameter string$params = "";Get the commandline and build the parameter list for webclientFor $i = 1 to $CmdLine[0] step 1$params = $params & " " & $CmdLine[$i]Next;start webclient with parameters;Run("graph.exe" & $params)$WebClientPage = "C:\Program Files\Siemens\FactoryLink\Client\WebClient\Samples\En\webdef.htm"HotKeySet("!{F11}", "Maximize")HotKeySet("!{F4}", "WcExit")HotKeySet("!{F5}", "WcRefresh")_IEErrorHandlerRegister ()$oIE = _IECreateEmbedded()$handle = GUICreate( "Metrex - Webclient", _@DesktopWidth, @DesktopHeight, _0, 0, _$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)$size = WinGetClientSize( $handle)$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, @DesktopWidth, @DesktopHeight)$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)$GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30)GUISetState() ;Show GUI_IENavigate ($oIE, $WebClientPage)$oIE.document.body.scroll = "no";$oIE.navigate ("C:\Program Files\Siemens\FactoryLink\Client\WebClient\Samples\En\webdef.htm");get the PID for graph.exe, so we can check if the process is still running$webclient = ProcessExists( "autoit3.exe");msgbox(0, "Debug", String($webclient)); Waiting for user to close the windowWhile 1$msg = GUIGetMsg()SelectCase $msg = $GUI_EVENT_CLOSEExitLoopCase $msg = $GUI_Button_Home_IENavigate ($oIE, $WebClientPage);Case $msg = $GUI_Button_Back;_IEAction ($oIE, "back");Case $msg = $GUI_Button_Forward;_IEAction ($oIE, "forward"); Case $msg = $GUI_Button_Stop; ExitLoop;_IEAction ($oIE, "stop")Case $msg = $GUI_EVENT_MAXIMIZE;GUISetStyle( 0)Case $msg = $GUI_EVENT_MINIMIZE;$size = WinGetClientSize( $handle)Case $msg = $GUI_EVENT_RESIZED;$size = WinGetClientSize( $handle);$oIE.Width = $size[0];$oIE.Height = $size[1]Case $msg = $GUI_EVENT_RESTORE;GUISetStyle($WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)Case Else$size = WinGetClientSize( $handle)$oIE.Width = $size[0]$oIE.Height = $size[1]EndSelect$oIE.document.body.scroll = "no"WEndGUIDelete()ExitFunc Maximize()Local Const $SC_MAXIMIZE = 0xF030, $SC_RESTORE = 0xF120Local $sStateIf BitAND(WinGetState($handle), 32) = 0 Then ; Not Maximised$sState = $SC_MAXIMIZE;GUISetStyle( 0)Else$sState = $SC_RESTORE;GUISetStyle($WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)EndIfReturn _SendMessage($handle, $WM_SYSCOMMAND, $sState)EndFunc ;==>MaximizeFunc WcExit()ExitEndFunc ;==>WcExitFunc WcRefresh()_IENavigate ($oIE, $WebClientPage)EndFunc