Jump to content

Script Ideas...


Recommended Posts

I have one for you.

I would like to see something like this.

A script that continually opens and closes a website and logs how long it takes in variables.  It then creates a running average of the last 100 load times and compairs that time to the difference of the current load time.  If the current load time goes 50% higher then the running average it sends a netsend to the admin.

Also it would be nice if it displays the current time and running average in a Splash Text window.

Nice one.

Tomorrow I have plenty of time and I will be working on this.

Link to comment
Share on other sites

  • Replies 68
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Done.

Change the following values to your needs.

How many times would you like to open/close the website?

$Times = 100

Title of the page/website

$Title = "MSN.com"

Address of the website

$Website = "www.MSN.com"

Message to be sent when current load time exceeds 50%.

$SendMessage = "Load time exceeds 50%!"

You have to change %COMPUTERNAME% to where the Net Send message has to be sent

Dim $MeasTime = 0
$Times = 100
$Title = "MSN.com"
Opt("WinTitleMatchMode", 2)
$Website = "www.MSN.com"
$SendMessage = "Load time exceeds 50%!"

SplashTextOn("Untitled - AutoIt3", "", 300, 50, -1, -1, 16, "", 11)

$Text = "0/" & $Times & @CRLF & "Average time: 0.00 seconds."
ControlSetText("Untitled - AutoIt3", "", "Static1", $Text)

$x = 1

Do
;Start timer
$StartTime = TimerStart()

;Block user input for a while (temporarily)
BlockInput(1)
MouseMove(100, 1, 0)

;Start browser with the website specified
Run(@ProgramFilesDir & "\Internet Explorer\IEXPLORE.EXE " & $Website, "", @SW_MAXIMIZE)

If Not WinExists($Title, "") Then
WinWait($Title, "")
EndIf

Sleep(50)

$CheckCursor = MouseGetCursor()

If $CheckCursor <> 2 Then
   While $CheckCursor <> 2
     $CheckCursor = MouseGetCursor()
     Sleep(1)
   WEnd
EndIf

;Close browser window
WinClose($Title, "")

;Enable user input
BlockInput(0)
MouseMove(500, 500, 0)

;Stop timer
$StopTime = TimerStop($StartTime)

;Add current load time to the total load time
$MeasTime = $MeasTime + $StopTime

;Create avarage load time
$Average = Round(($MeasTime / $x) / 1000, 3)

;Update SplashText window
$Text = $x & "/" & $Times & @CRLF & "Average time: " & $Average & " seconds."
ControlSetText("Untitled - AutoIt3", "", "Static1", $Text)

$x = $x + 1
Until $x > $Times

$x = $x - 1

;Close last browser window
If WinExists($Title, "") Then WinClose($Title, "")

;Pause 5 seconds to see the average time
$Text = $x & "/" & $Times & @CRLF & "Average time: " & $Average & " seconds."
ControlSetText("Untitled - AutoIt3", "", "Static1", $Text)

Sleep(5 * 1000)

SplashOff()

;Check if current load time exceeds 50% from the total average load time
$CurTime = Round($StopTime / 1000, 3) / $Average
$CurTime = $CurTime * 100
$CurTime = Round($CurTime , 0)

;If true then send message to %COMPUTERNAME%
If $CurTime >= 50 Then
Run(@ComSpec & " /c Net Send %COMPUTERNAME% " & $SendMessage, "", @SW_HIDE)
EndIf
Edited by SlimShady
Link to comment
Share on other sites

You are missing my point.

Ok the continuous loop is easy with a while 1 Wend

The hard part is to only average the last 100 loads. This would most likely need to be done in an array or a file.

For instance if I set your script to load a site $Times = 100000000000000000, then the averages would not be realistic to how the site is working today after only a few days. If the average could keep readjusting itself every load by dropping the oldest value out of 100 for each new load time then the numbers would be much more realistic.

Link to comment
Share on other sites

I understand you now. You want to check a website and not test your internet connection.

Ok, I'll create an ini file tomorrow. This ain't that difficult.

I'm lost, it is difficult.

Here's what I have so far:

Dim $MeasTime[101]
$x = 1
$Title = "MSN.com"
Opt("WinTitleMatchMode", 2)
$Website = "www.MSN.com"
$SendMessage = "Load time exceeds 50%!"

HotKeySet("{ESC}", "Escape")

SplashTextOn("Untitled - AutoIt3", "", 300, 50, -1, -1, 16, "", 11)

$Text = "Average time: 0.00 seconds."
ControlSetText("Untitled - AutoIt3", "", "Static1", $Text)

While 1
;Start timer
$StartTime = TimerStart()

;Block user input for a while (temporarily)
;BlockInput(1)
MouseMove(100, 1, 0)

;Start browser with the website specified
Run(@ProgramFilesDir & "\Internet Explorer\IEXPLORE.EXE " & $Website, "", @SW_MAXIMIZE)

If Not WinExists($Title, "") Then
WinWait($Title, "")
EndIf

Sleep(50)

$CheckCursor = MouseGetCursor()

If $CheckCursor <> 2 Then
   While $CheckCursor <> 2
     $CheckCursor = MouseGetCursor()
     Sleep(1)
   WEnd
EndIf

;Close browser window
WinClose($Title, "")

Sleep(50)

;Stop timer
$StopTime = TimerStop($StartTime)

If $x <= 3 Then
  $MeasTime[$x] = $StopTime
Else

  For $i = 1 To $x
    $CalcAverage = $CalcAverage + $MeasTime[$i]
  Next

;Create avarage load time
$Average = Round($CalcAverage / 1000 / $x, 3)

