AutoItNoob Posted November 10, 2005 Share Posted November 10, 2005 Good day to all. I am new to AutoIt and had a question for anyone that has time. I am working on a project to write a script that sends my boss an email everytime a numerical event occurs on our server. Basically our suedo-code for this situation would look like this:Do While bln.test = true If control.Text > 0 then - (if the text of the specific control we are looking at is more than zero) Func_email_Admin - (I want to fire off an email that tells us this event has taken place.) Sleep(5 min) - (once this has happened, resend an email every 5 minutes till resolved.) End If Sleep(10 sec) - (then do this loop every ten secounds to check the value of the text.)LoopWe were playing around with how to do this and my boss asked me to research AutoIt. I like it so far and have boned up on the tutorials and help descriptions, however I haven't really found exactly what I think I'm looking for to be able to do what I need. I played around with the Active Window Info. and figured out that the data that is specific to what I need is: Window Details: Title = Connect - Sch InControl Under Mouse: Control Id = 1029 ClassNameNN = Static9 Text = 0 (this is the key to shooting off my email)Basically I was hoping to figure out if this would even be my best solution, to use AutoIt to write a script for my event. And where I could find more detailed help on what functions do what or more tutorials to help me meander around writing a script to take care of this.Thanks for your time and any direction anyone can assist me with. Link to comment Share on other sites More sharing options...
SpookMeister Posted November 10, 2005 Share Posted November 10, 2005 Have you tried ControlGetText()? If you can get that function to return the information you need then the rest is fairly easy. [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
AutoItNoob Posted November 15, 2005 Author Share Posted November 15, 2005 Have you tried ControlGetText()? If you can get that function to return the information you need then the rest is fairly easy.So I tried that, but I don't think I hae to correct context of how to use it and where to place functions and commands and how to format it correctly so that it will compile and run w/o errors (I got quite a few of those...). Here is what I've kind of thrown together to try and attempt a step in the somewhat right direction:While 1 bln.test = true If (ControlGetText > 0) Then While 2 (ControlId = 1029 and ClassNameNN = Static9) Func Send("email" [, admin] ) Sleep( 300 ) EndFunc WEnd EndIf Sleep( 10 )LoopWEnd Link to comment Share on other sites More sharing options...
SpookMeister Posted November 15, 2005 Share Posted November 15, 2005 (edited) I would start off with verifying that you are getting the results that you expect from ControlGetText() With the app that you are trying to get the info from running try: ;replace App_Title in the following line with the title of the application (use AU3Info) $var = ControlGetText("App_Title","",1029) MsgBox(0,"Info","The control shows: " & $var) Once you know what you are getting then you can move on to testing for different results and making it do what you want. Edited November 15, 2005 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
herewasplato Posted November 15, 2005 Share Posted November 15, 2005 Untested:AutoItSetOption("WinTitleMatchMode", 3) AutoItSetOption("TrayIconDebug", 1) $S_Win_Title = "Connect - Sch In" $S_Win_Text = "0" While 1 If WinExists($S_Win_Title, $S_Win_Text) Then Func SendIt() Sleep(1000) WEnd Func SendIt() $S_bmail = "bmail.exe";full path to bmail.exe $S_SMTP_Server_switch = " -s some_server.domain.com" $S_TO_address = " -t some_alias@domain.com" $S_FROM_address = " -f AutoIt-Bmail" $S_Text_Subject = ' -a "some subject line text"' $S_Text_Body = ' -b "some body text"' Run($S_bmail & $S_SMTP_Server_switch & $S_TO_address & $S_FROM_address & $S_Text_Subject & $S_Text_Body) ;sleep until the window goes away While WinExists($S_Win_Title, $S_Win_Text) Sleep(1000) WEnd EndFunc ;==>SendItEdit the variables within the function as needed.You can hide the "DOS" window that pops up if you wish, see the help file for "Run".Download BMAIL here: http://www.beyondlogic.org/solutions/cmdli...cmdlinemail.htmor search the forum for other ways to send e-mails.... [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
AutoItNoob Posted November 16, 2005 Author Share Posted November 16, 2005 Untested:AutoItSetOption("WinTitleMatchMode", 3) AutoItSetOption("TrayIconDebug", 1) $S_Win_Title = "Connect - Sch In" $S_Win_Text = "0" While 1 If WinExists($S_Win_Title, $S_Win_Text) Then Func SendIt() Sleep(1000) WEnd Func SendIt() $S_bmail = "bmail.exe";full path to bmail.exe $S_SMTP_Server_switch = " -s some_server.domain.com" $S_TO_address = " -t some_alias@domain.com" $S_FROM_address = " -f AutoIt-Bmail" $S_Text_Subject = ' -a "some subject line text"' $S_Text_Body = ' -b "some body text"' Run($S_bmail & $S_SMTP_Server_switch & $S_TO_address & $S_FROM_address & $S_Text_Subject & $S_Text_Body) ;sleep until the window goes away While WinExists($S_Win_Title, $S_Win_Text) Sleep(1000) WEnd EndFunc ;==>SendItEdit the variables within the function as needed.You can hide the "DOS" window that pops up if you wish, see the help file for "Run".Download BMAIL here: http://www.beyondlogic.org/solutions/cmdli...cmdlinemail.htmor search the forum for other ways to send e-mails....Thanks guys, that made more sense. And after walking away and lookig at it for awhile, later I saw my errors and my boss and myself wiggled our way through it to get it to work. Appreciate your time - have a good one! 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