sumit Posted October 18, 2007 Share Posted October 18, 2007 Guys this is a part of the code from my program. My problem is that this program as long as $msg = 0. my program pings to 203.81.72.254. That is it keeps on sending pinging packets. I want to reduce the no. of times my program pings. I want that my program should only ping after 100 seconds and still when user selects $msg = $prefsitem etc. it should take required action. Here is the actual code CODEWhile 1 $msg = TrayGetMsg() Select Case $msg = 0 $ping = ping("203.81.72.254",1000) if $ping then ContinueLoop Else ExitLoop Endif Case $msg = $prefsitem $oIE = _IECreate("about:blank") WinSetState("about", "", @SW_MAXIMIZE) Case $msg = $aboutitem MsgBox(64, "about:", "MPT Broadband Internet Access Client") Case $msg = $exititem ExitLoop EndSelect WEnd I tried something like this CODEWhile 1 $msg = TrayGetMsg() Select Case $msg = 0 sleep(100000) ; this is the additional step $ping = ping("203.81.72.254",1000) if $ping then ContinueLoop Else ExitLoop Endif Case $msg = $prefsitem $oIE = _IECreate("about:blank") WinSetState("about", "", @SW_MAXIMIZE) Case $msg = $aboutitem MsgBox(64, "about:", "MPT Broadband Internet Access Client") Case $msg = $exititem ExitLoop EndSelect WEnd but here the program stops responding to user action for $msg = $prefsitem etc. because it goes to sleep. Please suggest. Thanks Link to comment Share on other sites More sharing options...
weaponx Posted October 18, 2007 Share Posted October 18, 2007 (edited) Perhaps: Select Case $msg = 0 If (TimerDiff($stamp) / 1000) > 100 Then $ping = Ping("203.81.72.254", 1000) If $ping Then $stamp = TimerInit() ContinueLoop Else ExitLoop EndIf Else ContinueLoop EndIf Case $msg = $prefsitem $oIE = _IECreate("about:blank") WinSetState("about", "", @SW_MAXIMIZE) Case $msg = $aboutitem MsgBox(64, "about:", "MPT Broadband Internet Access Client") Case $msg = $exititem ExitLoop EndSelect Store a timestamp after successful ping, don't ping again until 100 seconds have passed. EDIT: You should probably dim $stamp = 0 at the top of your script Edited October 18, 2007 by weaponx Link to comment Share on other sites More sharing options...
sumit Posted October 18, 2007 Author Share Posted October 18, 2007 Perhaps: Select Case $msg = 0 If (TimerDiff($stamp) / 1000) > 100 Then $ping = Ping("203.81.72.254", 1000) If $ping Then $stamp = TimerInit() ContinueLoop Else ExitLoop EndIf Else ContinueLoop EndIf Case $msg = $prefsitem $oIE = _IECreate("about:blank") WinSetState("about", "", @SW_MAXIMIZE) Case $msg = $aboutitem MsgBox(64, "about:", "MPT Broadband Internet Access Client") Case $msg = $exititem ExitLoop EndSelect Store a timestamp after successful ping, don't ping again until 100 seconds have passed. EDIT: You should probably dim $stamp = 0 at the top of your script Thanks a lot buddy. I am really greatful for this 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