Jump to content

FileOpen Issue


Recommended Posts

Hi to all, i have a "strange" problem with a script. I want to read the index.dat file located in the cookie windows path. This is the code:

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
$Index_Contenent = ""
$History = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Cookies")
Global $Index_Path = $History & "\index.dat"
$Form1 = GUICreate("Form1", 623, 442, 192, 124)
$ListView1 = GUICtrlCreateListView("Data", 0, 0, 618, 438)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 610)
_Index_View()
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd
Func _Index_View()
Local $hFile
$hFile = FileOpen($Index_Path, 0)
$read = FileRead($hFile)
$Index_Contenent = StringSplit($read , "Cookie:" & @UserName & "@", 1)
FileClose($hFile)
For $i = 2 To UBound($Index_Contenent) - 1
  GUICtrlCreateListViewItem($Index_Contenent[$i], $ListView1)
Next
EndFunc

This script WORK good with Autoit v3.2.2.0 but DOESN'T work on the latest Autoit v3.3.8.1. Whit this version the script just simply give me an empty listview. I think that there is a difference on how FileOpen function work between this two different version of Autoit.

Anyone know how i can fix that? Thanks in advantage :oops:

Link to comment
Share on other sites

As i have previusly written, this script work well with this older Autoit Version: v3.2.2.0.But it stop to work to work with the new autoit version v3.3.8. Now i'm very curios to know what is changed between this version, and how i can fix this script, to work with with version 3.3.8.

Hi and thanks

Link to comment
Share on other sites

As soon as the file read hits the first NUL in that file it stops. I'm not sure how they handled a NUL character 5 years ago in AutoIt, but it looks like it's working as intended.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

@kylomas

The path is right, as i have write... the same script, on the same machine but with an older autoit version work well. If i try to start it with a new autoit version it stop to work. I think that somethink is change between this two autoit version. The real question is...how to fix that, and get this working again? :oops:

Hi!

Link to comment
Share on other sites

$read = "Client UrlCache MMF Ver 5.2"

If I run your script on my VM, which is being used to access the forum so there are cookies, I will have an empty gui. No "cookie" in $read. How about you take a look at your $read? Or insult me again that idk what I'm doing.

Link to comment
Share on other sites

StungStang,

Yes, I understand. Perhaps followup on what BewManNH has pointed out, or, review the change log for the new version to see if anything affecting your code has changed.

If it were me I owuld first display the path, then the input being fed to the listview routine. Something like "start at the beginning, go to the end and then stop".

My suggestion about checking return codes is simply good programming practice.

Good Luck,

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

I ran the script on my Windows 7 machine, it does get the correct path (I tested that first before anything else), it does start to read the index.dat file into read, but as soon as it reads the NUL character after the string jb09 posted it stops. FileRead won't read a text file after the first NUL it finds, that I believe is by design. There are a LOT of NULs in that file and unless there's a file reading command out there that reads past a NUL I don't think it will work on that file.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Tried that too, opened the file in binary, did a fileread, and used binarytostring to convert it back, all I got was the first line again. In binary its just a LONG line of numbers.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I have tried this code:

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
$Index_Contenent = ""
$History = RegRead("HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerShell Folders", "Cookies")
Global $Index_Path = $History & "index.dat"
$Form1 = GUICreate("Form1", 623, 442, 192, 124)
$ListView1 = GUICtrlCreateListView("Data", 0, 0, 618, 438)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 610)
_Index_View()
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

Func _Index_View()
Local $hFile
$hFile = FileOpen($Index_Path, 0)
$read = FileRead($hFile)
$Index_Contenent = StringSplit($read , "Cookie:" & StringLower(@UserName) & "@", 1)
FileClose($hFile)
For $i = 2 To UBound($Index_Contenent) - 1
  GUICtrlCreateListViewItem($Index_Contenent[$i], $ListView1)
Next
EndFunc

I just simply lower the @username string and it seems to work. Can anyone prove? :oops:

Hi and thanks for support

Edited by StungStang
Link to comment
Share on other sites

@jb09

What is strange that with the same script, without changing nothing, with an old version of autoit it work perfecty, but if i run it with a new autoit version it stop to work. Anyway now seems to work with the new autoit version, just simply converting the @username string to lowercase.

Hi

Link to comment
Share on other sites

Well, @username returns same string in both versions. Yet, I believe stringsplit changed. http://www.autoitscript.com/autoit3/docs/history.htm says "Fixed: StringSplit() flag=1 delimiters not case sensitive." Yet http://www.autoitscript.com/autoit3/docs/functions/StringSplit.htm says " flag = 1, entire delimiter string is needed to mark the split". Considering you used flag = 1.

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