How do I manage 2 seperate ErrorMsg handlers and in the same script? do I just use one and call from IE and SQL? Or I have to reg and unreg after each use?
SQL Function
IE Functions
SQL Function
_SQL_RegisterErrorHandler() Global $oADODB = _SQL_Startup() If $oADODB = $SQL_ERROR then LOGDATA($LEVEL, "ETSSO MANAGER DEBUG",_SQL_GetErrMsg()&@CRLF) If _SQL_Connect($oADODB,$SQLSvr,"",$sqladm,$sqlpwd) = $SQL_ERROR then HideLogonprogress() MsgBox(4096,"Logon Failure","Either the instance name or the credentials are incorrect.") LOGDATA($LEVEL, "ETSSO MANAGER DEBUG","authentication Failure, or incorrectly defined SQL Server.") GUISetState(@SW_SHOW,$loggui) Return Else Local $saveinfochk = GUICtrlRead($SaveInfo) Global $XylocSetting= GUICtrlRead($XylocInfo) If $saveinfochk=1 Then $serverinstance=GUICtrlRead($SQLSvrdata) IniWrite(@ScriptDir&"\Data\Settings.ini","Server Settings","Name",$serverinstance) $serveradmin=GUICtrlRead($SQLadmdata) IniWrite(@ScriptDir&"\Data\Settings.ini","Server Settings","Admin",$serveradmin) $serveradminpwd=GUICtrlRead($sqlpwddata) IniWrite(@ScriptDir&"\Data\Settings.ini","Server Settings","Pwd",_Base64Encode($serveradminpwd)) LOGDATA($LEVEL, "ETSSO MANAGER DEBUG","Saving Credential Data in ../Data/Settings.ini.") Else IniWrite(@ScriptDir&"\Data\Settings.ini","Server Settings","Name","") IniWrite(@ScriptDir&"\Data\Settings.ini","Server Settings","Admin","") IniWrite(@ScriptDir&"\Data\Settings.ini","Server Settings","Pwd","") LOGDATA($LEVEL, "ETSSO MANAGER DEBUG", "Clearing ini settings in ../Data/Settings.ini." & $LEVEL) EndIf _SQL_UnRegisterErrorHandler() _SQL_Close() EndIf
IE Functions
Func StartApp()
_SQL_UnRegisterErrorHandler()
_IEErrorHandlerRegister("_ErrFunc")
Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
;ConsoleWrite(GUICtrlRead($AppType1)&@CRLF)
If GUICtrlRead($AppType) = "Internet Explorer" then
Global $oIEEvents = ObjEvent($oIE, "_IEEvent_", "DWebBrowserEvents2")
Global $oInputs = _IETagNameGetCollection($oIE, "input")
For $oInput In $oInputs
;ConsoleWrite($oInput.name&@CRLF)
GUICtrlSetData($logontitle,_IEPropertyGet($oIE,"title"))
GUICtrlSetData($LAppPath,_IEPropertyGet($oIE,"locationurl"))
GUICtrlSetData($logonctrl, $oInput.name,"") ; add other item
GUICtrlSetData($pwdctrl, $oInput.name,"") ; add other item
GUICtrlSetData($submitctrl, $oInput.name,"") ; add other item
Next
EndIf
EndFunc
Func ShowLogonCtrl()
_SQL_UnRegisterErrorHandler()
_IEErrorHandlerRegister("_ErrFunc")
$o_form = _IEFormGetCollection($oIE,0)
$n_Forms = @extended
;ConsoleWrite("Forms Found:"&$n_Forms&@CRLF)
$o_Elements = _IEFormElementGetCollection($o_form,0)
$n_Elements = @extended
;ConsoleWrite("Elements Found:"&$n_Elements&@CRLF)
Local $oInputs = _IETagNameGetCollection($oIE, "input")
For $oInput In $oInputs
If $oInput.name = GUICtrlRead($logonctrl,1) Then
Global $iScreenX = _IEPropertyGet($oInput, "screenx")
Global $iScreenY = _IEPropertyGet($oInput, "screeny")
Local $iBrowserX = _IEPropertyGet($oInput, "browserx")
Local $iBrowserY = _IEPropertyGet($oInput, "browserY")
Global $iWidth = _IEPropertyGet($oInput, "width")
Global $iHeight = _IEPropertyGet($oInput, "height")
ConsoleWrite("X:"&$iScreenX&@CRLF&"Y:"&$iScreenY&@CRLF&"W:"&$iWidth&@CRLF&"H:"&$iHeight)
ToolTip("Logon Control",$iScreenX,$iScreenY,"","")
sleep(3000)
ToolTip("")
EndIf
Next
WinActivate(GUICtrlRead($logontitle,1))
Return
EndFunc