Exit Posted July 27, 2011 Share Posted July 27, 2011 (edited) If you are running IE9 and click or submit returns with no error, but no action is performed, then this little Function is your friend.Func _SetIE8($_oIE) ; by forumer100 ----- Set IE9 to IE8 Browser mode If RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\IEDevTools", "Pinned") Then RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\IEDevTools", "Pinned", "REG_DWORD", 0) $hwnd1 = _IEPropertyGet($_oIE, "hwnd") $titleOld = _IEPropertyGet($_oIE, "title") $titleNew = $titleOld & " " & Random(10000000, 99999999, 1) _IEPropertySet($_oIE, "title", $titleNew) ControlSend($hwnd1, "", "Internet Explorer_Server1", "{F12}") $titleF12 = $titleNew & " - F12" WinWait($titleF12, "", 60) WinSetState($titleF12, "", @SW_HIDE) $hwndF12 = WinGetHandle($titleF12) ControlSend($hwndF12, "", "ToolbarWindow321", "{alt}b8") Sleep(1000) WinClose($hwndF12) _IEPropertySet($_oIE, "title", $titleOld) WinActivate($hwnd1) _IEAction($hwnd1,"refresh") EndFunc ;==>_SetIE8For more details,Sample:#include <IE.au3> #include '_SetIE8.au3' $oIE = _IECreate() _SetIE8($oIE) Exit MsgBox(0, '', "Now, check the browser setting by pressing F12 (after OK)") Edited July 27, 2011 by forumer100 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
supersonic Posted July 28, 2011 Share Posted July 28, 2011 (edited) Hi forumer100, thank you for your UDF. It is a relative practical workaround. To better fit my needs I modified your UDF a bit to support Browser and Document Mode (see UDF header for more details): expandcollapse popup#include-once #include <IE.au3> #include <Misc.au3> ; #FUNCTION# ========================================================================================= ; Function Name: _IESetMode() ; Description: Switches the Browser and/or Document Mode in Microsoft Internet Explorer 9 ; [http://www.autoitscript.com/forum/topic/129694-ie9-and-ielinkclickbytext/], ; [http://www.autoitscript.com/forum/topic/131236-setie8-to-circumvent-clicksubmit-errors-in-ie9/]. ; Syntax: _IESetMode(ByRef $oIESM_Object, $iIESM_Type, $sIESM_Mode [, $bIESM_Refresh = False)]) ; Parameter(s): $oIESM_Object - Target variable to a COM (Component Object Model [InternetExplorer.Application]) object or a DOM (Document Object Model) element. ; $iIESM_Type - Select type: ; | 0 - Browser Mode. ; | 1 - Document Mode. ; $sIESM_Mode - Select mode: ; | 7 - Microsoft Internet Explorer 7 (both modes). ; | 8 - Microsoft Internet Explorer 8 (both modes). ; | 9 - Microsoft Internet Explorer 9 (both modes). ; | C - Microsoft Internet Explorer 9 Compatibility View (Browser Mode only). ; | Q - Quirks Mode (Document Mode only). ; $bIESM_Refresh - Return zero- or one-based array: ; | False - Do not refresh after mode switching. ; | True - Refresh after mode switching. ; Requirement(s): #include <IE.au3> ; #include <Misc.au3> ; Return Value(s): Success - Returns 0/1, @error = 0. ; Failure - Returns 0, @error: ; | 0 - No error. ; | 1 - Invalid type. ; | 2 - Invalid mode. ; | 3 - '_IEPropertyGet()' failed. ; | 4 - 'RegWrite()' failed. ; | 5 - 'WinWait()' failed (timeout). ; Author(s): forumer100, Supersonic! ; ==================================================================================================== Func _IESetMode(ByRef $oIESM_Object, $iIESM_Type, $sIESM_Mode, $bIESM_Refresh = False) Local $iReturn = 0 Switch _VersionCompare(FileGetVersion(@WindowsDir & "\system32\ieframe.dll"), "9.0.0.0") Case 0, 1 ; 0 = EQU, 1 = GTR. Switch $iIESM_Type Case 0, 1 ; 0 = Browser Mode, 1 = Document Mode. $sIESM_Mode = String($sIESM_Mode) Switch $sIESM_Mode Case "7", "8", "9", "C", "Q" ; Microsoft Internet Explorer 7 - 9, Compatibility View, Quirks Mode. Local $hIE_Wnd = _IEPropertyGet($oIESM_Object, "HWND") If Not @error Then Local $sIESM_Key = "HKCU\Software\Microsoft\Internet Explorer\IEDevTools" Local $sIESM_Pinned = RegRead($sIESM_Key, "Pinned") RegWrite($sIESM_Key, "Pinned", "REG_DWORD", 0) If @error = 0 Then Local $iIESM_AISO = AutoItSetOption("WinTitleMatchMode") AutoItSetOption("WinTitleMatchMode", 2) ControlSend($hIE_Wnd, "", "Internet Explorer_Server1", "{F12}") If WinWait(" - F12", "", 10) <> 0 Then Local $hIE_F12 = WinGetHandle(" - F12", "") WinSetState($hIE_F12, "", @SW_HIDE) ; ---------------------------------------------------------------------------------------------------- Switch $iIESM_Type Case 0 ; Browser Mode. Switch $sIESM_Mode Case "7", "8", "9", "C" ; Microsoft Internet Explorer 7 - 9, Compatibility View. ControlSend($hIE_F12, "", "[CLASS:ToolbarWindow32; INSTANCE:1]", "{ALT}b{DOWN}" & $sIESM_Mode) EndSwitch Case 1 ; Document Mode. Switch $sIESM_Mode Case "7", "8", "9", "Q" ; Microsoft Internet Explorer 7 - 9, Quirks Mode. ControlSend($hIE_F12, "", "[CLASS:ToolbarWindow32; INSTANCE:1]", "{ALT}m{DOWN}" & $sIESM_Mode) EndSwitch EndSwitch ; ---------------------------------------------------------------------------------------------------- If $bIESM_Refresh = True Then $oIESM_Object.Refresh() EndIf ; ---------------------------------------------------------------------------------------------------- $iReturn = 1 WinClose($hIE_F12, "") SetError(0, 0) Else SetError(5, 0) EndIf AutoItSetOption("WinTitleMatchMode", $iIESM_AISO) Else SetError(4, 0) EndIf ; ---------------------------------------------------------------------------------------------------- If $sIESM_Pinned <> "" Then RegWrite($sIESM_Key, "Pinned", "REG_DWORD", $sIESM_Pinned) EndIf Else SetError(3, 0) EndIf Case Else SetError(2, 0) EndSwitch Case Else SetError(1, 0) EndSwitch Case Else SetError(0, 0) EndSwitch Return $iReturn EndFunc ;==>_IESetMode I'm still not very happy with this kind of "solution" but for the moment it works... Is there a way to set the Document Mode by modifying the IE object directly? With '$oIE.document.documentMode' you can determine the current Document Mode. Setting the Document Mode with '$oIE.document.documentMode = 8' fails. Maybe someone has a better solution to this issue... Greets, -supersonic._IESetMode.zip Edited July 28, 2011 by supersonic Link to comment Share on other sites More sharing options...
Seldon Posted August 4, 2011 Share Posted August 4, 2011 Hello, I've a problem: on my PC (Windows-7 64bit with IE9) it works, but in another PC... the script stops on -> WinWait($titleF12, "", 60) . If I press F12 manually it works ! For some reason -> ControlSend($hwnd1, "", "Internet Explorer_Server1", "{F12}") seems to fail, but I don't know why. I'm using the English version of IE9.. maybe this text "Internet Explorer_Server1" is different in other languages ? Thank you ! Link to comment Share on other sites More sharing options...
supersonic Posted August 5, 2011 Share Posted August 5, 2011 Seldon,I'm sure that the control name "Internet Explorer_Server1" is not different. You can test this with the "AutoIt Window Info" tool.Please, try my UDF posted above - it operates slightly different, maybe it works...-supersonic.Hello, I've a problem: on my PC (Windows-7 64bit with IE9) it works, but in another PC... the script stops on -> WinWait($titleF12, "", 60) . If I press F12 manually it works ! For some reason -> ControlSend($hwnd1, "", "Internet Explorer_Server1", "{F12}") seems to fail, but I don't know why. I'm using the English version of IE9.. maybe this text "Internet Explorer_Server1" is different in other languages ?Thank you ! Link to comment Share on other sites More sharing options...
icu Posted November 12, 2012 Share Posted November 12, 2012 (edited) Dear All, Both Exit and supersonic I can't get your UDFs to work... can you please enlighten me? Has anyone gotten their UDFs to work? Edited November 12, 2012 by icu Link to comment Share on other sites More sharing options...
supersonic Posted November 13, 2012 Share Posted November 13, 2012 icu, I should have mentioned earlier that my UDF will only works if UAC is disabled - this is one big drawback of the used concept. If UAC is disabled my script works pretty well even with W8 + IE10. Link to comment Share on other sites More sharing options...
icu Posted November 13, 2012 Share Posted November 13, 2012 (edited) Great, this may be the solution I'm looking for since the websites I need to scrape will not have any ads and are secure so I won't need to worry (too much) about malicious browser stuff. I'll have a go when I have more time and report back.Edit: Edited November 16, 2012 by icu Link to comment Share on other sites More sharing options...
supersonic Posted November 26, 2012 Share Posted November 26, 2012 (edited) icu, thank you for the feedback. I've updated my code to Support W8 + IE10: expandcollapse popup#include-once #include <IE.au3> #include <Misc.au3> ; #FUNCTION# ========================================================================================= ; Function Name: _IESetMode() ; Description: Switches the Browser and/or Document Mode in Microsoft Internet Explorer ; (if available, the User Account Control (UAC) has to be deactivated) ; [http://www.autoitscript.com/forum/topic/129694-ie9-and-ielinkclickbytext/], ; [http://www.autoitscript.com/forum/topic/131236-setie8-to-circumvent-clicksubmit-errors-in-ie9/], ; [http://www.autoitscript.com/forum/topic/145775-solved-forcing-ie9-into-ie8-browser-mode/]. ; Syntax: _IESetMode(ByRef $oIESM_Object, $iIESM_Type, $sIESM_Mode [, $bIESM_Refresh = False)]) ; Parameter(s): $oIESM_Object - Target variable to a COM (Component Object Model [InternetExplorer.Application]) object or a DOM (Document Object Model) element. ; $iIESM_Type - Select type: ; | 0 - Browser Mode. ; | 1 - Document Mode. ; $sIESM_Mode - Select mode: ; | 7 - Microsoft Internet Explorer 7 (both modes). ; | 8 - Microsoft Internet Explorer 8 (both modes). ; | 9 - Microsoft Internet Explorer 9 (both modes). ; | 0 - Microsoft Internet Explorer 10 (Browser Mode only). ; | C, K - Microsoft Internet Explorer Compatibility View (Browser Mode only) (language-dependent). ; | | C = English. ; | | K = German. ; | Q - Quirks Mode (Document Mode only). ; | S - Standards Mode (Page Default) (Document Mode only). ; | U - Microsoft Internet Explorer 5 (Quirks Mode) (Document Mode only). ; $bIESM_Refresh - Return zero- or one-based array: ; | False - Do not refresh after mode switching. ; | True - Refresh after mode switching. ; Requirement(s): #include <IE.au3> ; #include <Misc.au3> ; Return Value(s): Success - Returns 0/1, @error = 0. ; Failure - Returns 0, @error: ; | 0 - No error. ; | 1 - Invalid type. ; | 2 - Invalid mode. ; | 3 - '_IEPropertyGet()' failed. ; | 4 - 'RegWrite()' failed. ; | 5 - 'WinWait()' failed (timeout). ; Author(s): forumer100, Supersonic! ; ==================================================================================================== Func _IESetMode(ByRef $oIESM_Object, $iIESM_Type, $sIESM_Mode, $bIESM_Refresh = False) Local $iReturn = 0 Switch _VersionCompare(FileGetVersion(@WindowsDir & "system32ieframe.dll"), "9.0.0.0") Case 0, 1 ; 0 = EQU, 1 = GTR. Switch $iIESM_Type Case 0, 1 ; 0 = Browser Mode, 1 = Document Mode. $sIESM_Mode = String($sIESM_Mode) Switch $sIESM_Mode Case "7", "8", "9", "0", "C", "Q", "S", "U" ; Microsoft Internet Explorer 7 - 10, Compatibility View, Quirks Mode, Standards Mode, Microsoft Internet Explorer 5 Quirks Mode. Local $hIE_Wnd = _IEPropertyGet($oIESM_Object, "HWND") If Not @error Then Local $sIESM_Key = "HKCUSoftwareMicrosoftInternet ExplorerIEDevTools" Local $sIESM_Pinned = RegRead($sIESM_Key, "Pinned") RegWrite($sIESM_Key, "Pinned", "REG_DWORD", 0) If @error = 0 Then Local $iIESM_AISO = AutoItSetOption("WinTitleMatchMode") AutoItSetOption("WinTitleMatchMode", 2) ; ControlSend($hIE_Wnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{F12}") ControlSend($hIE_Wnd, "", "Internet Explorer_Server1", "{F12}") If WinWait(" - F12", "", 10) <> 0 Then Local $hIE_F12 = WinGetHandle(" - F12", "") WinSetState($hIE_F12, "", @SW_HIDE) ; ---------------------------------------------------------------------------------------------------- Switch $iIESM_Type Case 0 ; Browser Mode. Switch $sIESM_Mode Case "7", "8", "9", "0", "C", "K" ; Microsoft Internet Explorer 7 - 10, Compatibility View. ControlSend($hIE_F12, "", "[CLASS:ToolbarWindow32; INSTANCE:1]", "{ALT}b{DOWN}" & $sIESM_Mode) EndSwitch Case 1 ; Document Mode. Switch $sIESM_Mode Case "7", "8", "9", "Q", "S", "U" ; Microsoft Internet Explorer 7 - 9, Quirks Mode, Standards Mode, Microsoft Internet Explorer 5 Quirks Mode. ControlSend($hIE_F12, "", "[CLASS:ToolbarWindow32; INSTANCE:1]", "{ALT}m{DOWN}" & $sIESM_Mode) EndSwitch EndSwitch ; ---------------------------------------------------------------------------------------------------- If $bIESM_Refresh = True Then $oIESM_Object.Refresh() EndIf ; ---------------------------------------------------------------------------------------------------- $iReturn = 1 WinClose($hIE_F12, "") Else ; Error. SetError(5, 0) EndIf AutoItSetOption("WinTitleMatchMode", $iIESM_AISO) Else ; Error. SetError(4, 0) EndIf ; ---------------------------------------------------------------------------------------------------- If $sIESM_Pinned <> "" Then RegWrite($sIESM_Key, "Pinned", "REG_DWORD", $sIESM_Pinned) EndIf Else ; Error. SetError(3, 0) EndIf Case Else SetError(2, 0) EndSwitch Case Else SetError(1, 0) EndSwitch EndSwitch Return $iReturn EndFunc ;==>_IESetMode Any feedback is welcome. Edited November 26, 2012 by supersonic 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