hamsteren Posted June 6, 2007 Share Posted June 6, 2007 Hi I am creating an inventory script that uses WMI over the network I have this $iprange_from = _GUICtrlIpAddressCreate ($mainwindow, 150, 20, 125, 20) $iprange_to = _GUICtrlIpAddressCreate ($mainwindow, 280, 20, 125, 20) i want that my script starts at $iprange_from and ends at $iprange_to i can do it with a D range that meens 192.168.0.1 till 192.168.0.255 but i want to scan for example from 192.168.0.1 till 192.168.1.255 I hope you understand my question, my english isn't that perfect greats MikeY Link to comment Share on other sites More sharing options...
hamsteren Posted June 6, 2007 Author Share Posted June 6, 2007 I Have found the solutionFunction: Converts a string containing an IP4 IP into a proper addressFunc ip2long ($ip) $split = StringSplit($ip,'.') $long = ($split[1] * 16777216) + ($split[2] * 65536) + ($split[3] * 256) + ($split[4] * 1) return $long EndFunc oÝ÷ Ù±nËb¢{¢{Þ®Û¦º)z¶v·¬²Úø öv·¬³û¿m«¢+Ø)Õ¹±½¹É¥À ÀÌØí±½¹¤(%¥´ÀÌØí¥ÁlÑt($ÀÌØí¥ÁlÁtô±½½È ÀÌØí±½¹¼ÄØÜÜÜÈÄؤ($ÀÌØí½ÙÈô ÀÌØí±½¹´ ÄØÜÜÜÈÄبÀÌØí¥ÁlÁt¤¤($ÀÌØí¥ÁlÅtô±½½È ÀÌØí½ÙȼØÔÔÌؤ($ÀÌØí½ÙÈô ÀÌØí½ÙÈ´ ØÔÔÌبÀÌØí¥ÁlÅt¤¤($ÀÌØí¥ÁlÉtô±½½È ÀÌØí½ÙȼÈÔؤ($ÀÌØí½ÙÈô ÀÌØí½ÙÈ´ ÈÔبÀÌØí¥ÁlÉt¤¤($ÀÌØí¥ÁlÍtô±½½È ÀÌØí½ÙȤ(%ÉÑÕɸÀÌØí¥ÁlÁtµÀìÌäì¸ÌäìµÀìÀÌØí¥ÁlÅtµÀìÌäì¸ÌäìµÀìÀÌØí¥ÁlÉtµÀìÌäì¸ÌäìµÀìÀÌØí¥ÁlÍt)¹Õ¹(oÝ÷ Øíá®*Þj׶ öv·¬²×±µº1zȧr[y¸§r[z[Fº"×kzË»x-ý¶®¶s`¢b33c¶&ævUög&öÒÒôuT7G&ÄFG&W747&VFRb33c¶ÖçvæF÷rÂSÂ#Â#RÂ#¢b33c¶&ævU÷FòÒôuT7G&ÄFG&W747&VFRb33c¶ÖçvæF÷rÂ#Â#Â#RÂ# oÝ÷ ØÚ0Áæ«z "hr·µëaz¶§æ®¶s` ¦f÷"b33c¶Òb33c¶&ævUög&öÕöÆöærFòb33c¶&ævUög&öÕ÷Fð¢eTä5DôâÆöæs&b33c¶¦æW@ Link to comment Share on other sites More sharing options...
Confuzzled Posted June 17, 2007 Share Posted June 17, 2007 I Have found the solution Function: Converts a string containing an IP4 IP into a proper address Func ip2long ($ip) $split = StringSplit($ip,'.') $long = ($split[1] * 16777216) + ($split[2] * 65536) + ($split[3] * 256) + ($split[4] * 1) return $long EndFuncoÝ÷ Ù±nËb¢{¢{Þ®Û¦º)z¶v·¬²Úø öv·¬³û¿m«¢+ÙÕ¹±½¹É¥À ÀÌØí±½¹¤(¥´ÀÌØí¥ÁlÑt(ÀÌØí¥ÁlÁtô±½½È ÀÌØí±½¹¼ÄØÜÜÜÈÄؤ(ÀÌØí½ÙÈô ÀÌØí±½¹´ ÄØÜÜÜÈÄبÀÌØí¥ÁlÁt¤¤(ÀÌØí¥ÁlÅtô±½½È ÀÌØí½ÙȼØÔÔÌؤ(ÀÌØí½ÙÈô ÀÌØí½ÙÈ´ ØÔÔÌبÀÌØí¥ÁlÅt¤¤(ÀÌØí¥ÁlÉtô±½½È ÀÌØí½ÙȼÈÔؤ(ÀÌØí½ÙÈô ÀÌØí½ÙÈ´ ÈÔبÀÌØí¥ÁlÉt¤¤(ÀÌØí¥ÁlÍtô±½½È ÀÌØí½ÙȤ(ÉÑÕɸÀÌØí¥ÁlÁtµÀìÌäì¸ÌäìµÀìÀÌØí¥ÁlÅtµÀìÌäì¸ÌäìµÀìÀÌØí¥ÁlÉtµÀìÌäì¸ÌäìµÀìÀÌØí¥ÁlÍt)¹Õ¹Comment: The first funtion contains ($split[4] * 1) which is a waste of resources (but an excellent inclusion to make the algorithm clear). I see the second has already been pruned. The speed savings may not be important, but who knows? Link to comment Share on other sites More sharing options...
psadac Posted July 29, 2007 Share Posted July 29, 2007 (edited) I've just needed these functions for little script, but i think it would be better to use bit manipulation functions : ; Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address Func ip2long($ip_str) Local $ip = StringSplit($ip_str, '.') Return BitOR(BitShift($ip[1], -24), BitShift($ip[2], -16), BitShift($ip[3], -8), $ip[4]) EndFunc ;==>ip2long ; Converts an (IPv4) Internet network address into a string in Internet standard dotted format Func long2ip($ip) Return BitAND(BitShift($ip, 24), 255) & "." & _ BitAND(BitShift($ip, 16), 255) & "." & _ BitAND(BitShift($ip, 8), 255) & "." & _ BitAND($ip, 255) EndFunc ;==>long2ip Edited July 29, 2007 by psadac Link to comment Share on other sites More sharing options...
ptrex Posted July 31, 2007 Share Posted July 31, 2007 @all This is a working example based on the code snippets expandcollapse popup#include <GuiConstants.au3> #include <GuiIPAddress.au3> opt("GUIOnEventMode", 1) $mainwindow = GuiCreate("IP Addresses", 475, 271,(@DesktopWidth-475)/2, (@DesktopHeight-271)/2 , _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) GUISetOnEvent($GUI_EVENT_CLOSE, "GUIevent") ; Close GuiEvent ;Button Control $cButton1=GUICtrlCreateButton ("Get IP",10,20,100,20) GUICtrlSetOnEvent(-1,"GetIP") $iprange_from = _GUICtrlIpAddressCreate ($mainwindow, 150, 20, 125, 20) $iprange_to = _GUICtrlIpAddressCreate ($mainwindow, 280, 20, 125, 20) GuiSetState() While 1 Sleep(100) WEnd Func GetIP() ; Now use the function to create a proper address from the ip addresses $iprange_from_long = ip2long(_GUICtrlIpAddressGet($iprange_from)) $iprange_to_long = ip2long(_GUICtrlIpAddressGet($iprange_to)) ; Now we are going to create the range for $i = $iprange_from_long to $iprange_to_long ConsoleWrite(long2ip($i)&@CRLF) next EndFunc ; Function: Converts a string containing an IP4 IP into a proper address Func ip2long ($ip) $split = StringSplit($ip,'.') $long = ($split[1] * 16777216) + ($split[2] * 65536) + ($split[3] * 256) + ($split[4] * 1) return $long EndFunc ;Function: Converts a proper address to an IP4 IP address func long2ip ($long) dim $ip[4] $ip[0] = Floor( $long / 16777216 ) $over = ( $long - (16777216 * $ip[0])) $ip[1] = Floor( $over / 65536 ) $over = ($over - (65536 * $ip[1])) $ip[2] = Floor( $over / 256 ) $over = ($over - (256 * $ip[2])) $ip[3] = Floor($over) return $ip[0] & '.' & $ip[1] & '.' & $ip[2] & '.' & $ip[3] EndFunc ;----------------------------- Gui Events ------------------------------------ Func GUIevent() Exit EndFunc regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New 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