Vadersapien Posted January 18, 2010 Posted January 18, 2010 (edited) Hi again, I'm trying to read an ini file from the internet, preferably without downloading the file to a temporary location. I've had a play around with InetRead with no success. Does anyone have any ideas? Edited January 26, 2010 by Vadersapien Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Vadersapien Posted January 18, 2010 Author Posted January 18, 2010 (edited) _INetGetSource() and InetRead will both successfully get the contents of the ini file into a string, but then how do I parse the contents? IniRead doesn't seem to accept the contents of an ini file, only a path to the ini... Edited January 18, 2010 by Vadersapien Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Vadersapien Posted January 18, 2010 Author Posted January 18, 2010 It really would be easier to just download the ini to the temp directory.I'm going to have to agree on that one...I think it would be much easier than manually parsing the ini... Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
ResNullius Posted January 18, 2010 Posted January 18, 2010 I'm going to have to agree on that one...I think it would be much easier than manually parsing the ini...Or: http://www.autoitscript.com/forum/index.php?act=findpost&pid=530284
Vadersapien Posted January 18, 2010 Author Posted January 18, 2010 (edited) Or: http://www.autoitscript.com/forum/index.php?act=findpost&pid=530284 Thanks! Nice UDF too. It's exactly what I was looking for...I did quite a thorough search of the forums, yet it didn't show up...maybe I was just the wrong keywords Functionality like this should be included in AutoIt!EDIT: One problem: The script locks up while downloading the file, or if there is no internet access. Any idea how to avoid that? Edited January 18, 2010 by Vadersapien Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Vadersapien Posted January 19, 2010 Author Posted January 19, 2010 (edited) Hmm...another problem...I can only parse files off the hard disk(via fileread) with _IniString_Read(). Ones from the internet(via _InetGetSource() or InetRead) won't work for some reason... Edited January 19, 2010 by Vadersapien Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
ResNullius Posted January 22, 2010 Posted January 22, 2010 One problem: The script locks up while downloading the file, or if there is no internet access. Any idea how to avoid that?As for the script locking up while downloading, I have no idea what your script looks like.If there is no internet access, well that's really up to you to put proper checks into your scriptHmm...another problem...I can only parse files off the hard disk(via fileread) with _IniString_Read(). Ones from the internet(via _InetGetSource() or InetRead) won't work for some reason...The IniString_Examples.au3 included with the UDF (still) works for me using _InetGetSource() to read the update.dat file from www.autoitscript.com So I have to guess it's a problem with your particular script. Do you check the contents of the variable you store the ini in once you _InetGetSource() it?A little code might help us troubleshoot...
Vadersapien Posted January 24, 2010 Author Posted January 24, 2010 Well, here is my entire code: expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <IniString.au3> #include <WindowsConstants.au3> Local $var = IniStringReadSectionNames(BinaryToString(InetRead('http://10.0.0.5/rsmware/rsmware.ini'))) Local $listview, $hImage $inet = BinaryToString(InetRead('http://10.0.0.5/rsmware/rsmware.ini')) MsgBox(-1, '', FileRead(FileOpen("rsmware.ini", 0))) MsgBox(-1, '', $inet) GUICreate('Test GUI', 800, 600) MsgBox(-1, '', IniStringRead($inet, 'Alarm Clock', 'Author', 'Error')) $appname = GUICtrlCreateLabel('', 250, 10, 450, 20) $appauthor = GUICtrlCreateLabel('', 250, 30, 450, 20) $appver = GUICtrlCreateLabel('', 250, 50, 450, 20) $appinfo = GUICtrlCreateLabel('', 250, 70, 450, 500) $listview = GUICtrlCreateListView('', 0, 0, 200, 600, BitOr($LVS_SORTASCENDING, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER)) GUISetState() GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY') _GUICtrlListView_AddColumn($listview, 'Column 1', 196) _GUICtrlListView_BeginUpdate($listview) For $i = 1 To $var[0] _GUICtrlListView_AddItem($listview, $var[$i], $i-1) Next _GUICtrlListView_EndUpdate($listview) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndListView $hWndListView = $listview If Not IsHWnd($listview) Then $hWndListView = GUICtrlGetHandle($listview) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) Switch HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Case $hWndListView Switch DllStructGetData($tNMHDR, "Code") Case $NM_CLICK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $SelectedIndices = _GUICtrlListView_GetSelectedIndices($listview, True) If UBound($SelectedIndices) = 2 Then $SelectedApp = _GUICtrlListView_GetItemText($listview, $SelectedIndices[1]) GUICtrlSetData($appname, $SelectedApp) MsgBox(-1, '', IniStringRead($inet, 'Alarm Clock', 'Author', 'Error')) GUICtrlSetData($appver, 'Version ' & IniStringRead($inet, $SelectedApp, 'Version', '')) GUICtrlSetData($appinfo, IniStringRead($inet, $SelectedApp, 'Description', '')) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Don't bother testing the code, it won't work since I'm using local IP addresses. Figured out how to address detecting if there's no internet or the server is down, all I had to do was ping the server and check the result. Still don't know why it locks up while downloading though. Also found out that using _InetGetSource() with the AutoIt update.dat works fine too... Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
ResNullius Posted January 24, 2010 Posted January 24, 2010 So, sounds like the lockup during download is one of those bugs you're going to have real fun chasing down One note on your code as it stands, Why do you do Local $var = IniStringReadSectionNames(BinaryToString(InetRead('http://10.0.0.5/rsmware/rsmware.ini'))) And then read the file again with $inet = BinaryToString(InetRead('http://10.0.0.5/rsmware/rsmware.ini')) Why not just: $inet = BinaryToString(InetRead('http://10.0.0.5/rsmware/rsmware.ini')) $var = IniStringReadSectionNames($inet) ???
Vadersapien Posted January 24, 2010 Author Posted January 24, 2010 One note on your code as it stands, Why do you do Local $var = IniStringReadSectionNames(BinaryToString(InetRead('http://10.0.0.5/rsmware/rsmware.ini'))) And then read the file again with $inet = BinaryToString(InetRead('http://10.0.0.5/rsmware/rsmware.ini')) Why not just: $inet = BinaryToString(InetRead('http://10.0.0.5/rsmware/rsmware.ini')) $var = IniStringReadSectionNames($inet) ??? Oh that's because I've been adding code all over the place since it's a test environment I was gonna clean all that up once I merged it into my actual program. If you saw how I MsgBoxed the contents of the local and downloaded ini, both return the exact same contents...maybe I'm just gonna have to download it first... Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Vadersapien Posted January 26, 2010 Author Posted January 26, 2010 I solved my problem(finally) The ini file had to be uploaded in binary mode for it to parse correctly...though I find it weird how the section names still read when uploaded in text mode Is there a way I can mark the thread resolved at all? Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
AdmiralAlkex Posted January 26, 2010 Posted January 26, 2010 Is there a way I can mark the thread resolved at all? By pressing "Edit" on your first post you can edit the threads title, maybe to "[solved] Read .ini file from internet" or something like that... .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
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