Jump to content

Net Meter


sak
 Share

Recommended Posts

Easy Script: Net Meter. Design for use with Mobile net Modem. :unsure:

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>

Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)

Global $curr

Local $hWnd = GUICreate("Net Meter", 265, 19, 750, 713, _
BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_POPUP,$WS_GROUP,$WS_CLIPSIBLINGS), _
BitOR($WS_EX_OVERLAPPEDWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUISetIcon(@WindowsDir&"\Network Diagnostic\xpnetdiag.exe", -1, $hWnd)
Local $hProgress = GUICtrlCreateProgress(2, 2, 262, 17, -1, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUISetState(@SW_SHOW)

TraySetClick(1+16)
Local $infoitem = TrayCreateItem("Info")
TrayItemSetOnEvent(-1,"ShowInfo")
TrayCreateItem("")
Local $exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitScript")
TraySetIcon(@WindowsDir&"\Network Diagnostic\xpnetdiag.exe", -1)
TraySetState()

Do
    If @IPAddress1 <> '127.0.0.1'Then
        $curr = Ping("www.google.com", 4000)
        GUICtrlSetData($hProgress, $curr/100*10)
        ToolTip("Status:Online IP:"&@IPAddress1&" Send:"&$curr&".ms" ,752, 695, "")
        If $curr <= 0 Or GUICtrlRead($hProgress) <= 0 Then
            ToolTip("No,signal..Please wait! ", 820, 695, "")
            GUICtrlSetData($hProgress, 0)
        Else
            GUICtrlSetData($hProgress, $curr/100*10)
        EndIf
    Else
        ToolTip("Status:Offline IP:"&@IPAddress1&" Send:"&$curr&"0.ms" ,775, 695, "")
        GUICtrlSetData($hProgress, 0)
    EndIf
Until GUIGetMsg() = -3

Func ShowInfo()
    Msgbox(4096,"Net Meter","Create by:sak2005", 0, $hWnd)
EndFunc

Func ExitScript()
    Exit
EndFunc
Edited by sak
Link to comment
Share on other sites

  • Moderators

and please you should use AutoIt Tags for post your code.Posted Image

Where do these rules come from? It's like people telling other people not to quote the people they're referencing. Kind of ridiculous.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

wakillon

New modify. You're can drag mouse to move GUI.

Click or Right click on Tray icon for info and exit GUI.:unsure:

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>

Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)

Global Const $SC_DRAGMOVE = 0xF012
Global $curr

Local $hGUI = GUICreate("Net Meter", 228, 35, -1, -1, _
BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_POPUP,$WS_GROUP,$WS_CLIPSIBLINGS), _
BitOR($WS_EX_OVERLAPPEDWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUISetBkColor(0x000000, $hGUI)
GUISetIcon(@WindowsDir&"\Network Diagnostic\xpnetdiag.exe", -1, $hGUI)
GUICtrlSetCursor(-1, 3)
Local $Progress = GUICtrlCreateProgress(1, 16, 225, 17)
GUICtrlSetCursor(-1, 3)
Local $Label = GUICtrlCreateLabel(@TAB&"Sending Data Please wait!", 1, 1, 298, 15)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1, 3)
GUISetState(@SW_SHOW)

TraySetClick(1+16)
Local $infoitem = TrayCreateItem("Info")
TrayItemSetOnEvent(-1,"ShowInfo")
TrayCreateItem("")
Local $exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitScript")
TraySetIcon(@WindowsDir&"\Network Diagnostic\xpnetdiag.exe", -1)
TraySetState()

While 1
    Local $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_PRIMARYDOWN
            _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
        Case 0
            If @IPAddress1 <> '127.0.0.1'Then
                $curr = Ping("www.Google.com", 4000)
                GUICtrlSetData($Progress, $curr/100*10)
                GUICtrlSetData($Label,"Status:Online IP:"&@IPAddress1&" Send:"&GUICtrlRead($Progress)*10&".ms")
            Else
                GUICtrlSetData($Progress, $curr/100*10)
                GUICtrlSetData($Label,"Status:Offline IP:"&@IPAddress1&" Send:"&GUICtrlRead($Progress)*10&".ms")
            EndIf
    EndSwitch
WEnd

Func ShowInfo()
    Msgbox(4096,"Net Meter","Create by:sak2005", 0, $hGUI)
EndFunc

Func ExitScript()
    Exit
EndFunc
Edited by sak
Link to comment
Share on other sites

Where do these rules come from? It's like people telling other people not to quote the people they're referencing. Kind of ridiculous.

Easy there trigger. I believe he was just suggesting that he should the autoit tags since it does indeed make it easier for people read the code. I don't know why you, a mod, of all people would make an issue out of it.

Anyway, to get back on topic, it's a neat script. The loop/refresh rate is causing it the CPU to get as high as 14-20% use on my machine. Perhaps 1/2/sec refresh rate should do it.

Edited by Foxhound
Link to comment
Share on other sites

  • Moderators

Easy there trigger. I believe he was just suggesting that he should the autoit tags since it does indeed make it easier for people read the code. I don't know why you, a mod, of all people would make an issue out of it.

Trigger? :unsure:

Easier or not for you specifically, if you've been a member for any period of time, you'd know that the autoit code tags, though pretty as they may be, break scripts often and make them un-manageable. Then people leave, never update, or forget what the code was, and you have quite a few threads asking for help.

Easier on the eyes? Maybe. Easier on the Soul? Doubtful.

It's you the users choice on how they chose to display their code ( if at all ), as well as if you want to use stupid font that makes your eyes cross when reading something.

There you go... more explanation... now you know why I said what I said when I said it... Get it? ... Good.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Modify again is Auto browser Net meter. Use includ netmeter.au3 :unsure:

includ script: netmeter.au3

#include-once
#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>

Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)

