Sign in to follow this  
Followers 0
Hasher

100% CPU Usage

8 posts in this topic

Hi I am making a little app that monitors a webpage. It uses a while loop to reside in memory until the desired action is performed by user. The probelm I have is that it takes up 100% of the memory and makes the computer lock up. From previous posts I read one option is to put sleep(10) in the loop but this has not worked. Any suggestions ??

#include <IE.au3>
HotKeySet("{ESC}","KillMe")

$sWebPage = "http://www.google.com"
$i = 1
$oIE = _IECreate()
_IENavigate($oIE, $sWebPage)


While $i = 1
sleep(10)
$oEvent = ObjEvent($oIE, "onsubmit")
if $oEvent = true then IEEvent_onbeforeunload()
WEnd




Func IEEvent_onbeforeunload()
MsgBox(0,"success","onsubmit worked")

EndFunc

Func KillMe()
   Exit
EndFunc

Thank you in advance .. Paul :-D


Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Share this post


Link to post
Share on other sites



If I do that it can 'miss' my if statement


Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Judging from this list: http://msdn.microsoft.com/library/default..../reflist_vb.asp, there's no such event called "onbeforeunload", neither one such as "onsubmit"(javascript?).

And even if it does, you are defining the event handler the wrong way, it's not meant to be used in a loop like that - you use it once, after creating the object it should handle.

This is how it should be defined(assuming that the events exists):

$oIE = _IECreate()

$oEvent = ObjEvent($oIE, "IEEvent_")

Func IEEvent_onbeforeunload()
    MsgBox(0,"success","onsubmit worked")
EndFunc

Func IEEvent_onsubmit()
    MsgBox(0,"success","onsubmit worked")
EndFunc

That "onsubmit" event looks like javascript, and as far as I am aware, javascript is not connected to the "InternetExplorer.Application.1" object - that the IE.au3 functions uses - in any way.

Edit:

Clarified.

Edited by FreeFry

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hasher

Try This:

#include <IE.au3>
HotKeySet("{ESC}","KillMe")

$sWebPage = "http://www.google.com"
$i = 1
$oIE = _IECreate()
_IENavigate($oIE, $sWebPage)

AdlibEnable("Loop", 10)

While 1
   Sleep(100)
Wend

Func Loop()
   $oEvent = ObjEvent($oIE, "onsubmit")
   if $oEvent = true then IEEvent_onbeforeunload()
EndFunc

Func IEEvent_onbeforeunload()
MsgBox(0,"success","onsubmit worked")

EndFunc

Func KillMe()
   Exit
EndFunc
Edited by MsCreatoR

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Hasher

Try This:

#include <IE.au3>
HotKeySet("{ESC}","KillMe")

$sWebPage = "http://www.google.com"
$i = 1
$oIE = _IECreate()
_IENavigate($oIE, $sWebPage)

AdlibEnable("Loop", 10)

While 1
   Sleep(100)
Wend

Func Loop()
   $oEvent = ObjEvent($oIE, "onsubmit")
   if $oEvent = true then IEEvent_onbeforeunload()
EndFunc

Func IEEvent_onbeforeunload()
MsgBox(0,"success","onsubmit worked")

EndFunc

Func KillMe()
   Exit
EndFunc

This still does hang the cpu at 100%/almost hangs the internet explorer window, and it doesn't work for me ?? My computer only or?

Share this post


Link to post
Share on other sites

Thanks Freefry

I took the $oEvent = ObjEvent($oIE, "IEEvent_") out of the loop and used BeforeNavigate (which works for submit and navigating away from current page) and it works fine now.... new source is

$oEvent = ObjEvent($oIE, "IEEvent_")
    
    While $i = 1
        sleep(10)
    WEnd

Your where very helpful :-)

Thanks Paul


Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Great to be of help :whistle:

Though, all submits doesn't really "navigate", at least I don't think they do(take for example when submitting something that doesn't load/reload a page).

But of course for finding when a page is updated it works great! :)

Edit:

Taken from MSND @ http://msdn.microsoft.com/workshop/browser...renavigate2.asp

The BeforeNavigate2 event replaces the BeforeNavigate and FrameBeforeNavigate events, which should no longer be used. The pDisp parameter that specifies the corresponding WebBrowser object clearly identifies where the navigation is to occur. Microsoft Internet Explorer 3.0 required the FrameBeforeNavigate and a target frame name to identify the target of navigation. However, this solution was potentially ambiguous as frame names are not unique.

Edited by FreeFry

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0