Jump to content

Help with ping tool


Skorn
 Share

Recommended Posts

Hello, I wanted to make a ping app for my company. We have 2 different networks so I have radio buttons to choose from, which would look like this:

radio1 = ip starts with 10.0.0.

radio2 = ip starts with 20.0.0.

then there is an updown that selects the last octet of the ip. But for some reason it is not updating and the last octet always winds up being 9 or 10 regardless of what I choose in the updown box.

Thanks in advance

ps-the code for the actual pinging was taken from a post on this site, i couldn't find who it was from again to give credit, so thanks whoever you are.

#include <GuiConstants.au3>

GuiCreate("Ping Tool", 300, 300)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)

; selection
GUISetFont (16, 400, 0, "Arial")
GuiCtrlCreateGroup("Choose store:", 30, 20, 180, 100)
$radio1 = GuiCtrlCreateRadio("Store 1", 50, 40, 80)
GuiCtrlSetState(-1, $GUI_CHECKED)
$radio2 = GuiCtrlCreateRadio("Store 2", 50, 80, 120)
GUICtrlCreateGroup ("",-99,-99,1,1);close group

; first 3 octets
$store = GUICtrlCreateLabel("", 60, 200, 100, 30, 0x1000)

; 4th octet selection (width, height)
GUISetFont (16, 400, 0, "Arial")
GuiCtrlCreateLabel("IP Address", 115, 165)
$endip = GuiCtrlCreateInput("1", 180, 200, 75, 30)
GuiCtrlCreateUpDown(-1)
GUICtrlSetLimit(-1,254, 1)

; create ping button
$ping= GUICtrlCreateButton("Ping!", 130, 250, 60, 35)

; GUI MESSAGE LOOP
GuiSetState()

; set default
GUICtrlSetData($store, "10.0.0.")
$startip = "10.0.0."


While 1
   $msg = GUIGetMsg()
   Select
     
      Case $msg = $radio1
             GUICtrlSetData($store, "10.0.0.")
         $startip = "10.0.0."
      Case $msg = $radio2
             GUICtrlSetData($store, "20.0.0.")
         $startip = "20.0.0."
      Case $msg = $ping
         $fullip = $startip & $endip
         $test = $startip & $endip
          msgbox(0,"Updown",$fullip)
         RunWait(@ComSpec & " /C Ping -a -n 1 " & $fullip & "> Find_IP.txt",@MyDocumentsDir, @SW_HIDE)
         $ip = FileRead(@MyDocumentsDir & "\Find_IP.txt", FileGetSize(@MyDocumentsDir & "\Find_IP.txt"))
         FileDelete(@MyDocumentsDir & "\Find_IP.txt")
         MsgBox(0,"Returned Ping String [data]", "" & $ip)
;         MsgBox(0,"" & $strcomputer & " IP:", "" & $ip) 
       
   EndSelect
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
Edited by Skorn
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...