Jump to content

Recommended Posts

Posted

What in the world happened?

All the other scripts work, but not this one...

I have no idea why but it continues to happen unless the filename is renamed to something like "abcd.exe". thats the only way it works and i'm kinda pissed that it does this...

the code's down below so feel free to tell me what i did wrong and if anyone could compile it and see if they get the same result...

im thinking file corruption and i've already reinstalled autoit v3...

global $notify

If FileExists("Preferences01.ini") = 0 Then

setup()

Else

test()

EndIf

Func setup()

#include <GUIConstants.au3>

GUICreate("Connection Guardian v1.0 Setup",300,200)

$checkfor = GUICtrlCreateInput("Ip address or website",5,5,150)

$time = GUICtrlCreateCombo("Interval Time",5,30,150)

GUICtrlSetData($time,"1 Minute|5 Minutes|10 Minutes|15 Minutes|30 Minutes|1 Hour|2 Hours")

$set = GUICtrlCreateButton("Set And Start",215,165,80)

$notify = GUICtrlCreateCombo("Type of notification",5,60,150)

GUICtrlSetData($notify,"Ballon Tip|Msg Box|Tool Tip (by mouse pointer)|Tray Icon")

GUISetState()

While 1

$msg = GUIGetMsg()

If $msg = $gui_event_close Then

Exit

EndIf

If $msg = $gui_event_minimize Then

;winsetstate()

EndIf

If $msg = $set Then

$address = GUICtrlRead($checkfor)

$time = GUICtrlRead($time)

$notify = GUICtrlRead($notify)

If $address = "Ip address or website" Then

MsgBox(0,"Error!","Please insert an IP address that is not your own or a website like www.google.com")

GUIDelete()

setup()

ElseIf $time = "Interval Time" Then

MsgBox(0,"Error!","Please Select an interval period")

GUIDelete()

setup()

ElseIf $notify = "Type of notification" Then

MsgBox(0,"Error!","Select a type of notification!")

GUIDelete()

setup()

Else

IniWrite("Preferences01.ini","Settings","Address",$address)

IniWrite("Preferences01.ini","Settings","Interval",$time)

IniWrite("Preferences01.ini","Settings","Notfiy",$notify)

test()

EndIf

EndIf

WEnd

EndFunc

Func test()

$address = IniRead("Preferences01.ini","Settings","Address","www.google.com")

$time = IniRead("Preferences01.ini","Settings","Interval","15 Minutes")

$notify = IniRead("Preferences01.ini","Settings","Notify","Ballon Tip")

If $time = "1 Minute" Then

$time = 60000

ElseIf $time = "5 Minutes" Then

$time = 60000 * 5

ElseIf $time = "10 Minutes" Then

$time = 600000

ElseIf $time = "15 Minutes" Then

$time = 15000 * 60

ElseIf $time = "30 Minutes" Then

$time = 30000 * 60

ElseIf $time = "1 Hour" Then

$time = 3600000

ElseIf $time = "2 Hours" Then

$time = 120 * 60000

EndIf

While 1

Ping($address)

If @error > 0 Then

If $notify = "Ballon Tip" Then

TrayTip("Network Error Detected!","Your internet connection may have been lost. This may also be due to server issues. To check this, google and yahoo will both be tested.",30,3)

test2()

ElseIf $notify = "Msg Box" Then

MsgBox(0,"Network Error Detected!","Your internet connection may have been lost. This may also be due to server issues. To check this, google will be tested. A confirmation box will appear showing the results.")

test2()

ElseIf $notify = "Tool Tip (by mouse pointer)" Then

ToolTip("Network Error Detected! Checking Validity...you will see a confirmation box that will show the results.")

test2()

ElseIf $notify = "Tray Icon" Then

;work on this

EndIf

EndIf

Sleep($time)

WEnd

EndFunc

Func test2()

Ping("www.google.com")

If @error > 0 Then

If $notify = "Ballon Tip" Then

