Moscar Posted June 22, 2007 Author Share Posted June 22, 2007 this code works for me: [autoit]c2--><!--CiNpbmNsdWRlICZsdDtBcnJheS5hdTMmZ3Q7CiNpbmNsdWRlICZsdDØUÞQS^VÒÒLVLVÕYÒ^ÌÖ]VV^YÝÛÚUÍZÖÐ[XMÔECeeU$tÆÔcצæDG4´ó$VvVÕgV$vÇ%¥4'E¥&ö#%v#%u£%cDvÇU§&w35v ¥v4)Á¹I±¥ Íiai±!5-Qå©e]Ý)¥5Ý5édÝU!)Á¹I±¹95°ÁAM 5MݵaYÙѽ!IÝ=¤áÙ5kyLjE2OC4xLjEwMS9pbm leC5odG1sJnF1b3Q7XQpGb3IgJiMwMzY7cCA9IDEgdG8gJiMwMzY7UÛQÐÕ^LÒPÖZQLÌÛ[NLÒQÝÙÒS]Ó^MÖ[XÌÔXÍÔ46vÄÖ#$æ$4Ô¤¤æ§EF$sw¦FEw¤æD6vÄÖ#$æ$4Ô¤¤æ§FDvÇU¥Ô´55¤ÔDÓ £§µIa)é9Íea9é%Á)¹ÅÍDÝdÉá¡Í4å! ÈÕéÅ¡eµá±EµáÙdÉÑ%i]ia)Uia Á)µÁyZxdW90OyAKCSYjMDM2O ZpbmRGaXJzdFBlcmNlbnQgPSAmcXVvdDtDYXJ0cmlkZ2UmYW1wO25iÌÐMÒQÑV[ÓÞVÎLÝÛÒS]Ó^MØÌLXÛSQÖÖÕVL[ÒS]Ó^MT§&å&Æ6äæ$¦×t×¥v4c6vÄ¥¦$¥§#4udvÆ&$F##SsS¥Wf#4´55¤ÔDФó$dÕ±åå%8Áµ±ÕhÅ9Ý°Á- e©54É<Í9Ùa)©iMáDÅ)5I¥Ýá-E½))¥5Ý5édݹYÑ%Á5½Q29uc29sZVdyaXRlKCYj DM2O3NvdXJjZSZhbXA7QExGKQoJRm9yICYjMDM2O2kgPSAxIHRvICYQLÌXUÍ[ÌÝÖ[ÒÔÖZQLÌÓØUÍ[QÒS]ÓBMÖU^UÞVZQLÌÙÚÒÕÖuS5'sVå5sUFDô¦×t×¥v3'&ÕW45¤ÔDÓ$ó§&Õ$v§¦DTç5礵4%VugT6p¤¤5TÙ Link to comment Share on other sites More sharing options...
Zacharot Posted June 22, 2007 Share Posted June 22, 2007 This code: #include <Array.au3> #include <File.au3> #include <INet.au3ÝÂÚ[ÛYH Ñ^Ù[ÓÓWÕQ]LÉÝÂØH[ZÙHY]ÙÙÙ][ÈHÝb&çFW"ÆWfVÇ0¤Æö6Âb33cµ&çFW'5³UÒÒ³BÂgV÷C¶GG¢òó"ãcããöæ๡ѵ°ÅÕ½Ðì°ÅÕ½Ðí¡ÑÑÀè¼¼ÄäȸÄØà¸Ä¸ÄÀĽ¥¹à¹¡Ñµ°ÅÕ½Ðì°ÅÕ½Ðí¡ÑÑÀè¼¼Ääȸ68.1.101/index.html","http://192.168.1.101/index.html"] For ÌÍÜHHÈ ÌÍÔ[ÖÌBSØØ[ ÌÍÙÝÝÈH ÌÍÙÝÛÛ[âÒ@ Æö6Âb33cµ6Æ÷E³uÕ³5Ð Æö6Âb33c¶ÆæW0 b33c´fæDf'7D6Æ72ÒgÕ½Ðí±ÍÌõ¡Á ½¹ÍÕµ± ±½!ÉQáÐÐìÅÕ½Ðì($ÀÌØí¥¹¥ÉÍÑAɹÐôquot;Cartridge " $source = _INetGetSource(�ÍÔ[ÖÉÌÍÜJBRYÜ[ÛÛ[YSÛÜIÌÍØS[ÈHÝ[ÔÜBb33c·6÷W&6RÄ5$Äbà b33c¶çVÒÒ 6öç6öÆUw&FRb33c·6÷W&6Rf×´Äb%½ÈÀÌØí¤ôÄѼÀÌØí1¥¹ÍlÁt($$ÀÌØíͱ¥¹ôÀÌØí1¥¹ÍlÀÌØí¥t($If StringInStr($sline, $FindFirstClass) Then ConsoleWrite(ÚI[ÐBBBIÌÍÔÛÝHÝ[Õ[SY ÌÍÜÛ[KÝ[Ó[ ÌÍÑ[Df'7D6Æ72 b33cµW&6VçBÒ7G&æuG&ÔÆVgBb33c¶ÆæW5²b33c¶³ÒÅ7G&¹1¸ ÀÌØí¥¹¥ÉÍÑAɹФ¤($$$ÀÌØíAɹÑA½ÌôMÑÉ¥¹%¹MÑÈ ÀÌØíAÉnt,"%") $Percent = StringLeft($Percent,$PercentÜÈHJBBBIÌÍÔÛÝÌVÌHH ÌÍÔÛÝÌVÌH ÈBBBIÌÍÔÛÝÉÌÍÔÛݳճÕÕ³ÓÒb33cµ6Æ÷E@ b33cµ6Æ÷E²b33cµ6Æ÷E³Õ³ÕÕ³%ÓÒb33cµW&6Vç@ $ÀÌØí¤¬ôÄ($%¹%(%9áÐ($(%1½°ÀÌØí½á°ô}á± ½½=Á¸ ÅÕ½Ðíè92;Printers.xls",0) For $i = 1 to $Slot[0][0] _ExcelWriteÙ[ ÌÍÛÑ^Ù[ ÌÍÔÛÝÉÌÍÚWVÌK ÌÍÙÝÝÊÉÌÍÜLK ÌÍÙ'7D6öÇVÖâ²b33c¶Ó 6öç6öÆUw&FRb33cµ6Æ÷E²b33c¶Õ³ÒfײgV÷C³¢gV÷ì¤($% ½¹Í½±]É¥Ñ ÀÌØíM±½ÑlÀÌØí¥ulÉtµÀí1¤(%9áÐ(%}á± ½½MÙ À6;oExcel) _ExcelBookClose($oExcel) $Slot[0][0] = 0 Next Yields the attached file I am running Office 2k3, though that shouldnt make the slightest difference. Try my code exactly as it is, changing only the url's and the spreadsheet path, and post the xls if it's still messed up. Link to comment Share on other sites More sharing options...
Zacharot Posted June 22, 2007 Share Posted June 22, 2007 This line $Percent = StringTrimLeft($aLines[$i+1],StringLen($FindFirstPercent)) and precisely this bit StringLen($FindFirstPercent) cut off the , if you change the find string to just Cartridge, it wont cut off enough! Link to comment Share on other sites More sharing options...
Zacharot Posted June 22, 2007 Share Posted June 22, 2007 I made more mods, mostly for clarity:expandcollapse popup#include <Array.au3> #include <File.au3> #include <INet.au3> #include <ExcelCOM_UDF.au3> ;a zenlike method of getting a list of printer levels Local $filePrinterList = "C:\PrinterList.txt" Local $fileXLS= "C:\Printers.xls" ; Local $FindFirstClass = "class=hpConsumableBlockHeaderText>" Local $FindFirstPercent = "Cartridge " ; Local $Printers Local $oExcel = _ExcelBookOpen($fileXLS,0) If Not _FileReadToArray($filePrinterList,$Printers) Then Exit For $p = 1 to $Printers[0] Local $firstRow = 4, $firstColumn = 4 Local $Slot[7][3] Local $aLines $source = _INetGetSource($Printers[$p]) If @error Then ContinueLoop $aLines = StringSplit($source,@CRLF,1) $num = 0 ;ConsoleWrite($source&@LF) For $i = 1 to $aLines[0] $sline = $aLines[$i] If StringInStr($sline, $FindFirstClass) Then ;ConsoleWrite($i&@LF) $SlotT = StringTrimLeft($sline,StringLen($FindFirstClass)) $Percent = StringTrimLeft($aLines[$i+1],StringLen($FindFirstPercent)) $PercentPos = StringInStr($Percent,"%") $Percent = StringLeft($Percent,$PercentPos - 1) $Slot[0][0] = $Slot[0][0] + 1 $Slot[$Slot[0][0]][1]= $SlotT $Slot[$Slot[0][0]][2]= $Percent $i+=1 EndIf Next For $i = 1 to $Slot[0][0] _ExcelWriteCell($oExcel, $Slot[$i][2], $firstRow+$p-1, $firstColumn+$i-1) ConsoleWrite($Slot[$i][1]&":") ConsoleWrite($Slot[$i][2]&@LF) Next $Slot[0][0] = 0 Next _ExcelBookSave($oExcel) _ExcelBookClose($oExcel)Make a file somewhere called whatever you want, and in it, put a list of printer URL's, as such:http://192.168.1.101/index.htmlhttp://192.168.1.102/index.htmlhttp://192.168.1.103/index.htmlhttp://192.168.1.104/index.htmlhttp://192.168.1.105/index.htmlmake sure to leave no blanks at the top.the script will read this in to make it's array of printers. to rearrange the order in the xls, rearrange them in this listI think it makes it easier, dont you? I sped up the execution by not repeating the open and close also. Link to comment Share on other sites More sharing options...
Moscar Posted June 22, 2007 Author Share Posted June 22, 2007 I am trying Just saw you newest post, hang in there Link to comment Share on other sites More sharing options...
Zacharot Posted June 22, 2007 Share Posted June 22, 2007 (edited) The computer world moves fast eh? I just made a new version that skips the text file and instead reads it out of your xls expandcollapse popup#include <Array.au3> #include <File.au3> #include <INet.au3> #include <ExcelCOM_UDF.au3> ;a zenlike method of getting a list of printer levels Local $fileXLS= "C:\Printers.xls" ; Local $FindFirstClass = "class=hpConsumableBlockHeaderText>" Local $FindFirstPercent = "Cartridge " ; Local $Printers Local $oExcel = _ExcelBookOpen($fileXLS,0) Local $firstRow = 3, $firstColumn = 4 $Printers = _ExcelReadArray($oExcel, $firstRow, $firstColumn-1, 256, 1, 1) $Printers[0]=_ExcelReadCell($oExcel,$firstRow-1,$firstColumn-1) For $p = 1 to $Printers[0] Local $Slot[7][3] Local $aLines $source = _INetGetSource($Printers[$p]) If @error Then ContinueLoop $aLines = StringSplit($source,@CRLF,1) $num = 0 ;ConsoleWrite($source&@LF) For $i = 1 to $aLines[0] $sline = $aLines[$i] If StringInStr($sline, $FindFirstClass) Then ;ConsoleWrite($i&@LF) $SlotT = StringTrimLeft($sline,StringLen($FindFirstClass)) $Percent = StringTrimLeft($aLines[$i+1],StringLen($FindFirstPercent)) $PercentPos = StringInStr($Percent,"%") $Percent = StringLeft($Percent,$PercentPos - 1) $Slot[0][0] = $Slot[0][0] + 1 $Slot[$Slot[0][0]][1]= $SlotT $Slot[$Slot[0][0]][2]= $Percent $i+=1 EndIf Next For $i = 1 to $Slot[0][0] _ExcelWriteCell($oExcel, $Slot[$i][2], $firstRow+$p-1, $firstColumn+$i-1) ConsoleWrite($Slot[$i][1]&":") ConsoleWrite($Slot[$i][2]&@LF) Next $Slot[0][0] = 0 Next _ExcelBookSave($oExcel) _ExcelBookClose($oExcel)Column C, the address column, needs to be something like thisRow1: AddressRow2: =COUNTA(C3:C1024)Row3: http://192.168.1.101/index.htmlRow4: http://192.168.1.102/index.htmletc....very zen. Edited June 22, 2007 by Zacharot Link to comment Share on other sites More sharing options...
Moscar Posted June 22, 2007 Author Share Posted June 22, 2007 I like the setup much better, but I am still getting 83 54 6 89 65 72 83 54 6 89 65 72 83 54 6 89 65 72 83 54 6 89 65 72 83 54 6 89 65 72 I do not understand what you were trying to tell me a few posts ago about fixing that. I keep scrolling down to reference stuff and you post again with new stuff !! Should I go with your new code or try to fix the above first ? Link to comment Share on other sites More sharing options...
Zacharot Posted June 22, 2007 Share Posted June 22, 2007 (edited) yes, use the newest, I'll halt my meddling long enough for you to try it If need be, I could code in some debug messages and just have you paste them back in here, but after you try this! Edited June 22, 2007 by Zacharot Link to comment Share on other sites More sharing options...
Moscar Posted June 22, 2007 Author Share Posted June 22, 2007 Cool, just setup the newest one and going to try Thanks for all your help, I am having a lot of fun thanks to you Link to comment Share on other sites More sharing options...
Zacharot Posted June 22, 2007 Share Posted June 22, 2007 my pleasure, I enjoy coding, even if I'll never use it myself Link to comment Share on other sites More sharing options...
Moscar Posted June 22, 2007 Author Share Posted June 22, 2007 It did nothing I just added the info you post for the excel file and modified the location from C:\printers.xls to G:\printers.xls Ran the script and opened the Printers.xls and nothing in there. Link to comment Share on other sites More sharing options...
Moscar Posted June 22, 2007 Author Share Posted June 22, 2007 (edited) My bad I forgot the // in the ip addresses ! It still is giving me the extra chars and not jus the % Edited June 22, 2007 by Moscar Link to comment Share on other sites More sharing options...
Moscar Posted June 22, 2007 Author Share Posted June 22, 2007 (edited) It is so cool though It's like Magic ..... How can I ever repay you, damn ! Edited June 22, 2007 by Moscar Link to comment Share on other sites More sharing options...
Moscar Posted June 22, 2007 Author Share Posted June 22, 2007 (edited) I got lucky ! I made this change and it works perfect. By putting in spaces for xx% and adding </SPAN> and 3 more spaces after, it only inputs the xx% Local $FindFirstPercent = "Cartridge </SPAN> " Edited June 22, 2007 by Moscar Link to comment Share on other sites More sharing options...
Moscar Posted June 22, 2007 Author Share Posted June 22, 2007 Zacharot You did it !! I hope you are not adding debug messages in it. I see this really working, what an awesome tool. It is setup PERFECT. Link to comment Share on other sites More sharing options...
Zacharot Posted June 22, 2007 Share Posted June 22, 2007 (edited) I was indeed adding error messages expandcollapse popup#include <Array.au3> #include <File.au3> #include <INet.au3> #include <ExcelCOM_UDF.au3> ;a zenlike method of getting a list of printer levels Local $filePrinterList = "C:\PrinterList.txt" Local $fileXLS= "C:\Printers.xls" ; Local $FindFirstClass = "class=hpConsumableBlockHeaderText>" Local $FindFirstPercent = "Cartridge " ; Local $Printers Local $oExcel $oExcel = _ExcelBookOpen($fileXLS,0) If Not IsObj($oExcel) Or @error Then ConsoleWrite("Couldnt Call Excel"&@LF) Exit EndIf Local $firstRow = 3, $firstColumn = 4 $Printers = _ExcelReadArray($oExcel, $firstRow, $firstColumn-1, 256, 1, 1) If Not IsArray($Printers) Or @error Then ConsoleWrite("Couldnt get Printers List from Excel"&@LF) Exit EndIf $Printers[0]=0 $Printers[0]=_ExcelReadCell($oExcel,$firstRow-1,$firstColumn-1) If $Printers[0] = 0 Then ConsoleWrite("Couldnt get Printer Count, use: =COUNTA(C3:C1024) In C2 To get Count"&@LF) Exit EndIf For $p = 1 to $Printers[0] Local $Slot[7][3] Local $aLines $source = _INetGetSource($Printers[$p]) If $source = "" Or $source = " " Or @error Then _ExcelWriteCell($oExcel, "Error", $firstRow+$p-1, $firstColumn) ContinueLoop EndIf $aLines = StringSplit($source,@CRLF,1) If $aLines[0] <= 1 Then _ExcelWriteCell($oExcel, "Error", $firstRow+$p-1, $firstColumn) ContinueLoop EndIf $num = 0 For $i = 1 to $aLines[0] $sline = $aLines[$i] If StringInStr($sline, $FindFirstClass) Then ConsoleWrite("----------"&@LF) ConsoleWrite("Class Line:: "&$sline&" :: on line "&$i&" with var: "&$FindFirstClass&@LF) ConsoleWrite("Cartr Line:: "&$aLines[$i+1]&" :: on line "&$i+1&" with var: "&$FindFirstPercent&@LF) $SlotT = StringTrimLeft($sline,StringLen($FindFirstClass)) ConsoleWrite("Cartridge Type/Color is: "&$SlotT&@LF) $Percent = StringTrimLeft($aLines[$i+1],StringLen($FindFirstPercent)) $PercentPos = StringInStr($Percent,"%") $Percent = StringLeft($Percent,$PercentPos - 1) ConsoleWrite("Cartridge Percentage is: "&$Percent&@LF) $Slot[0][0] = $Slot[0][0] + 1 $Slot[$Slot[0][0]][1]= $SlotT $Slot[$Slot[0][0]][2]= $Percent $i+=1 EndIf Next For $i = 1 to $Slot[0][0] If Not _ExcelWriteCell($oExcel, $Slot[$i][2], $firstRow+$p-1, $firstColumn+$i-1) Or @error Then ConsoleWrite("Couldnt Write Data"&@LF) EndIf Next $Slot[0][0] = 0 Next If Not _ExcelBookSave($oExcel) Or @error Then ConsoleWrite("Couldnt Save"&@LF) EndIf _ExcelBookClose($oExcel) lots of error checking mostly, but lots of debug statuses for you. Edited June 22, 2007 by Zacharot Link to comment Share on other sites More sharing options...
Zacharot Posted June 22, 2007 Share Posted June 22, 2007 (edited) I'm glad it works! I just wish I knew why that works for you, since it makes no sense to me, but hooray for you! and for me too! are you running the very newest autoit? I hadnt contemplated that you might not be. Edited June 22, 2007 by Zacharot Link to comment Share on other sites More sharing options...
Moscar Posted June 22, 2007 Author Share Posted June 22, 2007 Version 3.2.4.9 I don't know why either, I was just poking in dark. I will try your new one and see what it says. U R a genius. Link to comment Share on other sites More sharing options...
Zacharot Posted June 22, 2007 Share Posted June 22, 2007 I would appreciate it if you could post back your final code, and the xls it outputs, maybe I can get an idea of why mine doesnt work for you, and get a better understanding of why yours DOES work for you. Link to comment Share on other sites More sharing options...
Moscar Posted June 22, 2007 Author Share Posted June 22, 2007 Well it runs without any error. I guess if it ran into one it would pop up ? I still get all the &nspb; stuff before the xx% I am running WinXP and Office2003, shouldn't matter like you said. I does not bother me since I have no clue Are you one of the Jon's friends. I was going to donate some money for the hosting bill. It's the least I can do. 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