
vocoder
Members-
Posts
18 -
Joined
-
Last visited
vocoder's Achievements

Seeker (1/7)
0
Reputation
-
extracting part of a file name?
vocoder replied to vocoder's topic in AutoIt General Help and Support
thanks. now what if I don't know the name of the file, other than my and text....so i will never know the number 02272007, is there a wildcard function or something $file = "my_*_text.txt"; ? -
so lets say i have a file called myfile_02272007_text.txt is there anyway to get the 02272007 part? basically i want to a scan a directory for any file that begins with myfile_ and ends with _text.txt - and then get the number in the middle....if the number in the middle is greater than the previous one i have saved, process it. but i have no idea how to do this, or if it is even possible?
-
any ideas?
-
#Include <Constants.au3> #Include <_XMLDomWrapper.au3> #include <Array.au3> #include <GuiConstants.au3> #NoTrayIcon Opt("TrayMenuMode", 1) Local $sFile = $location ;-- Create GUI and components - GuiCreate("My Program", 430, 700,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), $WS_EX_TOPMOST) If FileExists($sFile) Then ;-- Message found, need to delete some GUI elements -- GUICtrlDelete($sent1) GUICtrlDelete($input_logo) Else ;-- Create barebones app when there is no message found -- $filemenu = GUICtrlCreateMenu ("&File") $filepref = GUICtrlCreateMenuitem ("Options",$filemenu) $fileexit = GUICtrlCreateMenuitem ("Exit",$filemenu) $sent1 = GUICtrlCreateLabel ($nomessage, 70, 140, 400, 200) GUICtrlSetColor(-1,0xff0000) GUICtrlSetFont (-1,$nofontsize, 400, 2, $nofont) GUICtrlSetColor(-1,$nomsgfontcolor) GUISetState (@SW_SHOW) EndIf GUISetState() ;-- Tray Menu Items -- $Show = TrayCreateItem("Show My Program") $spacer1 = TrayCreateItem("") $pref = TrayCreateItem("Options") $spacer2 = TrayCreateItem("") $Hide = TrayCreateItem("Hide My Program") $spacer2 = TrayCreateItem("") $about = TrayCreateItem("About") $spacer3 = TrayCreateItem("") $exit = TrayCreateItem("Exit") $spacer4 = TrayCreateItem("") TraySetState() ;-- While the Program is running, do the following -- $sec = @SEC While 1 If FileExists($sFile) Then Local $sFile = $location ;-- Create GUI and components - $ret = _XMLFileOpen($sFile) GUISetState(@SW_SHOW) ;-- do some stuff here (i removed this to trim down the code for the time being) ;-- removed reading from files, then displaying text on the GUI GUISetState (@SW_SHOW) ;-- after we are done reading the file, need to move it to a logfile ;FileDelete($sFile) EndIf ;-- begin system tray stuff -- $msg = TrayGetMsg() $xmsg = GUIGetMsg() If $xmsg = $filepref Then GuiDelete("My Program") GuiCreate("My Program Options", 430, 700,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), $WS_EX_TOPMOST) GUISetState (@SW_SHOW) EndIf Select Case $xmsg = $sent1 WinSetState("My Program", "", @SW_SHOW) Case $msg = $Show WinSetState("My Program", "", @SW_SHOW) Case $msg = $Hide WinSetState("My Program", "", @SW_HIDE) Case $msg = $about MsgBox(64, "about:", "My Program") Case $msg = $exit Or $xmsg = $fileexit Exit Case $xmsg = $GUI_EVENT_CLOSE GUISetState(@SW_HIDE) Case $xmsg = $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) Case $msg = $TRAY_EVENT_PRIMARYDOUBLE GUISetState(@SW_SHOW) EndSelect WEnd Exit I removed some of the GUI code as it was very very long and not really necessary...where i put the remove comment, just image lots of GUICreateLabel and GUICreateInputs
-
So I have a created a GUI that has some text on it...and I have created a menu that has menuitems Options and Exit. I am a bit stumped on how to do this When a user clicks on option, I want the text in the current screen to be replaced by Options that I read from a text file...the user can change them and then save. when they press save, it would save all the options, then go back to the original gui (which itself also reads from text file, but i need the original text on screen) does anyone have an example of a basic gui options screen that works like this? I tried looking through the examples, but nothing seems to work like this thanks
-
i modified the while statement to be While 1 If FileExists($sFile) Then GUISetState(@SW_SHOW) FileDelete($sFile) Else GUISetState(@SW_HIDE) EndIf $msg = TrayGetMsg() $xmsg = GUIGetMsg() Select Case $xmsg = $sent1 WinSetState("CONTROL", "", @SW_SHOW) Case $msg = $Show WinSetState("CONTROL", "", @SW_SHOW) Case $msg = $Hide WinSetState("CONTROL", "", @SW_HIDE) Case $msg = $about MsgBox(64, "about:", "Program version 1.0") Case $msg = $exit Exit Case $xmsg = $GUI_EVENT_CLOSE GUISetState(@SW_HIDE) Case $xmsg = $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) Case $msg = $TRAY_EVENT_PRIMARYDOUBLE GUISetState(@SW_SHOW) EndSelect WEnd now the problem seems to be, as soon as i delete the message, the window disappears. i still want the window to stay on the screen until the user exits by pressing the minimize button or close button.....after i have already deleted the file. help? thanks! edit: i think i fixed the problem. I just moved most of the gui creation to inside of the while statement, it appears to be working correctly now. thanks for the help!
-
thanks, but that doesn't seem to work at all. I modified it a bit to add $ret = _XMLFileOpen($sFile) because it needs to open the xml file. but then it just opens once, pops up the window, then exits with an error : Unable to open file, the maximum number of open files has been exceeded.: $search1 = FileFindFirstFile($location) basically this is how i want the app to function: xml file is created in a folder (which i read from ini file) every so often when the xml file is created, i want a window to pop up notifying the user and displaying the xml file contents (i have this working). i then delete the file. the app would never stop running - after it displays the user the contents of the file, the user can click the x (close) or minimize button on the notification window, but the app still sits int he system tray (like how the time works or sound tray icon, etc) while sitting in the tray, it continues to scan for this file, whenever it is found, it always pops up the notification window to the user, then deletes the file. the first script i posted works, but only once...it doesn't loop after the file is found to continue searching for the file again. the xml include just allows me to read the xml file and put the contents of the tags into a variable (so i can display them to the user) edit: i attached the xmldomwrapper to this msg
-
#Include <Constants.au3> #Include <_XMLDomWrapper.au3> #include <Array.au3> #include <GuiConstants.au3> #NoTrayIcon Opt("TrayMenuMode", 1) While 1 ;Waiting for the file Sleep(1000) ;wait this amount of time $location = IniRead("my.ini", "files", "location", "NotFound") $logo = IniRead("my.ini", "files", "logo", "NotFound") Local $sFile = $location If FileExists($sFile) Then $ret = _XMLFileOpen ($sFile) if $ret =0 then Exit GuiCreate("CONTROL", 430, 500,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) ; form GUI $header = _XMLGetValue ("/control/header") $sent = _XMLGetValue ("/control/sent") FileDelete($sFile) ; delete the file $header1 = GuiCtrlCreateLabel("Headline:", 10, 110, 150, 20) $sent1 = GuiCtrlCreateLabel("Sent:", 10, 140, 150, 20) GUISetState (@SW_HIDE) $Input_headline = GuiCtrlCreateInput("" & $headline[1], 120, 110, 280, 20) $Input_sent = GuiCtrlCreateInput("" & $sent[1], 120, 140, 280, 20) GUISetState (@SW_HIDE) TraySetState() $Show= TrayCreateItem("Show Program") $spacer1 = TrayCreateItem("") $Hide= TrayCreateItem("Hide Program") $spacer2 = TrayCreateItem("") $about = TrayCreateItem("About Program") $spacer3 = TrayCreateItem("") $exit = TrayCreateItem("Exit") $spacer4 = TrayCreateItem("") ; ; While 1 $msg = TrayGetMsg() $xmsg = GUIGetMsg() Select Case $xmsg = $sent1 WinSetState("CONTROL", "", @SW_HIDE) Case $msg = $Show WinSetState("CONTROL", "", @SW_SHOW) Case $msg = $Hide WinSetState("CONTROL", "", @SW_HIDE) Case $msg = $about MsgBox(64, "about:", "Program version 1.0") Case $msg = $exit ExitLoop TrayItemDelete($Show) TrayItemDelete($spacer1) TrayItemDelete($about) TrayItemDelete($spacer2) TrayItemDelete($Hide) TrayItemDelete($spacer3) TrayItemDelete($exit) TrayItemDelete($spacer4) GUIDelete() Exit Case $xmsg = $GUI_EVENT_CLOSE GUISetState(@SW_HIDE) Case $xmsg = $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) Case $msg = $TRAY_EVENT_PRIMARYDOUBLE GUISetState(@SW_SHOW) EndSelect WEnd EndIf WEnd Exit this code works if the file is found....but if it is not found, nothing displays. i think i found the problem with that - the endif needs to be moved up and some of the body of the GUI recreated if the file isn't found...correct? but the main problem i'm having is...lets say the file is found...i delete it - then i want the program to keep running and to keep checking for the file every x amount of time. if the file is found again, it would pop open the gui window. what am i doing wrong? logic?
-
thanks for the help, I have it mostly working now. Although now i'm having a different problem (go figure). i always want the app to sit in the system tray. if the file isn't found, thats fine, just have it sit in the system tray. but to keep checking the directory every x amount of time (that is why i have the sleep function in there). if it scans the directory and finds the file, it pops up. it works if the file is there. but if i take the file out, run the app, then copy the file to the directory, the window never pops up. the idea is once the file is found, i'll delete the file and the app will continue to run looking for a new file and repeat the process if it finds one.
-
raySetState() ; ; Do $guiMsg = GUIGetMsg() $trayMsg = TrayGetMsg() if Not WinActive("CONTROL") and $clicked = 1 Then ;sleep(1000);waits a second before setting to tray GUISetState(@SW_HIDE, $guiCONTROL) $clicked = 0 EndIf Select Case $trayMsg = $TRAY_EVENT_PRIMARYDOWN or $trayMsg = $TRAY_EVENT_PRIMARYDOUBLE If $clicked = 0 Then sleep(100) GUISetState(@SW_SHOW, $guiCONTROL) $clicked = 1 Else GUISetState(@SW_HIDE, $guiCONTROL) $clicked = 0 EndIf Case $guiMsg = $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE, $guiCONTROL) $clicked = 0 EndSelect ; until $guiMsg = $GUI_EVENT_CLOSE EndIf WEnd oÝ÷ ÚȨv'âyÙ²r^¶Z½ëaƵêÓ¬zÔjרj^j»-¡Ú0«bÁ©í½êâßÙ§¢Û.èhÂÚuÙ²³+-¬¬zW¶*'¢b¢{-¢Øb±Êy«¢+Ø)]¡¥±Ä(($$$$$ÀÌØíµÍôQÉåÑ5Í ¤($$$$$ÀÌØíáµÍôU%Ñ5Í ¤($$$$%M±Ð($$$$$% ÍÀÌØíáµÍôÀÌØí͹ÐÄ($$$$$$%]¥¹MÑMÑÑ ÅÕ½Ðí =9QI=0ÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°M]}!%¤($$$$$% ÍÀÌØíµÍôÀÌØíM¡½Ü($$$$$$%]¥¹MÑMÑÑ ÅÕ½Ðí =9QI=0°ÅÕ½ÐìÅÕ½Ðì°M]}M!=¤($$$$$% ÍÀÌØíµÍôÀÌØí!¥($$$$$$%]¥¹MÑMÑÑ ÅÕ½Ðí =9QI=0ÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°M]}!%¤($$$$$% ÍÀÌØíµÍôÀÌØí½ÕÐ($$$$$$%5Í ½à ØÐ°ÅÕ½Ðí½ÕÐèÅÕ½Ðì°ÅÕ½Ðí5åAɽɴĸÀÅÕ½Ðì¤($$$$$% ÍÀÌØíµÍôÀÌØíá¥Ð($$$$$$$ì±ÑÑ¡ÑÉä¥ÑµÌ¹±½ÍÑ¡U$($$$$$$%QÉå%ѵ±Ñ ÀÌØíM¡½Ü¤($$$$$$%QÉå%ѵ±Ñ ÀÌØíÍÁÈĤ($$$$$$%QÉå%ѵ±Ñ ÀÌØí½ÕФ($$$$$$%QÉå%ѵ±Ñ ÀÌØíÍÁÈȤ($$$$$$%QÉå%ѵ±Ñ ÀÌØí!¥¤($$$$$$%QÉå%ѵ±Ñ ÀÌØíÍÁÈ̤($$$$$$%QÉå%ѵ±Ñ ÀÌØíá¥Ð¤($$$$$$%QÉå%ѵ±Ñ ÀÌØíÍÁÈФ($$$$$$%U%±Ñ ¤($$$$$$%á¥Ñ1½½À($$$$%¹M±Ð($$$%]¹( so the first part of the code works (app still runs in the system tray)..but now i have to add the 'winsetstate' stuff to the first part of the code..if i put it in my code, it reverts to how it used to work (wrongly). i also tried just adding the case statements to the case statements in the first code bit, but that didn't work at all either. what am i doing wrong?
-
that doesn't seem to do what I want - although it fixed one problem, thanks! I guess what I really want is when the user clicks the - (minimize) on the window it would send it back to the systray (where the time is) and not have the window listed on the taskbar anymore. if this isn't possible, then a button on the main gui that sends 'send back to systray' and it do this. possible? what should i be looking at? like how virus scanner systray icons work. you double click them, the control window comes up..but then you can close the control window, but the systray icon still stays and your virus scan software still runs. for my program, when i hit the x (even with the fix) nothing happens. it doesnt even exit the program.
-
I have most of my app up and running but have come to a roadblock. I am creating an application that I would like to sit in the system stray with other apps (virus scanner, steam, mail notification, soundicon, etc). when a file is created in a certain directory, it would pop up a window with the contents of the file in it. almost like Msgbox does but with the nice layout of the guicreate stuff. Here is my code so far #Include <Constants.au3> #Include <_XMLDomWrapper.au3> #include <Array.au3> #include <GuiConstants.au3> #NoTrayIcon Opt("TrayMenuMode", 1) While 1 ;Waiting for the file Sleep(1000) $location = IniRead("my.ini", "files", "location", "NotFound") Local $sFile = $location If FileExists($sFile) Then $ret = _XMLFileOpen ($sFile) if $ret =0 then Exit GuiCreate("CONTROL", 430, 500,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) ; $sent = _XMLGetValue ("/info/sent") $headline = _XMLGetValue ("/info/headline") $header1 = GuiCtrlCreateLabel("Headline:", 10, 110, 150, 20) $sent1 = GuiCtrlCreateLabel("Sent:", 10, 140, 150, 20) GUISetState (@SW_SHOW) $Input_headline = GuiCtrlCreateInput("" & $headline[1], 120, 110, 280, 20) $Input_sent = GuiCtrlCreateInput("" & $sent[1], 120, 140, 280, 20) GUISetState (@SW_SHOW) $Show= TrayCreateItem("Show MyProgram") TrayCreateItem("") $about = TrayCreateItem("About MyProgramr") TrayCreateItem("") $exit = TrayCreateItem("Exit") TrayCreateItem("") TraySetState() While 1 $msg = TrayGetMsg() $xmsg = GUIGetMsg() Select Case $xmsg = $sent1 WinSetState("CONTROL", "", @SW_HIDE) Case $msg = $Show WinSetState("CONTROL", "", @SW_SHOW) Case $msg = $about Msgbox(64,"about:","MyProgram 1.0") Case $msg = $exit ExitLoop EndSelect WEnd Exit EndIf WEnd Exit so, one problem is that when the window pops up, when you click the X on the window to close it, it doesn't do anything. I would like it so the windows closes but the app is still running in the system tray. Is this possible?? the other thing I am going to need to code is so once the file is found, it pops up the window...the user can close the window, but app is still running in system tray....then it starts over again looking for the file...if it is found it will pop up the window again. possible?
-
some noob questions - system tray + reading file
vocoder replied to vocoder's topic in AutoIt GUI Help and Support
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? -
some noob questions - system tray + reading file
vocoder replied to vocoder's topic in AutoIt GUI Help and Support
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.