TrayTip("Validity Check Concluded...","Your network connection has been lost...",30,3)

test()

ElseIf $notify = "Msg Box" Then

MsgBox(0,"Validity Check Concluded...","Your network connection has been lost...")

test()

ElseIf $notify = "Tool Tip (by mouse pointer)" Then

ToolTip("Validity Check Concluded...","Your network connection has been lost...")

test()

ElseIf $notify = "Tray Icon" Then

;work on this

EndIf

Else

If $notify = "Ballon Tip" Then

TrayTip("Validity Check Concluded...","Your network connection has NOT been lost. The error must have been due to server issues.",30,3)

test()

ElseIf $notify = "Msg Box" Then

MsgBox(0,"Validity Check Concluded...","Your network connection has NOT been lost. The error must have been due to server issues.")

test()

ElseIf $notify = "Tool Tip (by mouse pointer)" Then

ToolTip("Validity Check Concluded...","Your network connection has NOT been lost. The error must have been due to server issues.")

test()

ElseIf $notify = "Tray Icon" Then

;work on this

EndIf

EndIf

EndFunc

If my posts or emails are not in the correct format, too bad! Technology is my territory!My Programming Page (I need members!):http://doublexlegion.gwgaming.net/

Posted (edited)

Your post is rather vague...

Are you saying that if you run the above script through the interpreter it works fine?

Are you saying that when you compile this script, the compiled script errors/crashes?

Are you saying that the aforementioned compiled script doesn't crash if you rename it afterwards?

What is the filename you are giving it?

If you compile the script as "abcd.exe" does it run?

I certainly hope you're not saying that some precompiled version of this script isn't working and you just haven't even tried recompiling it.

Some notes though:

Don't put the #include line inside a function declaration. It will cause problems for sure. For example, until I moved it to the top of the script, if I hit the "Set And Start" button it would crash saying it was trying to redefine a constant. Also, why do you have it delete and then recreate the GUI everytime you put something wrong in. Why not just have the message box, and then leave the GUI? Also, when I hit "Set And Start" with valid conditions, the program becomes unresponsive. I believe this is because of the Sleep($time) line you give. Your GUI will not respond to any user actions until after that sleep has finished.

*Edit: Also, you kept misspelling "balloon." I'll forgive you if english is not your first language, but otherwise, what kind of a baboon can't see that "ballon" would not be pronounced the same way as ballOOn? (I'll also forgive you if you have some kind of learning disability or dyslexia or something, otherwise, baboon it is [or would you prefer babbon?])

Edited by Saunders
Posted

Here, I think I fixed everything. From "ballons" to indenting. Don't you have a hard time reading your script when everything is just.. there? I used to be opposed to indenting myself, but then when I got into complex scripts I just couldn't tell where one if statement ended and a function began.

Posted (edited)

Here, I think I fixed everything. From "ballons" to indenting. Don't you have a hard time reading your script when everything is just.. there? I used to be opposed to indenting myself, but then when I got into complex scripts I just couldn't tell where one if statement ended and a function began.

<{POST_SNAPBACK}>

i did indent but it doesnt show when i copy it and im too lazy to indent manually...

and yes, the script itself would run fine, but the copiled exe didnt.. i renamed it to a.exe and abcd.exe and it works...

yea i was writing this last night at 2 am so forgive me for that...

but wouldnt the compiler pick that up? it should...

and the notifications are just there for now...no other reason. im making this for my friend so i was in a hurry...his internet always goes down and he wanted a program that could ping some address and report an error if there was one (i could have made this faster which i might for his release, no configuring setup crap and all...just the check function)

sorry for being such a newb but im still working on like three other projects...im not usually that careless.

thanks for your help and i'll see what you did...

i'll report the results in a few.....

Edited by Centurion_D

If my posts or emails are not in the correct format, too bad! Technology is my territory!My Programming Page (I need members!):http://doublexlegion.gwgaming.net/

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
  • Recently Browsing   0 members

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