Sign in to follow this  
Followers 0
rawrr

Tray question..

11 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Mind posting your code?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Sure.. 1 sec.

#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 by rawrr

Share this post


Link to post
Share on other sites

You need to use the handle returned by FileOpen

ie.

#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

Share this post


Link to post
Share on other sites

sweeeeet. Thanks man. This stumped me all day. =]

Share this post


Link to post
Share on other sites

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!"

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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!"

Share this post


Link to post
Share on other sites

ty lol

Share this post


Link to post
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
Sign in to follow this  
Followers 0