Global Const $SC_DRAGMOVE = 0xF012
Global $hGUI, $curr


Func netmeter()
Local $hGUI = GUICreate("Net Meter", @DesktopWidth/4-29, @DesktopHeight/4-158, 400, 0, _
$WS_POPUP, BitOr($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor(0x000000, $hGUI)
GUISetIcon(@WindowsDir&"\Network Diagnostic\xpnetdiag.exe", -1, $hGUI)
GUICtrlSetCursor(-1, 3)
Local $Progress = GUICtrlCreateProgress(1, 16, 225, 17)
GUICtrlSetCursor(-1, 3)
Local $Label = GUICtrlCreateLabel(@TAB&"Sending Data Please wait!", 1, 1, 298, 15)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1, 3)
GUISetState(@SW_SHOW)

TraySetClick(1+16)
Local $infoitem = TrayCreateItem("Info")
TrayItemSetOnEvent(-1,"ShowInfo")
TrayCreateItem("")
Local $exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitScript")
TraySetIcon(@WindowsDir&"\Network Diagnostic\xpnetdiag.exe", -1)
TraySetState()

While 1
    Local $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_PRIMARYDOWN
            _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
        Case 0
            If @IPAddress1 <> '127.0.0.1'Then
                $curr = Ping("www.Google.com", 4000)
                GUICtrlSetData($Progress, $curr/100*10)
                GUICtrlSetData($Label,"Status:Online IP:"&@IPAddress1&" Send:"&GUICtrlRead($Progress)*10&".ms")
            Else
                GUICtrlSetData($Progress, $curr/100*10)
                GUICtrlSetData($Label,"Status:Offline IP:"&@IPAddress1&" Send:"&GUICtrlRead($Progress)*10&".ms")
            EndIf
    EndSwitch
WEnd
    Return
EndFunc

Func ShowInfo()
    Msgbox(4096,"Net Meter","Create by:sak2005", 0, $hGUI)
EndFunc

Func ExitScript()
    Exit
EndFunc

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

Auto browser Net meter

#include "netmeter.au3"
Local $keyname = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{EF29A0E7-C8AC-4982-A287-1952F9A35DF0}'
Local $valuename = 'DhcpIPAddress'
Local $valuedata = '0.0.0.0'
Local $firefoxpath = @ProgramFilesDir&'\Mozilla Firefox 4.0 Beta 7\firefox.exe'
Local $iepath =  @ProgramFilesDir&'\Internet Explorer\IEXPLORE.EXE'
Local $ipserver = '127.0.0.1'

While 1
    If RegRead($keyname, $valuename) = $valuedata Or @IPAddress1 = $ipserver Then
        ToolTip("Pleased.. Connections.", 400, 300, "")
    Else
        If FileExists($firefoxpath) Then
            ToolTip("")
            ShellExecute($firefoxpath)
        Else
            ShellExecute($iepath)
            ToolTip("")
        EndIf
            netmeter()
            ExitLoop
    EndIf
        Sleep(1000)
WEnd
Edited by sak
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...