MsgBox(0, "Test", "$Average = " & $Average)

$CheckAverage = Round(($StopTime / 1000) / $Average * 100, 0)

MsgBox(0, "Test", "$CheckAverage = " & $CheckAverage & "%")

;If true then send message to %COMPUTERNAME%
If $CheckAverage >= 50 Then Run(@ComSpec & " /c Net Send %COMPUTERNAME% " & $SendMessage, "", @SW_HIDE)

;  $x = 1
Exit
EndIf

If $x > 1 Then
  For $i = 1 To $x
    $CalcAverage = $CalcAverage + $MeasTime[$i]
  Next

;Create avarage load time
$Average = Round($CalcAverage / 1000 / $x, 3)

Else
$Average = $MeasTime[1]

$Average = Round($Average / 1000, 3)
EndIf

;Update SplashText window
$Text = "After " & $x & " runs, average time is: " & $Average & " seconds."
ControlSetText("Untitled - AutoIt3", "", "Static1", $Text)

$x = $x + 1
WEnd

Func Escape()
SplashOff()
If WinExists($Title, "") Then WinClose($Title, "")
HotKeySet("{ESC}")
Exit
EndFunc
Edited by SlimShady
Link to comment
Share on other sites

If you see the list here: currently you can only write to the registry and to an INI file.

You can create an hta application that runs a script file;

- Create a small web page with a textbox

- A button that selects the text and runs the script

- the script sends CTRL+C and using AutoIt you can ClipGet

the text and save it to a textfile

Link to comment
Share on other sites

If you see the list here: currently you can only write to the registry and to an INI file.

You can create an hta application that runs a script file;

- Create a small web page with a textbox

- A button that selects the text and runs the script

- the script sends CTRL+C and using AutoIt you can ClipGet

the text and save it to a textfile

Thanks

Any suggestions on how to point control c to the text box?

Rick

Link to comment
Share on other sites

If you see the list here: currently you can only write to the registry and to an INI file.

You can create an hta application that runs a script file;

- Create a small web page with a textbox

- A button that selects the text and runs the script

- the script sends CTRL+C and using AutoIt you can ClipGet

the text and save it to a textfile

Wait aminute

What about using autoitx to write the value of the text box to the clipboard

That's doable right?

Can you show me how?

Rick

Link to comment
Share on other sites

AutoItX uses VBScript so I started searching for information about VBScript and HTML textareas.

I didn't find any examples only that: it's possible.

In the meantime I found this:

An HTA-Notepad that uses VBScript to read/save any text file.

Link to comment
Share on other sites

AutoItX uses VBScript so I started searching for information about VBScript and HTML textareas.

I didn't find any examples only that: it's possible.

In the meantime I found this:

An HTA-Notepad that uses VBScript to read/save any text file.

Sorry I thought you new it was already in autoitx and autit3x

Methods are:

------------

AutoItSetOption ( "option", param )

BlockInput ( flag )

CDTray ( "drive", "status" )

ClipGet ( )

ClipPut ( "value" )

I just don't know how to setup the format to get the textbox text to the clipboard

0Autoit3.clipput blah

Rick

Oh I tried the notepad it looked interesting but I got an error

While I'm asking newbie questions is there a way to install the autoitx object with vbscript so I can start right off with the HTA meu?

Edited by tutor2000
Link to comment
Share on other sites

To use the AutoItX dll, you have to register it;

- Save it some place safe

- Open the run box

- and enter this: regsvr32.exe path\to\AutoItX3.dll

I made a start and like I said: I couldn't find an example of how VBScript interacts with an HTML textarea.

<html>
<head>
<title>  HTML Form Textarea Example 
</title>
</head>
<body>
<h1>   HTML Form Textarea Example 
</h1>

<form>
<P>
 <TEXTAREA name="content" rows=5 cols=65>
<INPUT TYPE=BUTTON onclick="SaveText()" VALUE="calculate">
</TEXTAREA>
</p>       
</form>

<script language="VBScript/Text" type="VBScript/Text">
Set oAutoIt = CreateObject("AutoItX3.Control")
Sub SaveText()

End Sub
</script>

</body>
</html>
Link to comment
Share on other sites

  • 2 weeks later...

Bored again.........

Does anyone have ideas?

I made GUIs for some scripts (which I haven't posted here)...

If you would like to know which ones:

  • AlarmClock
  • A small script that creates receipts (add and subtract values)
edit:

While I was relaxing in the backyard enjoying the weather, I was thinking of

a converter.

That converts anything! With an INI file where you can specify your own things.

I'm gonna include a currency converter. And in the INI file you can specify which currencies you're going to use.

Edited by SlimShady
Link to comment
Share on other sites

Bored again.........

Does anyone have ideas?

I made GUIs for some scripts (which I haven't posted here)...

If you would like to know which ones:

  • AlarmClock

  • A small script that creates receipts (add and subtract values)
edit:

While I was relaxing in the backyard enjoying the weather, I was thinking of

a converter.

That converts anything! With an INI file where you can specify your own things.

I'm gonna include a currency converter. And in the INI file you can specify which currencies you're going to use.

An ebook compiler which fileinstalls an hta based ebook the program helps the user to create

How's that?

Rick

Link to comment
Share on other sites

Ok, I'm practically finished with "Convert Anything".

You have to add the things you want to convert from .. to ... , manually.

Limitations:

You can only add conversions that don't require formulas.

Meters <=> Feet: Yes

Dollars <=> Euros: Yes

Celsius <=> Fahrenheit: No

So that's a little problem.

If you give me a list with common used conversions, I will implement them.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...