Sign in to follow this  
Followers 0
vocoder

some noob questions - system tray + reading file

4 posts in this topic

hello,

I'm new to autoit, so sorry if these are some really noobish questions.

I have created the beginnings of an application that i want to function like this....i guess my first question is, is autoit even possible of doing this

runs in the system tray, checks a directory every 5 minutes. if a certain file is in that directory, it will maximize out of the system tray, play a sound and display the file to the user.

ideally, i would like to have some user options so the user could select where the file to watch is located

is this possible? if so, what functions should I be looking at? I already have the system tray working and can output the file once the user maximizes the system tray icon, but i'm sort of lost after that.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hmm, as for the system tray and looking for a file...

TrayCreateMenu

&

FileExists

And you'll need to also search for help in the help file for @Dir's (directory shtuff)

and for the maximizing I think all you'll need is a func and a create gui...

EDIT:

I havent tested this yet but it SHOULD WORK, but even so, I suggest you research the commandy things so you know how to use them...

This will rest in the tray till a file named "file.au3" is found in the Program Files directory.... ALSO to make it scan ONLY every five minutes, simply put Sleep(300000) somewhere in that WHILE loop...

$Tray= TrayCreateItem("Tray Item Here")
$Item = TrayCreateItem("Another Item",-1,-1,1)
While 1 ;Waiting for the file
Sleep(300000);Wait 5 minutes before scanning again
If FileExists(@ProgramFilesDir & "\file.au3") Then ;Looping a search for the file till it finds it!
#include <GuiConstants.au3>

GuiCreate("MyGUI", 392, 76,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) ; This is your gui forming

$Label_1 = GuiCtrlCreateLabel("This is your GUI", 10, 10, 370, 50)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        ;;;
    EndSelect
WEnd
Exit
EndIf
WEnd
Edited by P a R a D o X

If I hadn't said thank you yet, and you deserve it, than thank you...

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

okay thanks, i'm still having some problems....here is some of the code so far (sort of working , not really..i think i need some help with my logic

Include <Constants.au3>
#Include <_XMLDomWrapper.au3>
#include <Array.au3>
#NoTrayIcon
Opt("TrayMenuMode", 1)
$location = IniRead("my.ini", "files", "location", "NotFound")
Local $sFile = $location
    If FileExists($sFile) Then
            $ret = _XMLFileOpen ($sFile)
            if $ret =0 then Exit
            soundplay("sound.wav",1)
            $sender = _XMLGetValue ("/notice/sender")
Else
       $sender = "none";
EndIf
GUICreate("Caption", 430, 500)
GUICtrlCreateLabel("sender:" & $sender[1],10,30)

GUISetState (@SW_HIDE)

Show= TrayCreateItem("Show MyProgram")
TrayCreateItem("")
$about = TrayCreateItem("About MyProgram")
TrayCreateItem("")
$exit = TrayCreateItem("Exit")
TrayCreateItem("")

TraySetState()

While 1
    
    $msg = TrayGetMsg()
    $xmsg = GUIGetMsg()
    Select
        Case $xmsg = $sender
            WinSetState("Caption", "", @SW_HIDE)
        Case $msg = $Show
            WinSetState("Caption", "", @SW_SHOW)
        Case $msg = $about
            Msgbox(64,"About:","MyProgram version 1.0")
        Case $msg = $exit
            ExitLoop
    EndSelect
WEnd


Exit

now, i need to modify this so it will still show the GUI window if no file is found...it will just be blank or just display 'file not found' in the GUI when the system tray icon is maximized. Any hints on how I would go about doing that?

I also need to put some sort of timer on this (sleep(10000) ?) that checks for the file every 10 seconds, if its found then maximize the window and play the sound. I'm stuck though, any help would be greatly appreciated.

edit: oops didn't see the edit on your post...i'll the timer stuff out, thanks.

edit#2: okay checked out the timing stuff, seems to work thanks. but now i'm having another problem (man i feel like such a noob, sorry hehe) basically i need to tweak it a little bit i think. i need the program to continuously run -> if it finds the file it would display it like it does now, then delete the file (i can do that) but continue to run, so if the user minimizes it, it would start over looking for the file again...or even if the user doesn't minimize the program.

Edited by vocoder

Share this post


Link to post
Share on other sites

and one more question , this one about GUICreateLabel

I am getting text from an xml file...one of the fields text is very very long

for example:

lets say

$sender = "lorem epsom ipson dolor sic amet sec in consetum nunc ad valorem. Lorem ipson dolor sic amet sec in consetum nunc ad valorem. Lorem ipson dolor sic amet epsom sec in consetum nunc ad valorem. Lorem ipson dolor sic amet sec in consetum nunc ad valorem. Lorem ipson dolor sic amet sec in consetum nunc ad valorem. Lorem ipson dolor sic epsom amet sec in consetum nunc ad valorem. Lorem ipson dolor sic amet sec in consetum nunc ad valorem. Lorem ipson dolor sic amet sec in consetum nunc ad epsom valorem. Lorem ipson epsom dolor sic amet sec in consetum nunc ad valorem."

but I have GUICreate set to

GuiCreate("MyProgram", 430, 500

the problem is, when I use

GUICtrlCreateLabel("sender:" & $sender[1],10,330)

it doesn't display all the text, it just goes off the side of the application screen since it appears as all 1 line. Is there some way to make it wrap once it hits the application width?

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