Jump to content

count until


Recommended Posts

iam trying to look for every hostname on my b address but it dont seem to look further then 1, it must count from172.29.1.1 till 172.29.254.254

#include <GUIConstants.au3>
#include <inet.au3>
Dim $f,$i,$sIp


GUICreate("My GUI list"); will create a dialog box that when displayed is centered

$add=GUICtrlCreateButton ("Add", 64,32,75,25)
$clear=GUICtrlCreateButton ("Clear", 64,72,75,25)
$mylist=GUICtrlCreateList ("", 176,32,121,97)
GUICtrlSetLimit(-1,200); to limit horizontal scrolling

$close=GUICtrlCreateButton ("my closing button", 64,160,175,25)

GUISetState ()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()

    Select
        case $msg = $add
            
TCPStartup()

do 
For $i = 1 to 254 Step +1
$f = Number(1)
$sIp= "172.29."&$f&"."&$i
GUICtrlSetData($mylist,$sIp)    
if $i = "254"Then
$bla = Number($f +1)
$ssIp= "172.29."&$bla&"."&$i
GUICtrlSetData($mylist,$ssIp)   

    EndIf
;~ $result =_TCPIpToName ($sIp)
Next
Until $f = 254
         case $msg = $clear
        GUICtrlSetData($mylist,"")
         Case $msg = $close
            MsgBox(0,"", "the closing button has been clicked",2)
            Exit
    EndSelect
Wend
Edited by realkiller
Link to comment
Share on other sites

iam trying to look for every hostname on my b address but it dont seem to look further then 1, it must count from172.29.1.1 till 172.29.254.254

For $i = 1 to 254
       For $j = 1 to 254
       [...]
       Next
   Next

try something like this !!!

Cramaboule !

Link to comment
Share on other sites

that won't work

fount it myself but now is the question how can sort the numbers?

#include <GUIConstants.au3>
#include <inet.au3>
Dim $f,$i,$sIp


GUICreate("My GUI list",800,600); will create a dialog box that when displayed is centered

$add=GUICtrlCreateButton ("Add", 64,32,75,25)
$clear=GUICtrlCreateButton ("Clear", 64,72,75,25)
$mylist=GUICtrlCreateList ("", 176,32,150,400)
GUICtrlSetLimit(-1,-1); to limit horizontal scrolling



GUISetState ()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()

    Select
        case $msg = $add
            
TCPStartup()
$f = Number(1)
do 
For $i = 1 to 254 Step +1

if $i = "254"Then
    $f = Number($f +1)
EndIf
$sIp= "172.29."&$f&"."&$i
GUICtrlSetData($mylist,$sIp)    

;~ $result =_TCPIpToName ($sIp)
Next

Until $f = 254
        
            
        
         case $msg = $clear
        GUICtrlSetData($mylist,"")
    EndSelect
Wend
Link to comment
Share on other sites

IPs can be converted from Numeric to String and the way round, too. So you can use this Code

For $i = 2887581953 To 2887646974
 ConsoleWrite(IpConvert($i) & @LF)
Next

Func IpConvert($asNewIP)
    Local $x,$Num,$return
    If IsNumber($asNewIP) Then
        For $x = 1 To 4
            $Num = Int($asNewIP / 256 ^ (4 - $x))
            $asNewIP -= ($Num * 256 ^ (4 - $x))
            If $Num > 255 Then
                Return "0.0.0.0"
            EndIf
            If $x = 1 Then
                $return =  $Num
            Else
                $return &= "." & $Num
            EndIf
        Next
        Return $return
    Else    
        Local $lnResults, $lnIndex, $lnIpAry
        $lnIpAry = StringSplit($asNewIP, ".")
If $lnIndex[0] <> 4 THen Return -1
        For $lnIndex = 1 To 4
            If Not ($lnIndex = 4) Then
                $lnIpAry[$lnIndex] *= (256 ^ (4 - $lnIndex))
            EndIf
            $lnResults += $lnIpAry[$lnIndex]
        Next
        Return $lnResults
    EndIf
Return(-1)
EndFunc

//Edit: the List sorts them automatically in alphabeltical order. To avoid that, use

$mylist=GUICtrlCreateList ("", 176,32,121,97,$WS_BORDER+ $WS_VSCROLL)

The ListView mustn't sort the IPs because they are created in the right order :D

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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