Advertisement
XPyro

HostSearch 1.0

Jun 5th, 2011
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 6.13 KB | None | 0 0
  1. #NoTrayIcon
  2. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  3. #AutoIt3Wrapper_icon=icono.ico
  4. #AutoIt3Wrapper_outfile=HostSearch 1.0.exe
  5. #AutoIt3Wrapper_Compression=4
  6. #AutoIt3Wrapper_UseX64=n
  7. #AutoIt3Wrapper_Res_Comment=Creado por XPyro
  8. #AutoIt3Wrapper_Res_Description=Script para buscar PCs conectadas en su red local
  9. #AutoIt3Wrapper_Res_Fileversion=1.0.0.0
  10. #AutoIt3Wrapper_Res_LegalCopyright=XPYRO SOFT
  11. #AutoIt3Wrapper_Res_Language=2058
  12. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  13. #include <ButtonConstants.au3>
  14. #include <GUIConstantsEx.au3>
  15. #include <ListViewConstants.au3>
  16. #include <StaticConstants.au3>
  17. #include <WindowsConstants.au3>
  18. #Include <GuiListView.au3>
  19. #include <iNet.au3>
  20.  
  21. $Form1 = GUICreate("HostSearch 1.0", 390, 361, -1, -1)
  22. $Button1 = GUICtrlCreateButton("Buscar", 5, 8, 75, 25, $WS_GROUP)
  23. $Button2 = GUICtrlCreateButton("Guardar", 85, 8, 75, 25, $WS_GROUP)
  24. GUICtrlCreateLabel("De:", 240, 15, 20, 17)
  25. $Input1 = GUICtrlCreateInput("1", 260, 9, 35, 22)
  26. GUICtrlCreateLabel("Hasta:", 310, 15, 30, 17)
  27. $Input2 = GUICtrlCreateInput("300", 350, 9, 35, 22)
  28. $ListView1 = _GUICtrlListView_Create($Form1, "", 5, 40, 380, 286)
  29. _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FLATSB, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
  30. _GUICtrlListView_InsertColumn($ListView1, 0, "IP", 120)
  31. _GUICtrlListView_InsertColumn($ListView1, 1, "Nombre local", 120)
  32. _GUICtrlListView_InsertColumn($ListView1, 2, "Tiempo en responder", 120)
  33. $Label1 = GUICtrlCreateLabel("Listo para comenzar", 8, 336, 182, 17)
  34. GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
  35. GUICtrlSetColor(-1, 0x008000)
  36. $Label2 = GUICtrlCreateLabel("Acerca de", 335, 336, 53, 17)
  37. GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif")
  38. GUICtrlSetColor(-1, 0x0000FF)
  39. GUICtrlSetCursor (-1, 0)
  40. GUISetState(@SW_SHOW)
  41. GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
  42.  
  43. While 1
  44.     $nMsg = GUIGetMsg()
  45.     Switch $nMsg
  46.         Case $GUI_EVENT_CLOSE
  47.             Exit
  48.         Case $Button1
  49.             $Msgc = MsgBox(8228,"Comenzar","¿Comenzar búsqueda?")
  50.             If $Msgc = 6 Then
  51.                 _GUICtrlListView_DeleteAllItems($ListView1)
  52.                 GUICtrlSetData($Button1, "Detener")
  53.                 GUICtrlSetState($Button2, $GUI_DISABLE)
  54.                 GUICtrlSetState($Label2, $GUI_DISABLE)
  55.                 $Cadena = StringSplit(@IPAddress1, ".")
  56.                 TCPStartup()
  57.                 For $i = GUICtrlRead($Input1) To GUICtrlRead($Input2)
  58.                     $nMsg = GUIGetMsg()
  59.                     If $nMsg = $Button1 Then
  60.                         $Msgd = MsgBox(8244,"Detener","¿Desea detener la busqueda?")
  61.                         If $Msgd = 6 Then ExitLoop
  62.                     EndIf
  63.                     $IP = $Cadena[1] & "." & $Cadena[2] & "." &  $Cadena[3] & "." &  $i
  64.                     GUICtrlSetData($Label1, "Buscando en: " & $IP)
  65.                     $aping = Ping($IP)
  66.                     $aResult = _TCPIpToName($IP)
  67.                     If Not @error Then
  68.                         $hItem = _GUICtrlListView_AddItem($ListView1, $IP)
  69.                         _GUICtrlListView_AddSubItem($ListView1, $hItem, $aResult, 1)
  70.                         _GUICtrlListView_AddSubItem($ListView1, $hItem, $aping & " Milisegundos", 2)
  71.                     EndIf
  72.                     If $nMsg = $Button1 Then
  73.                         $Msgd = MsgBox(8244,"Detener","¿Desea detener la busqueda?")
  74.                         If $Msgd = 6 Then ExitLoop
  75.                     EndIf
  76.                 Next
  77.                 TCPShutdown()
  78.                 GUICtrlSetData($Label1, "Terminado, encontrados " & _GUICtrlListView_GetItemCount($ListView1))
  79.                 GUICtrlSetData($Button1, "Buscar")
  80.                 GUICtrlSetState($Button2, $GUI_ENABLE)
  81.                 GUICtrlSetState($Label2, $GUI_ENABLE)
  82.                 MsgBox(8256,"Listo", "Terminado, encontrados " & _GUICtrlListView_GetItemCount($ListView1))
  83.             EndIf
  84.         Case $Button2
  85.             $Saveh = FileSaveDialog("Guardar IPs", "", "Archivo de texto (*.txt)", 18, "Host-" & @MDAY & "-" & @MON & "-" & @YEAR & ".txt", $Form1)
  86.             $Saveho = FileOpen($Saveh, 10)
  87.             For $fw = 0 to _GUICtrlListView_GetItemCount($ListView1)
  88.                 FileWrite($Saveho, _GUICtrlListView_GetItemText($ListView1, $fw) & @CRLF & _GUICtrlListView_GetItemText($ListView1, $fw, 1) & @CRLF & _GUICtrlListView_GetItemText($ListView1, $fw, 2) & @CRLF & @CRLF)
  89.             Next
  90.             FileClose($Saveho)
  91.         Case $Label2
  92.             _Acercade()
  93.     EndSwitch
  94. WEnd
  95.  
  96. Func _Acercade() ;Función acerca de-------------------------------------------------
  97.     GUISetState(@SW_DISABLE, $Form1)
  98.     Local $AcForm = GUICreate('Acerca de', 329, 296, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE), $Form1)
  99.     GUICtrlCreateIcon(@ScriptFullPath, 99, 99, 10, 128, 128, BitOR($SS_NOTIFY, $WS_GROUP))
  100.     GUICtrlCreateLabel('HostSearch 1.0.0.0', 0, 145, 329, 33, $SS_CENTER)
  101.     GUICtrlSetFont(-1, 18, 800, 0, 'Verdana')
  102.     GUICtrlCreateLabel('Script para buscar PCs conectadas en su red local.', 0, 180, 329, 17, $SS_CENTER)
  103.     GUICtrlCreateLabel('© 2008 - 2011 XPYRO SOFT', 0, 200, 329, 17, $SS_CENTER)
  104.     Local $Link = GUICtrlCreateLabel('http://softx.comxa.com/', 0, 230, 329, 17, $SS_CENTER)
  105.     GUICtrlSetColor(-1, 0x0000FF)
  106.     GUICtrlSetCursor(-1, 0)
  107.     Local $2Button1 = GUICtrlCreateButton('Aceptar', 77, 255, 175, 25)
  108.     GUISetState(@SW_SHOW, $AcForm)
  109.     Do
  110.         Local $GMsg = GUIGetMsg()
  111.         If $GMsg = $Link Then ShellExecute("http://softx.comxa.com/")
  112.         Sleep(10)
  113.     Until $GMsg = $GUI_EVENT_CLOSE Or $GMsg = $2Button1
  114.     GUISetState(@SW_ENABLE, $Form1)
  115.     GUIDelete($AcForm)
  116. EndFunc ;---------------------------------------------------------------------------
  117.  
  118. Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
  119.     #forceref $hWnd, $iMsg, $iwParam
  120.     Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
  121.     $hWndListView = $ListView1
  122.     If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)
  123.  
  124.     $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
  125.     $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
  126.     $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
  127.     $iCode = DllStructGetData($tNMHDR, "Code")
  128.     Switch $hWndFrom
  129.         Case $hWndListView
  130.             Switch $iCode
  131.                 Case $NM_DBLCLK
  132.                     $Nitems = _GUICtrlListView_GetItemCount($ListView1)
  133.                     If $Nitems <> "" Then
  134.                         $ni = 0
  135.                         Do
  136.                             $Ires = _GUICtrlListView_GetItemSelected($ListView1, $ni)
  137.                             $ni = $ni + 1
  138.                         Until $Ires = True
  139.                     EndIf
  140.                     ShellExecute("\\" & _GUICtrlListView_GetItemText($ListView1, $ni - 1))
  141.             EndSwitch
  142.     EndSwitch
  143.     Return $GUI_RUNDEFMSG
  144. EndFunc   ;==>WM_NOTIFY
  145.  
  146. ;http://softx.comxa.com/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement