kaotkbliss Posted March 15, 2010 Share Posted March 15, 2010 I am adding on to my printing script to display a selected printers default name as a label. Currently the script works by the user entering the ip address of the printer. I want to be able to take that ip address and return the printer's name. I tried using _iptoname but have not been able to return anything expandcollapse popup#include <GuiConstants.au3> #include <Array.au3> #include <WindowsConstants.au3> #include <iNet.au3> $x = 1 $i = 0 Global $ip Global $ipen Global $ipme Global $ipin Global $ftpr Global $prin Global $ip[$x] $ip = IniReadSection(@WorkingDir & "\printip.ini", "ips") GUICreate("IP Print", 250, 120, -1, -1, -1, $WS_EX_ACCEPTFILES) $ipen = GUICtrlCreateCombo("", 1, 50) GUICtrlCreateLabel("Select IP", 1, 32, 45, 15) For $x = 1 To UBound($ip) - 1 GUICtrlSetData($ipen, $ip[$x][1] & "|") Next $ipme = GUICtrlCreateInput("Enter IP", 1, 3, 100, 20) $ipin = GUICtrlCreateButton("Save IP", 105, 1) $ftpr = GUICtrlCreateInput("", 1, 97, 100, 20) GUICtrlSetState($ftpr, $GUI_DROPACCEPTED) $prin = GUICtrlCreateButton("Print", 105, 94) GUICtrlCreateLabel("Drag File Here", 1, 77, 75, 15) $ptnm = GUICtrlCreateLabel("Printer Name", 58, 32, 65, 15) GUISetState(@SW_SHOW) main() Func main() TCPStartup() While 1 $msg = GUIGetMsg() $lbl = GUICtrlRead($ipen) $ptr = _TCPIpToName($lbl, 1) If IsArray($ptr) Then MsgBox(0, "", $lbl & " " & $ptr[1]) GUICtrlSetData($ptnm, $ptr[1], "Printer Name") EndIf If $msg = $ipin Then Do $i += 1 $chk = IniRead(@WorkingDir & "\printip.ini", "ips", $i, "") Until $chk = "" $nwip = GUICtrlRead($ipme) IniWrite(@WorkingDir & "\printip.ini", "ips", $i, $nwip) GUICtrlSetData($ipen, "") For $x = 1 To UBound($ip) - 1 GUICtrlSetData($ipen, $ip[$x][1] & "|") Next ElseIf $msg = $prin Then print() ElseIf $msg = $GUI_EVENT_CLOSE Then GUIDelete() Exit (1) EndIf WEnd EndFunc ;==>main Func print() $ipad = GUICtrlRead($ipen) $flad = GUICtrlRead($ftpr) If $ipad = "" Then MsgBox(0, "Error", "No IP Selected", 10) main() EndIf If $flad = "" Then MsgBox(0, "Error", "No File Selected", 10) main() EndIf RunWait(@ComSpec & ' /c lpr -S "' & $ipad & '" -P raw -o l -d "' & $flad & '"') main() EndFunc ;==>print 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Fulano Posted March 15, 2010 Share Posted March 15, 2010 An interesting tidbit, courtesy of pptfaq.com, of all places:Sometimes the simplest, fastest way is to use good ol' DOS:Open a command prompt window (choose Start, Run; type CMD then click OK)In the command prompt window, type NET VIEWThat gives you a list of computers on your network. Note the name of the one that your printer's connected to.Next, type NET VIEW \\server-name (substitute the name of the computer you chose above for "server-name")That gives you a list of the resources shared by that computer; your printer's name should be on the listI don't have a network printer to test it on, but you might be able to feed it the ip address and have it resolve the name. #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 15, 2010 Author Share Posted March 15, 2010 An interesting tidbit, courtesy of pptfaq.com, of all places:I don't have a network printer to test it on, but you might be able to feed it the ip address and have it resolve the name. Thanks, I will look into that. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 15, 2010 Author Share Posted March 15, 2010 (edited) I can locate the printer with net view, but there is nothing for autoit to compare the ip address it has with the list of printers given from net view I have also tried ping -a and nbtstat Edited March 15, 2010 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Developers Jos Posted March 15, 2010 Developers Share Posted March 15, 2010 You will have to add the IP addresses to your DNS server when you want to be able to retrieve a hostname that belongs to an IP address. The Netview command will show the available SHARES for the specified server but this will only work when al printers have a share. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 15, 2010 Author Share Posted March 15, 2010 I may have to skip this feature then because changes to the network is off limits to me 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Fulano Posted March 15, 2010 Share Posted March 15, 2010 Bummer #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! Link to comment Share on other sites More sharing options...
ptrex Posted March 15, 2010 Share Posted March 15, 2010 @Al You can alway fall back on the SNMP Protocol http://www.autoitscript.com/forum/index.php?showtopic=70759&st=0&p=518204&#entry518204 rgds 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...
ptrex Posted March 15, 2010 Share Posted March 15, 2010 @Al You can alway fall back on the SNMP Protocol http://www.autoitscript.com/forum/index.php?showtopic=70759&st=0&p=518204&#entry518204 rgds 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