rawrr Posted February 22, 2008 Share Posted February 22, 2008 I got a question.. I created a tray thing.. It lists stuff and when you click it it gives you text.. How can I make it so when I click it it actually writes the text in a file? Without you seeing of course. Then save and quit it.. Thanks in advance. =] Link to comment Share on other sites More sharing options...
FreeFry Posted February 22, 2008 Share Posted February 22, 2008 Have a look at the File functions in the helpfile, FileWrite is probably what you want, but if you want to write to it several times, you have to go with FileOpen first. Link to comment Share on other sites More sharing options...
rawrr Posted February 22, 2008 Author Share Posted February 22, 2008 I have.. And I had it all set up.. And when I click it it says Complete and stuff or w/e i wrote but it doesn't change the file.. O.o Link to comment Share on other sites More sharing options...
FreeFry Posted February 22, 2008 Share Posted February 22, 2008 Mind posting your code? Link to comment Share on other sites More sharing options...
rawrr Posted February 22, 2008 Author Share Posted February 22, 2008 (edited) Sure.. 1 sec. expandcollapse popup#Include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. $retail = TrayCreateItem("Retail WoW") traycreateitem("") $exit = traycreateitem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop case $msg = $retail FileOpen("C:\Program Files\World of Warcraft\realmlist.wtf", 1) ; Check if file opened for writing OK If $retail = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($retail, "set realmlist us.logon.worldofwarcraft.com" & @CRLF ) FileWrite($retail, "set patchlist us.version.worldofwarcraft.com") FileClose($retail) Case $msg = $Exit ExitLoop EndSelect WEnd Exit Edited February 22, 2008 by rawrr Link to comment Share on other sites More sharing options...
FreeFry Posted February 22, 2008 Share Posted February 22, 2008 You need to use the handle returned by FileOpen ie. expandcollapse popup#Include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. $retail = TrayCreateItem("Retail WoW") traycreateitem("") $exit = traycreateitem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop case $msg = $retail $fh = FileOpen("C:\Program Files\World of Warcraft\realmlist.wtf", 1) ; Check if file opened for writing OK If $fh = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($fh, "set realmlist us.logon.worldofwarcraft.com" & @CRLF ) FileWrite($fh, "set patchlist us.version.worldofwarcraft.com") FileClose($fh) Case $msg = $Exit ExitLoop EndSelect WEnd Exit Link to comment Share on other sites More sharing options...
rawrr Posted February 22, 2008 Author Share Posted February 22, 2008 sweeeeet. Thanks man. This stumped me all day. =] Link to comment Share on other sites More sharing options...
GEOSoft Posted February 22, 2008 Share Posted February 22, 2008 You have already declared $retail as a tray item so you don't want to re-declare it as the file handle. case $msg = $retail $file = FileOpen("C:\Program Files\World of Warcraft\realmlist.wtf", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file , "set realmlist us.logon.worldofwarcraft.com" & @CRLF ) FileWrite($file , "set patchlist us.version.worldofwarcraft.com") FileClose($file ) George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
rawrr Posted February 22, 2008 Author Share Posted February 22, 2008 And if i make the flag 10 it would erase whats in the doc and replace it right? $file = FileOpen("C:\Program Files\World of Warcraft\realmlist.wtf", 10) Link to comment Share on other sites More sharing options...
GEOSoft Posted February 22, 2008 Share Posted February 22, 2008 And if i make the flag 10 it would erase whats in the doc and replace it right? $file = FileOpen("C:\Program Files\World of Warcraft\realmlist.wtf", 10)$file = FileOpen("C:\Program Files\World of Warcraft\realmlist.wtf", 2) George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
rawrr Posted February 22, 2008 Author Share Posted February 22, 2008 ty lol 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