Letraindusoir Posted March 30, 2021 Share Posted March 30, 2021 (edited) #include <IE.au3> #include <Array.au3> Local $oIE = _IECreate() Local $ss = "" $ss &= 'var fruits = new Array();' $ss &= 'fruits[0] = "pear";' $ss &= 'fruits[1] = "peach";' $ss &= 'fruits[2] = "pineapple";' $ss &= 'fruits[3] = "strawberry";' $ss &= 'return fruits;' ;Local $aa = $oIE.document.parentwindow.execScript($ss) Local $aa = $oIE.document.parentwindow.eval($ss) If IsArray($aa) Then _ArrayDisplay($aa, '$aa') EndIf _IEQuit($oIE) error occurred: Local $aa = $oIE.document.parentwindow.eval($ss) Local $aa = $oIE.document.parentwindow^ ERROR As above if want to get the value of the variable 'fruits' in the statement How does it work? thanks! Edited March 30, 2021 by Letraindusoir Link to comment Share on other sites More sharing options...
Nine Posted March 30, 2021 Share Posted March 30, 2021 Eval is not working anymore with ObjCreate("InternetExplorer.Application"). Here's another way : #include <Constants.au3> #include <IE.au3> #include <Array.au3> Example2() Func Example2 () Local $hGUI = GUICreate("Browser", @DesktopWidth / 2, @DesktopHeight / 2) ;GUISetState() ;Show GUI Global $oIE = ObjCreate("Shell.Explorer.2") $hIE = GUICtrlCreateObj($oIE, 0, 0, @DesktopWidth / 2, @DesktopHeight / 2) $oIE.navigate('about:blank') $arr = StringSplit($oIE.Document.parentWindow.eval('function tt() {var fruits = [];fruits[0] = "pear";fruits[1] = "peach";' & _ 'fruits[2] = "pineapple";fruits[3] = "strawberry"; return fruits[0]+"|"+fruits[1]+"|"+fruits[2]+"|"+fruits[3];}; tt();'), "|", $STR_NOCOUNT) _ArrayDisplay($arr) EndFunc Letraindusoir 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Letraindusoir Posted March 30, 2021 Author Share Posted March 30, 2021 6 minutes ago, Nine said: Eval is not working anymore with ObjCreate("InternetExplorer.Application"). Here's another way : #include <Constants.au3> #include <IE.au3> #include <Array.au3> Example2() Func Example2 () Local $hGUI = GUICreate("Browser", @DesktopWidth / 2, @DesktopHeight / 2) ;GUISetState() ;Show GUI Global $oIE = ObjCreate("Shell.Explorer.2") $hIE = GUICtrlCreateObj($oIE, 0, 0, @DesktopWidth / 2, @DesktopHeight / 2) $oIE.navigate('about:blank') $arr = StringSplit($oIE.Document.parentWindow.eval('function tt() {var fruits = [];fruits[0] = "pear";fruits[1] = "peach";' & _ 'fruits[2] = "pineapple";fruits[3] = "strawberry"; return fruits[0]+"|"+fruits[1]+"|"+fruits[2]+"|"+fruits[3];}; tt();'), "|", $STR_NOCOUNT) _ArrayDisplay($arr) EndFunc Thanks! But Still Report Error: $arr = StringSplit($oIE.Document.parentWindow^ ERROR Windows 7 + IE11 Is it related to the system and browser? Link to comment Share on other sites More sharing options...
Letraindusoir Posted March 30, 2021 Author Share Posted March 30, 2021 There's no reporting error with 'Document.parentWindow.execScript' Link to comment Share on other sites More sharing options...
Nine Posted March 30, 2021 Share Posted March 30, 2021 It is working for me on Win7. You may need to set FEATURE_BROWSER_EMULATION in the registry for AutoIt3.exe to "0x2AF9". HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Letraindusoir Posted March 30, 2021 Author Share Posted March 30, 2021 #include <Constants.au3> #include <IE.au3> #include <Array.au3> Example2() Func Example2 () Local $hGUI = GUICreate("Browser", @DesktopWidth / 2, @DesktopHeight / 2) ;GUISetState() ;Show GUI Global $oIE = ObjCreate("Shell.Explorer.2") $hIE = GUICtrlCreateObj($oIE, 0, 0, @DesktopWidth / 2, @DesktopHeight / 2) $oIE.navigate('about:blank') $arr = $oIE.Document.parentWindow.eval('alert(123)') EndFunc After simplified tests are still 'execScript no-error-reporting' and 'eval error-reporting' Link to comment Share on other sites More sharing options...
Nine Posted March 30, 2021 Share Posted March 30, 2021 IDK. Since it works for me. Try different value of emulation ? ; IE11 edge mode: 11001 (0x2AF9) ; IE11: 11000 (0x2AF8) ; IE10: 10001 (0x2711) ; IE10: 10000 (0x02710) ; IE 9: 9999 (0x270F) ; IE 9: 9000 (0x2328) ; IE 8: 8888 (0x22B8) ; IE 8: 8000 (0x1F40) ; IE 7: 7000 (0x1B58) Letraindusoir 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Letraindusoir Posted March 30, 2021 Author Share Posted March 30, 2021 9 minutes ago, Nine said: It is working for me on Win7. You may need to set FEATURE_BROWSER_EMULATION in the registry for AutoIt3.exe to "0x2AF9". HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION I think There is something wrong with the grammar of javascript sentences I have used 'eval' or 'execScript' before, that sometimes work sometimes don't work Link to comment Share on other sites More sharing options...
Letraindusoir Posted March 30, 2021 Author Share Posted March 30, 2021 After Set FEATURE_BROWSER_EMULATION in the registry for AutoIt3.exe to "0x2AF9",It's Working Fine It's amazing Thanks Nine ! Link to comment Share on other sites More sharing options...
Nine Posted March 30, 2021 Share Posted March 30, 2021 You are welcome “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Letraindusoir Posted March 30, 2021 Author Share Posted March 30, 2021 var fruits = new Array(); fruits[0] = "pear"; fruits[1] = "peach"; fruits[2] = "pineapple"; fruits[3] = "strawberry"; console.log(fruits) The above statement runs on the browser console without error Not with eval or execScript. It seems that this is also a puzzling problem Link to comment Share on other sites More sharing options...
Nine Posted March 30, 2021 Share Posted March 30, 2021 it works also for me using var fruits = new Array(); You may have a glitch in your code. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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