r3d2dawn Posted February 12, 2008 Share Posted February 12, 2008 Hey All, yes I am a newb here and newb to AutoIt and scripting I have a script called keeform that works with keepass and will open IE and enter the user/pass, my question is how do I take it to work with firefox? Also where do I even begin to learn the various lines of code to use with AutoIt to do the things I want ( are their books or sites with more detailed information)? I see the script/code as to where it instructs IE to open, but can just that portion and the global $oIE be changed to specify Firefox or is this script soley for IE? here is the script expandcollapse popup; KeeForm v1.07 ; ; Copyright (C) 2005 - 2007 dave_keepass at users.sourceforge.net ; ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ; ; ; version 01: - Autohotkey version. Idea because of KeePass Auto-Type ; version 02: - AutoIt version. IE automation idea from ie.au3 Dale Hohm ; version 03: - improved "special character" issue - patch idea by Mr Fly ; - fixed "very long window title" issue ; - added {SUBMIT} {CLICK} - DOM tips and tricks by Chris Sauer ; version 1.04: - added {NOFOCUS} and enabled error handler ; version 1.04+: - added {ENTERFORM}, improved "no password message" ; - improved handling of cross frame security issues ; - added debug mode (new _KeeDebug functions) ; version 1.05: - use ENTERFORM only if no auto-type, else ENTER ; for "+{TAB}{DEL}fieldname{ENTERFORM}" issue ; ENTERFORM executed before fieldname printed ; - print date in sys info ; - Fixed issue in FindFrames (replaced >< with > <) ; - IE7 beta 2 compatible (TabWindowClass) ; version 1.06: - Suppress Password Not Found pop up, if not needed ; - Fixed small bug (Set focus debug message always displayed) ; - Run FormFiller, only if password or username is not empty ; - Use default for SendKeyDelay ; - Compiled with AutoIt version v3.2.0.1 (not beta anymore) ; version 1.07: - Compiled with AutoIt version v3.2.10.0 ; - Used new StringRegExpReplace (replacing special character substitution) ; - Test for Password field done before filling of fields ; - Improved error messages ; - {FILLALLPASSWORDS} option ; TODO - try to find "Shell Embedding" if "TabWindowClass" not found Global $KeeformVersion = "Keeform v1.07 1/1/2007" #include "KeeDebug.au3" Opt("WinTitleMatchMode", 2) Opt("MustDeclareVars", 1) ;Opt("SendKeyDelay", 1) Global $VK_RETURN = 0x0d ; required for {ENTERFORM} Global $WM_KEYDOWN = 0x0100 Global $oButtonElement ; button/image that we want to click Global $oPasswordForm ; Form with password Global $oIE ; Internet Explorer browser object Global $oMyError Global $Url Global $Username Global $Password Global $Autotype = "" ; string that contains misc commands Global $ButtonPressed = False Global $PasswordFound = False Global $SubmitEnabled = False Global $EnterFormEnabled = False Global $ClickEnabled = False Global $FocusDisabled = False Global $FillAllPasswords = False Global $FramesOutputEnabled = False Global $ErrorHandlerOn = True Global $ErrorHandlerMsgboxOn = True ; Debug turned on? If $CmdLine[0] = 5 Then ; $_KeeDebugLevel = $_KeeDebugLevelAll $_KeeDebugLevel = CheckDebugFlags ($CmdLine[5]) Else $_KeeDebugLevel = $_KeeDebugLevelOff EndIf _KeeDebugEnter ($KeeformVersion) PrintSystemInformation () _KeeDebugPrint ("CmdLine[0] = " & $CmdLine[0]) ; User needs to specify at least 3 arguments. Fourth one is optional if $CmdLine[0] < 3 or $CmdLine[0] > 5 Then MsgBox (0, 'KeeForm Error', 'Correct syntax is: KeeForm "URL" "Username" "Password" ["Autotype"]') _KeeDebugPrint ("incorrect syntax") _KeeDebugLeave ($KeeformVersion) exit EndIf ; _KeeDebugPrint ("CmdLineRaw = " & $CmdLineRaw) $Url = $CmdLine[1] $Username = $CmdLine[2] $Password = $CmdLine[3] _KeeDebugPrint ("CmdLine[1] = " & $CmdLine[1]) _KeeDebugPrint ("CmdLine[2] = " & "{USERNAME}") _KeeDebugPrint ("CmdLine[3] = " & "{PASSWORD}") If $CmdLine[0] >= 4 Then $Autotype = $CmdLine[4] _KeeDebugPrint ("CmdLine[4] = " & $CmdLine[4]) EndIf If $CmdLine[0] = 5 Then _KeeDebugPrint ("CmdLine[5] = " & $CmdLine[5]) EndIf ; Intercept error messages from Internet Explorer If $ErrorHandlerOn = True Then $oMyError = ObjEvent ("AutoIt.Error", "MyErrorHandler") _KeeDebugPrint ("AutoIt.Error started") EndIf ; Form Filler changes the focus to the first password field ; useful for web sites, that don't set any focus ; If not wanted, then disable CheckAndSetFlag ($Autotype, $FocusDisabled, "{NOFOCUS}") CheckAndSetFlag ($Autotype, $FillAllPasswords, "{FILLALLPASSWORDS}") ; Open Internet Explorer _KeeDebugPrint ("ObjCreate(InternetExplorer.Application)", $_KeeDebugLevelInfo) $oIE = ObjCreate("InternetExplorer.Application") _KeeDebugPrint ("ObjName ($oObject) = " & ObjName ($oIE), $_KeeDebugLevelErr) With $oIE ; Show browser window .Visible = True Do ; _KeeDebugPrint ("Sleep ", $_KeeDebugLevelInfo) Sleep(100) Until (.readyState = "complete" Or .readyState = 4) _KeeDebugPrint ("Created " & .FullName , $_KeeDebugLevelInfo) ; Navigate to URL; wait until IE and page is loaded .Navigate($Url) Do ; _KeeDebugPrint ("Sleep ", $_KeeDebugLevelInfo) Sleep(100) Until (.readyState = "complete" Or .readyState = 4) Do Sleep(100) ; _KeeDebugPrint ("Sleep ", $_KeeDebugLevelInfo) Until (.document.readyState = "complete" Or .document.readyState = 4) _KeeDebugPrint ("Navigated to " & $Url , $_KeeDebugLevelInfo) EndWith _KeeDebugPrint ("IE location name = " & $oIE.locationname, $_KeeDebugLevelInfo) _KeeDebugPrint ("IE location url = " & $oIE.locationurl, $_KeeDebugLevelInfo) RecurseIntoFrames($oIE, True) ; Check whether a form with a password field exists ; If not, most likely already logged in ; But give user the option to continue _KeeDebugPrint ("PasswordFound = " & $PasswordFound, $_KeeDebugLevelInfo) If $PasswordFound = False Then If $Username = "" and $Password = "" Then _KeeDebugPrint ("Username and Password empty", $_KeeDebugLevelInfo) _KeeDebugLeave ($KeeformVersion) Exit EndIf $ButtonPressed = MsgBox (1,"KeeForm Warning", $URL & @CRLF & $oIE.locationname & @CRLF & "No password field found. Do you really want to continue?",10) _KeeDebugPrint ("ButtonPressed = " & $ButtonPressed, $_KeeDebugLevelInfo) If $ButtonPressed <> 1 Then _KeeDebugPrint ("no password found", $_KeeDebugLevelErr) _KeeDebugLeave ($KeeformVersion) Exit EndIf EndIf $PasswordFound = False If $Username <> "" or $Password <> "" Then ; Fill form, also within frames RecurseIntoFrames($oIE, False) EndIf ; Check if Autotype wanted _KeeDebugPrint ("Autotype = " & $Autotype & " (before exit check)", $_KeeDebugLevelInfo) If $Autotype = "" Then _KeeDebugPrint ("Autotype empty", $_KeeDebugLevelWarn) _KeeDebugLeave ($KeeformVersion) Exit EndIf CheckAndSetFlag ($Autotype, $ClickEnabled, "{CLICK}") CheckAndSetFlag ($Autotype, $SubmitEnabled, "{SUBMIT}") CheckAndSetFlag ($Autotype, $EnterFormEnabled, "{ENTERFORM}") DoAutotype () _KeeDebugEnter ("Automatic Login", $_KeeDebugLevelFunc) _KeeDebugPrint ("IsObj($oPasswordForm) = " & IsObj($oPasswordForm), $_KeeDebugLevelInfo) _KeeDebugPrint ("IsObj($oButtonElement) = " & IsObj($oButtonElement), $_KeeDebugLevelInfo) If $EnterFormEnabled = True and IsObj ($oPasswordForm) Then ; send ENTERFORM only if no autotype, otherwise send {ENTER} ; to avoid problem, that Autoit-Send and PostMessage do not write into same queue If $Autotype = "" Then _KeeDebugPrint ("Enter Form {ENTERFORM}", $_KeeDebugLevelInfo) DllCall("user32.dll", "int", "PostMessage", "hwnd", FindInternet_ExplorerServer(), "int", $WM_KEYDOWN, "int", $VK_RETURN, "long",0) Else _KeeDebugPrint ("Enter Form {ENTER}", $_KeeDebugLevelInfo) Send ("{ENTER}") EndIf ElseIf $SubmitEnabled = True and IsObj ($oPasswordForm) Then _KeeDebugPrint ("Submit Form", $_KeeDebugLevelInfo) $oPasswordForm.submit() ElseIf $ClickEnabled = True and IsObj ($oButtonElement) Then _KeeDebugPrint ("Click Form", $_KeeDebugLevelInfo) $oButtonElement.click() Else _KeeDebugPrint ("automatic login not executed", $_KeeDebugLevelInfo) EndIf _KeeDebugLeave ("Automatic Login", $_KeeDebugLevelFunc) _KeeDebugLeave ($KeeformVersion & " EXIT") exit Func RecurseIntoFrames ($oObject, $TestOnly) Local $i Local $oFrame Local $test _KeeDebugEnter ("RecurseIntoFrames", $_KeeDebugLevelFunc) _KeeDebugPrint ("$TestOnly = " & $TestOnly, $_KeeDebugLevelErr) If IsObj($oObject) = False Then _KeeDebugPrint ("IsObj(oObject) = False", $_KeeDebugLevelErr) _KeeDebugLeave ("RecurseIntoFrames", $_KeeDebugLevelFunc) Return EndIf _KeeDebugPrint ("ObjName ($oObject) = " & ObjName ($oObject), $_KeeDebugLevelErr) ; Read the body tagname, this also tests whether there are ; security issues with frames (cross scripting security issue) _KeeDebugPrint ("Test if access denied", $_KeeDebugLevelErr) $ErrorHandlerMsgboxOn = False $test = $oObject.document.body.tagName If @error Then SetError(0) _KeeDebugLeave ("ErrorHandlerMsgboxOn = True", $_KeeDebugLevelInfo) _KeeDebugLeave ("RecurseIntoFrames", $_KeeDebugLevelFunc) $ErrorHandlerMsgboxOn = True Return EndIf $ErrorHandlerMsgboxOn = True _KeeDebugPrint ("access allowed", $_KeeDebugLevelErr) _KeeDebugPrint ("tag name " & $test , $_KeeDebugLevelErr) _KeeDebugPrint ("domain: " & $oObject.document.domain, $_KeeDebugLevelErr) _KeeDebugPrint ("protocol: " & $oObject.document.location.protocol & " " & $oObject.document.protocol, $_KeeDebugLevelErr) FormFiller ($oObject, $TestOnly) _KeeDebugPrint ("document.frames.length " & $oObject.document.parentwindow.frames.length, $_KeeDebugLevelInfo) If $oObject.document.parentwindow.frames.length = 0 Then _KeeDebugLeave ("RecurseIntoFrames", $_KeeDebugLevelFunc) Return EndIf FindFrameUrls ($oObject) _KeeDebugEnter ("For i = 0 to " & $oObject.document.parentwindow.frames.length-1, $_KeeDebugLevelFunc) For $i = 0 to $oObject.document.parentwindow.frames.length-1 _KeeDebugPrint ("i = " & $i, $_KeeDebugLevelInfo) $oFrame = $oObject.document.parentwindow.frames.item ($i) RecurseIntoFrames ($oFrame, $TestOnly) Next _KeeDebugLeave ("For i = 0 to " & $oObject.document.parentwindow.frames.length, $_KeeDebugLevelFunc) _KeeDebugLeave ("RecurseIntoFrames", $_KeeDebugLevelFunc) Endfunc Func FindFrameUrls ($oObject) Local $FrameUrls Local $r Local $NewUrl ; Local $Message _KeeDebugEnter ("FindFrameUrls", $_KeeDebugLevelFunc) $FrameUrls = FindTagInString(StringReplace($oObject.document.body.innerHTML,"><", "> <"), "<i?frame ", ">") ; ($oObject.document.body.innerHTML) ; ($oObject.document.documentelement.innerHTML) ; ($oObject.document.documentelement.outerHTML) _KeeDebugPrint ("Found " & UBound($FrameUrls,1) & " frame tags in body", $_KeeDebugLevelInfo) If BitAnd ($_KeeDebugLevel, $_KeeDebugLevelInfo) Then For $r = 0 to UBound($FrameUrls,1) - 1 _KeeDebugPrint ("Beep (500,100)", $_KeeDebugLevelInfo) ; Beep (500,100) FindAttribute ($FrameUrls[$r],"src=") Next EndIf If $FramesOutputEnabled Then For $r = 0 to UBound($FrameUrls,1) - 1 $NewUrl = FindAttribute ($FrameUrls[$r],"src=") If $NewUrl = "" Then _KeeDebugPrint ("$NewUrl is empty", $_KeeDebugLevelInfo) ContinueLoop EndIf If not StringInStr(StringLeft($NewUrl, 10), "://") Then $NewUrl = $oObject.document.location.protocol & "//" & $oObject.document.domain & "/" & $NewUrl EndIf _KeeDebugPrint ($NewUrl, $_KeeDebugLevelInfo) InputBox ("Frame " & $r+1, "Do you want to open the following frame?", $NewUrl, "", @DesktopWidth/2,80) If not @error Then If $CmdLine[0] = 4 Then $NewUrl = $NewUrl & ' "' & $CmdLine[2] & '" "' & $CmdLine[3] & '" "' & $CmdLine[4] & '"' EndIf If $CmdLine[0] = 5 Then $NewUrl = $NewUrl & ' "' & $CmdLine[2] & '" "' & $CmdLine[3] & '" "' & $CmdLine[4] & '" "' & $CmdLine[5] & '"' EndIf _KeeDebugPrint (@scriptname & " " & $url, $_KeeDebugLevelInfo) Run (@scriptname & " " & $NewUrl) EndIf ; $Message = $Message & FindAttribute ($FrameUrls[$r],"src=") & @LF Next ; MsgBox (0, "KeeForm Information", "Found the following frame URLs:" & @LF & @LF & $Message) EndIf _KeeDebugLeave ("FindFrameUrls", $_KeeDebugLevelFunc) Return $FrameUrls EndFunc Func FindAttribute($Tag, $Attribute) Local $AttributeValue = "" _KeeDebugEnter ("FindAttribute " & $Attribute & " " & $Tag, $_KeeDebugLevelFunc) If StringInStr($Tag, $Attribute & '"') Then $AttributeValue = FindTagInString($Tag, $Attribute & '"', '"') If UBound($AttributeValue) == 1 Then _KeeDebugLeave ("FindAttribute " & $AttributeValue[0], $_KeeDebugLevelFunc) Return $AttributeValue[0] EndIf ElseIf StringInStr($Tag, $Attribute & "'") Then $AttributeValue = FindTagInString($Tag, $Attribute & "'", "'") If UBound($AttributeValue) == 1 Then _KeeDebugLeave ("FindAttribute " & $AttributeValue[0], $_KeeDebugLevelFunc) Return $AttributeValue[0] EndIf ElseIf StringInStr($Tag, $Attribute) Then $AttributeValue = StringMid($Tag, StringInStr($Tag, $Attribute) + StringLen($Attribute)) If StringInStr($AttributeValue, " ") Then $AttributeValue = StringMid($AttributeValue, 1, StringInStr($AttributeValue, " ") - 1) EndIf _KeeDebugLeave ("FindAttribute " & $AttributeValue , $_KeeDebugLevelFunc) Return $AttributeValue EndIf _KeeDebugLeave ("FindAttribute ", $_KeeDebugLevelFunc) EndFunc Func FindTagInString($String, $before, $after) _KeeDebugEnter ("FindTagInString " & $String & " " & $before & " " & $after, $_KeeDebugLevelFunc) ;_KeeDebugPrint ("FindTagInString " & "(?i)" & $before & "(.*?)" & $after, $_KeeDebugLevelInfo) _KeeDebugLeave ("FindTagInString " , $_KeeDebugLevelFunc) Return StringRegExp($String, "(?i)" & $before & "(.*?)" & $after, 3) EndFunc Func FormFiller ($oObject, $TestOnly) Local $oTmpButtonElement Local $oPasswordElement Local $oUserElement Local $oForms Local $oForm Local $oInputs Local $oElement _KeeDebugEnter ("FormFiller", $_KeeDebugLevelFunc) _KeeDebugPrint ("$TestOnly = " & $TestOnly, $_KeeDebugLevelErr) _KeeDebugPrint ("$oForms = $oObject.document.forms", $_KeeDebugLevelInfo) $oForms = $oObject.document.forms _KeeDebugEnter ("For $oForm in $oForms", $_KeeDebugLevelFunc) For $oForm in $oForms _KeeDebugPrint ("Form name = " & $oForm.name, $_KeeDebugLevelInfo) $oPasswordElement = 0 $oUserElement = 0 $oTmpButtonElement = 0 $oInputs = $oForm.getElementsByTagName("input") _KeeDebugEnter ("For $oElement In $oInputs", $_KeeDebugLevelFunc) For $oElement In $oInputs If $oElement.value = "" Then _KeeDebugPrint ("<input type='" & $oElement.type &"' name='" & $oElement.name & "' value=" & "''" & ">", $_KeeDebugLevelInfo) Else _KeeDebugPrint ("<input type='" & $oElement.type &"' name='" & $oElement.name & "' value='" & $oElement.value & "'>", $_KeeDebugLevelInfo) EndIf Select Case $oElement.type = "submit" OR $oElement.type = "button" OR $oElement.type = "image" $oTmpButtonElement = $oElement ; Case $oElement.type = "password" and $FillAllPasswords = True ; $oElement.value = $Password Case $oElement.type = "password" and ($PasswordFound = False or $FillAllPasswords = True) If $TestOnly = False Then $oElement.value = $Password $oPasswordElement = $oElement $PasswordFound = True $ErrorHandlerMsgboxOn = False If $FocusDisabled = False and $TestOnly = False Then $oElement.focus() If not @error Then $ErrorHandlerMsgboxOn = False; just a dummy statement for com error _KeeDebugPrint ("Set focus in field '" & $oElement.name & "'" , $_KeeDebugLevelInfo) EndIf EndIf $ErrorHandlerMsgboxOn = True $oPasswordElement = $oElement $PasswordFound = True Case $oElement.type = "text" If $TestOnly = False Then $oElement.value = $Username $oUserElement = $oElement Case Else EndSelect If IsObj($oPasswordElement) and IsObj($oTmpButtonElement) and not IsObj($oButtonElement) Then $oButtonElement = $oTmpButtonElement EndIf Next _KeeDebugLeave ("For $oElement In $oInputs", $_KeeDebugLevelFunc) If IsObj ($oPasswordElement) and not IsObj ($oPasswordForm) Then $oPasswordForm = $oForm EndIf Next _KeeDebugLeave ("For $oForm in $oForms", $_KeeDebugLevelFunc) _KeeDebugLeave ("FormFiller", $_KeeDebugLevelFunc) EndFunc Func DoAutotype () Local $WinTitle ; This is only necessary if the user wants to use the username and ; and password within the autotype string. But this is would be ; a very rare use case ; Issue is, that the username or password can contain }{!^+# ; which are special characters for AutoIt (alt, shift and so on) _KeeDebugEnter ("DoAutotype", $_KeeDebugLevelFunc) if $Autotype = "" Then _KeeDebugPrint ("Autotype is empty", $_KeeDebugLevelWarn) _KeeDebugLeave ("DoAutotype", $_KeeDebugLevelFunc) Return EndIf $Username = EscapeSpecialCharacters($Username) $Password = EscapeSpecialCharacters($Password) $Autotype = StringReplace($Autotype, "{_USERNAME_}", $Username) $Autotype = StringReplace($Autotype, "{_PASSWORD_}", $Password) _KeeDebugPrint ("Autotype = " & $Autotype, $_KeeDebugLevelInfo) $WinTitle = GetBrowserTitle ($oIE.hwnd) If WinExists ($WinTitle) = 0 Then MsgBox (0, "KeeForm Error", "Could not activate window with title " & $WinTitle) _KeeDebugPrint ("WinExists = 0", $_KeeDebugLevelErr) _KeeDebugLeave ("DoAutotype", $_KeeDebugLevelFunc) _KeeDebugLeave ($KeeformVersion & " EXIT") Exit EndIf If Not WinActive ($WinTitle) Then WinActivate($WinTitle) If WinWaitActive ($WinTitle, "", 30) = 0 Then MsgBox (0, "KeeForm Error", "Could not activate window with title " & $WinTitle) _KeeDebugLeave ("DoAutotype EXIT", $_KeeDebugLevelFunc) _KeeDebugLeave ($KeeformVersion & " WinWaitActive = 0", $_KeeDebugLevelFunc) Exit EndIf Sleep(100) Send ($Autotype) _KeeDebugLeave ("DoAutotype", $_KeeDebugLevelFunc) EndFunc Func EscapeSpecialCharacters($String) _KeeDebugEnter ("EscapeSpecialCharacters", $_KeeDebugLevelFunc) $String = StringRegExpReplace($String,"([!#^+{}])","{\1}") ; _KeeDebugPrint ("StringRegExpReplace " & $String, $_KeeDebugLevelInfo) ; following statement doesn't work because of a bug in autoit ; $String = StringRegExpReplace($String,"([!#^+{}])","{\1}") ; ; so we have to use a couple of statements instead of one ; $String = StringReplace($String,"{","\\\\{\\\\") ; $String = StringReplace($String,"}","\\\\}\\\\") ; $String = StringReplace($String,"\\\\{\\\\","{{}") ; $String = StringReplace($String,"\\\\}\\\\","{}}") ; $String = StringReplace($String,"#","{#}") ; $String = StringReplace($String,"!","{!}") ; $String = StringReplace($String,"+","{+}") ; $String = StringReplace($String,"^","{^} ") ; _KeeDebugPrint ("StringRegExpReplace " & $String, $_KeeDebugLevelInfo) _KeeDebugLeave ("EscapeSpecialCharacters ", $_KeeDebugLevelFunc) Return $String EndFunc Func FindInternet_ExplorerServer() local $WinTitle local $hwnd _KeeDebugEnter ("FindInternet_ExplorerServer ", $_KeeDebugLevelFunc) $WinTitle = GetBrowserTitle ($oIE.hwnd) $hwnd = DLLCall("user32.dll","hwnd","FindWindowEx", "hwnd", $oIE.hwnd, "int", 0, "str", "TabWindowClass", "str", $WinTitle) _KeeDebugPrint ("TabWindowClass handle " & Hex ($hwnd[0]), $_KeeDebugLevelInfo) if $hwnd[0] = 0 Then $hwnd[0]=$oIE.hwnd _KeeDebugPrint ("Version is <= 6.0 " & Hex ($hwnd[0]), $_KeeDebugLevelInfo) Else _KeeDebugPrint ("Version is >= 7.0 ", $_KeeDebugLevelInfo) EndIf $hwnd = DLLCall("user32.dll","hwnd","FindWindowEx", "hwnd", $hwnd[0], "int", 0, "str", "Shell DocObject View", "int", 0) _KeeDebugPrint ("Shell DocObject View handle " & Hex ($hwnd[0])) if Not @error Then $hwnd = DLLCall("user32.dll","hwnd","FindWindowEx", "hwnd", $hwnd[0], "int", 0, "str", "Internet Explorer_Server", "int", 0) if @error Then _KeeDebugPrint ("FindWindowEx Shell DocObject View failed", $_KeeDebugLevelErr) Else _KeeDebugPrint ("FindWindowEx Internet Explorer_Server failed", $_KeeDebugLevelErr) EndIf _KeeDebugLeave ("FindInternet_ExplorerServer " & Hex ($hwnd[0]), $_KeeDebugLevelFunc) Return $hwnd[0] EndFunc Func GetBrowserTitle ($hwnd) local $Response local $WinTitle _KeeDebugEnter ("GetBrowserTitle " & Hex ($hwnd), $_KeeDebugLevelFunc) $Response = DllCall("user32.dll", "int", "GetWindowText", "hwnd", $hwnd, "str", "", "int", 32768) $WinTitle = $Response[2] _KeeDebugLeave ("GetBrowserTitle " & $WinTitle, $_KeeDebugLevelFunc) Return $WinTitle EndFunc Func CheckDebugFlags ($string) Local $DebugLevel = 0 _KeeDebugEnter ("CheckDebugFlags " & $string, $_KeeDebugLevelFunc) _KeeDebugPrint ("CmdLine[5] = " & $string) Select Case StringInStr($string, "Exit" ) $DebugLevel = $DebugLevel + $_KeeDebugLevelExit _KeeDebugPrint ("DebugLevelExit") Case StringInStr($string, "Err" ) $DebugLevel = $DebugLevel + $_KeeDebugLevelErr _KeeDebugPrint ("DebugLevelErr") Case StringInStr($string, "Warn" ) $DebugLevel = $DebugLevel + $_KeeDebugLevelWarn _KeeDebugPrint ("DebugLevelWarn") Case StringInStr($string, "Info" ) $DebugLevel = $DebugLevel + $_KeeDebugLevelInfo _KeeDebugPrint ("DebugLevelInfo") Case StringInStr($string, "Func" ) $DebugLevel = $DebugLevel + $_KeeDebugLevelFunc _KeeDebugPrint ("DebugLevelFunc") Case StringInStr($string, "Var" ) $DebugLevel = $DebugLevel + $_KeeDebugLevelVar _KeeDebugPrint ("DebugLevelVar") Case StringInStr($string, "Loop" ) $DebugLevel = $DebugLevel + $_KeeDebugLevelLoop _KeeDebugPrint ("DebugLevelLoop") Case StringInStr($string, "All" ) $DebugLevel = $_KeeDebugLevelAll _KeeDebugPrint ("DebugLevelAll") _KeeDebugPrint ("DebugLevel = " & $DebugLevel) Case Else EndSelect ;check only for {KEEFORMDEBUG, no "}" !!! If Not StringInStr($string, "{KEEFORMDEBUG") Then $DebugLevel = $_KeeDebugLevelOff _KeeDebugPrint ("NO KEEFORMDEBUG") _KeeDebugPrint ("DebugLevel = " & $DebugLevel) ElseIf $DebugLevel = 0 Then $DebugLevel = $_KeeDebugLevelAll _KeeDebugPrint ("{KEEFORMDEBUG") _KeeDebugPrint ("DebugLevelAll") _KeeDebugPrint ("DebugLevel = " & $DebugLevel) EndIf If StringInStr($string, "{KEEFORMERROR}" ) Then $ErrorHandlerOn = False _KeeDebugPrint ("{KEEFORMERROR}") _KeeDebugPrint ("ErrorHandlerOn = " & $ErrorHandlerOn) Else $ErrorHandlerOn = True EndIf If StringInStr($string, "{KEEFORMFRAMES}" ) Then $FramesOutputEnabled = True _KeeDebugPrint ("{KEEFORMFRAMES}") _KeeDebugPrint ("FramesOutputEnabled = " & $FramesOutputEnabled) Else $FramesOutputEnabled = False EndIf _KeeDebugLeave ("CheckDebugFlags " & $DebugLevel, $_KeeDebugLevelFunc) Return $DebugLevel EndFunc Func CheckAndSetFlag (ByRef $Autotype, ByRef $Flag, $string) _KeeDebugEnter ("CheckAndSetFlag " & $Autotype & " " & $Flag & " " & $string, $_KeeDebugLevelFunc) If StringInStr($Autotype, $string) Then $Autotype = StringReplace($Autotype, $string, "") $Flag = True Else $Flag = False EndIf _KeeDebugPrint ($string & " = " & $Flag, $_KeeDebugLevelInfo) _KeeDebugPrint ("Autotype = " & $Autotype, $_KeeDebugLevelInfo) _KeeDebugLeave ("CheckAndSetFlag", $_KeeDebugLevelFunc) EndFunc Func PrintSystemInformation () _KeeDebugEnter ("PrintSystemInformation", $_KeeDebugLevelFunc) _KeeDebugPrint ("Date " & @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC) _KeeDebugPrint ("@AutoItExe " & @AutoItExe) _KeeDebugPrint ("@AutoItPID " & @AutoItPID) _KeeDebugPrint ("@AutoItVersion " & @AutoItVersion) _KeeDebugPrint ("@Compiled " & @Compiled) _KeeDebugPrint ("@ComSpec " & @ComSpec) _KeeDebugPrint ("@OSBuild " & @OSBuild) _KeeDebugPrint ("@OSLang " & @OSLang) _KeeDebugPrint ("@OSServicePack " & @OSServicePack) _KeeDebugPrint ("@OSTYPE " & @OSTYPE) _KeeDebugPrint ("@OSVersion " & @OSVersion) _KeeDebugPrint ("@ProcessorArch " & @ProcessorArch) _KeeDebugPrint ("@ProgramFilesDir " & @ProgramFilesDir) _KeeDebugPrint ("@ProgramsDir " & @ProgramsDir) _KeeDebugPrint ("@ScriptDir " & @ScriptDir) _KeeDebugPrint ("@ScriptFullPath " & @ScriptFullPath) _KeeDebugPrint ("@ScriptLineNumber " & @ScriptLineNumber) _KeeDebugPrint ("@ScriptName " & @ScriptName) _KeeDebugPrint ("@SystemDir " & @SystemDir) _KeeDebugPrint ("@WindowsDir " & @WindowsDir) _KeeDebugPrint ("@WorkingDir " & @WorkingDir) _KeeDebugLeave ("PrintSystemInformation", $_KeeDebugLevelFunc) EndFunc Func MyErrorHandler() local $description local $HexNumber _KeeDebugEnter ("MyErrorHandler", $_KeeDebugLevelErr) $HexNumber = Hex ($oMyError.number,8) _KeeDebugPrint ("IE Error # " & $HexNumber & " " & $oMyError.description, $_KeeDebugLevelErr) _KeeDebugPrint (" " & $oMyError.windescription, $_KeeDebugLevelErr) _KeeDebugPrint ("$ErrorHandlerMsgboxOn = " & $ErrorHandlerMsgboxOn , $_KeeDebugLevelErr) if $ErrorHandlerMsgboxOn = False Then _KeeDebugLeave ("MyErrorHandler Return", $_KeeDebugLevelErr) SetError (1) return EndIf if $oMyError.description <> "" Then $description = $oMyError.description & @CRLF EndIf $description = $description & $oMyError.windescription Msgbox (0,"","KeeForm IE Error # " & $HexNumber & @CRLF & $description) _KeeDebugLeave ("MyErrorHandler EXIT", $_KeeDebugLevelErr) _KeeDebugLeave ($KeeformVersion & " MyErrorHandler", $_KeeDebugLevelErr) Exit EndFunc ; vim:ts=4:sw=4:ft=autoit:et:tw=0 Link to comment Share on other sites More sharing options...
herewasplato Posted February 12, 2008 Share Posted February 12, 2008 Welcome to the forum.See here for a tut... http://www.autoitscript.com/forum/index.php?showtopic=21048Yes, that script will only work with IE. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
FreeFry Posted February 12, 2008 Share Posted February 12, 2008 afaik. I don't think FireFox has a com object that allows it to be manipulated like Internet Explorer has. :/ Link to comment Share on other sites More sharing options...
James Posted February 12, 2008 Share Posted February 12, 2008 Yes it does but it has to be installed as a developer package when I last did it. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
FreeFry Posted February 12, 2008 Share Posted February 12, 2008 I see, what is this package called? Link to comment Share on other sites More sharing options...
James Posted February 12, 2008 Share Posted February 12, 2008 (edited) I can't remember. Do a Google search for "Firefox COM object".Have a look through here! Edited February 12, 2008 by JamesB Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
FreeFry Posted February 12, 2008 Share Posted February 12, 2008 (edited) okidok, thanks Edit:Is this it? http://www.iol.ie/~locka/mozilla/control.htm Edited February 12, 2008 by FreeFry Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now