Jump to content

Tray question..


rawrr
 Share

Recommended Posts

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

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
Link to comment
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
Link to comment
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!"

Link to comment
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!"

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