BrewManNH Posted November 3, 2018 Share Posted November 3, 2018 4 minutes ago, Danp2 said: That code comes from here That doesn't answer the question, does that code even work? How can you use Execute that way, and why would you in the first place? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
oemript Posted November 3, 2018 Author Share Posted November 3, 2018 (edited) _IEErrorNotify(True) is only coding for notification setting, I have tried @error, but Msgbox does not show up, so how to detect not responding properly under this situation? Sleep(250) $jsEval = Execute('$oIE.Document.head.eval') if @error then MsgBox(64 + 262144, 'Title', 'Error') EndIf Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^) Edited November 3, 2018 by oemript Link to comment Share on other sites More sharing options...
Danp2 Posted November 3, 2018 Share Posted November 3, 2018 @BrewManNH Yes... it works, allowing you to retrieve a reference the the browser's eval function. Original discussion is here. oemript 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
oemript Posted November 3, 2018 Author Share Posted November 3, 2018 (edited) Do Global $oIE = _IECreate($URL, 1) ... $jsEval = Execute('$oIE.Document.head.eval') If $jsEval("typeof jQuery=='undefined'") Then MsgBox(64 + 262144, 'Title', 'Error') EndIf Until IsObj($jsEval) Do Sleep(250) MsgBox(64 + 262144, 'Total Vol', '0') Until $jsEval("RawSummary.totalVol") <> 0 MsgBox(64 + 262144, 'Total Vol', 'Pass') When I test it, and find out the error occur totalVol = 0 on the second loop and it loops forever, problem is solved. Thanks, to everyone very much for any suggestions (^v^) Edited November 3, 2018 by oemript Link to comment Share on other sites More sharing options...
Danp2 Posted November 3, 2018 Share Posted November 3, 2018 Your code makes no sense, especially after the last edit. You can't expect to use $jsEval within the Do loop where it is being created. FrancescoDiMuro 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
oemript Posted November 3, 2018 Author Share Posted November 3, 2018 Code is updated, which need to start from beginning. Thanks, to everyone very much for suggestions (^v^) Link to comment Share on other sites More sharing options...
Gianni Posted November 6, 2018 Share Posted November 6, 2018 On 3/11/2018 at 2:39 PM, BrewManNH said: That doesn't answer the question, does that code even work? How can you use Execute that way, and why would you in the first place? It's a simple and ingenious way to avoid AutoIt crashes in some circumstances.I saw it used by @genius257 in this post: (https://www.autoitscript.com/forum/topic/185387-value-of-js-variable-in-ie/?do=findComment&comment=1332372) and in the first instance I was also perplexed, but in fact that way can save us from unwanted crashes. (see his explanation here)for example, if you want to get a reference to a javascript function you can use this code: $oIE.Document.head.eval but if the function is not yet available in the javascript environment, the above code causes the script to crash.By simply putting the code in the Execute () function, the error is not generated.You can still check if the command was successful by checking if the variable returned by Execute () is an object or not.In this way you can wait painlessly for the javascript function to be available until the returned variable is an object. Here an example of use: ...... ; create a reference to the javascript eval() function $oIE.document.parentWindow.setTimeout('document.head.eval = eval', 0) Do Sleep(250) $jsEval = Execute('$oIE.Document.head.eval') Until IsObj($jsEval) ....... Danp2 and genius257 2 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Gianni Posted November 6, 2018 Share Posted November 6, 2018 On 1/11/2018 at 11:23 PM, oemript said: Referring to following coding, I would like to set a condition if Do loop last more than 3 minutes, then break Do Loop and ContinueLoop for next For loop, if not, Do Loop would run forever. For example 1) Processing $x = 3 2) Running Do Loop more than 3 minutes 3) Exit Do Loop 4) Processing $x = 4 for $x = 1 to 5 ... Do Sleep(250) Until $jsEval("RawSummary.totalVol") <> 0 ... Next Does anyone have any suggestions? Thanks, to everyone very much for any suggestions (^v^) .... something like this... for $x = 1 to 5 $Timer = TimerInit() Do Sleep(250) Until ($jsEval("RawSummary.totalVol") <> 0) Or (TimerDiff($Timer) > 180000 ) ; timeout in 180000ms = 3 minutes ... Next On 3/11/2018 at 2:43 PM, oemript said: _IEErrorNotify(True) is only coding for notification setting, I have tried @error, but Msgbox does not show up, so how to detect not responding properly under this situation? Sleep(250) $jsEval = Execute('$oIE.Document.head.eval') if @error then MsgBox(64 + 262144, 'Title', 'Error') EndIf Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^) the error will never occur because the Execute() function never arises errors... check instead if the returned variable is of the type you are expecting or is empty something similar to this for example... Sleep(250) $jsEval = Execute('$oIE.Document.head.eval') if Not IsObj($jsEval) then MsgBox(64 + 262144, 'Error', 'eval still unavailable') EndIf Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
BrewManNH Posted November 6, 2018 Share Posted November 6, 2018 1 hour ago, Chimp said: It's a simple and ingenious way to avoid AutoIt crashes in some circumstances. Thank you for the explanation. It was really strange seeing that piece of code, never saw anything used that way before. Makes more sense now. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
oemript Posted November 17, 2018 Author Share Posted November 17, 2018 (edited) On 11/7/2018 at 4:21 AM, Chimp said: Sleep(250) $jsEval = Execute('$oIE.Document.head.eval') if Not IsObj($jsEval) then MsgBox(64 + 262144, 'Error', 'eval still unavailable') EndIf I would like to know any different on following 2 conditions for error checking. If $jsEval("typeof jQuery=='undefined'") Then If Not IsObj($jsEval) then Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^) Edited November 17, 2018 by oemript 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