Jump to content

Do two things at once?


ThinkOSX
 Share

Recommended Posts

Greetings!

I'd just like to say what an awesome time i'm having learning AutoIt. I've always wanted to learn programming but could never wrap my head around it. I've always been quite handy with batch files though so AutoIt made perfect sense to me!

Anyways..

I've written a function which will ping Google and then my server to verify that the app has internet access and that my server is up.

The issue is that i cant figure out a way to have it continually check without that being the only thing it's doing. While i have the function looping, none of the GUI or other functions work as it's busy pinging.

Here is my code for checking the internets and my server.

I was calling it in the same section where button press detection is defined. The script would constantly poll the GUI for button presses but also run CheckInternet().

$Online = 1

While Online = 1

CheckInternet()

Online = 0

Func CheckInternet()
If $Online = 0 Then
   While $Online = 0
   Do
   If Ping("Google.com", 100) Then
      If Ping($ServerIP, 100) Then
      $Online = 1
      $ConnStatus = "ONLINE"
      GUICtrlSetColor($LAB_ConnStatus, 0x008000)
      GUICtrlSetData($LAB_ConnStatus, $ConnStatus)
      Else
      $ServerStatus = "Server is DOWN!"
      $ConnStatus = "SERVER DOWN"
      GUICtrlSetColor($LAB_ConnStatus, 0xFF0000)
      GUICtrlSetData($LAB_ConnStatus, $ConnStatus)
         If Ping("Google.com", 100) Then
         MsgBox(0, "Status", "Internet is UP but server is DOWN!", 0, $vToolMainWin)
      Else
         $ConnStatus = "NONET!"
         GUICtrlSetColor($LAB_ConnStatus, 0xFF0000)
         GUICtrlSetData($LAB_ConnStatus, $ConnStatus)
         MsgBox(0, "Status", $ServerStatus, 0, $vToolMainWin)
      EndIf
      Exit
      EndIf
      Else
      $ConnStatus = "NONET!"
      GUICtrlSetColor($LAB_ConnStatus, 0xFF0000)
      GUICtrlSetData($LAB_ConnStatus, $ConnStatus)
      $InetStatus = "You are OFFLINE!" & @LF & _
      "At this time, vTool requires an internet connection."
      MsgBox(0, "Status", $InetStatus, 0, $vToolMainWin)
      Exit
   EndIf
   Until $Online = 1
   WEnd
EndIf
EndFunc

There are plenty of workarounds i can think of to compensate for if AutoIt can't multitask. Would just be awesome if it could.

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...