Sign in to follow this  
Followers 0
Limey Rat Bastard

Noob needs help

7 posts in this topic

OK, trying to get up to speed on creating scripts, but can't seem to find enough detail in the help to, well, help.

Used GUIBuilder to design a gui which has two input boxes for start date and end date. Then there are multiple buttons which I want to run a specific report in an application, passing the dates as the parameters.

Ideally I would ask for the dates and then open the app, send the keystrokes and dates, pause and then print. Leave the app open because then the next button will just send the keystrokes for that report.

Here is what I have so far:

GuiCreate("Monthly MailEssentials Reports", 392, 323,(@DesktopWidth-392)/2, (@DesktopHeight-323)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

$Input_1 = GuiCtrlCreateInput("MM/DD/YY", 20, 30, 140, 20)

$Label_2 = GuiCtrlCreateLabel("Enter start date", 20, 10, 110, 20)

$Input_3 = GuiCtrlCreateInput("mm/dd/yy", 220, 30, 140, 20)

$Label_4 = GuiCtrlCreateLabel("Enter end date", 220, 10, 110, 20)

$Button_5 = GuiCtrlCreateButton("Button5", 240, 110, 130, 30)

$Label_6 = GuiCtrlCreateLabel("User Communication", 20, 110, 200, 30)

$Button_7 = GuiCtrlCreateButton("Button7", 240, 160, 130, 30)

$Label_8 = GuiCtrlCreateLabel("Domain Usage - Inbound", 20, 160, 200, 30)

$Button_9 = GuiCtrlCreateButton("Button9", 240, 210, 130, 30)

$Label_10 = GuiCtrlCreateLabel("Domain Usage - Outbound", 20, 210, 200, 30)

$Button_11 = GuiCtrlCreateButton("Button11", 240, 260, 130, 30)

$Label_12 = GuiCtrlCreateLabel("Daily Spam", 20, 260, 200, 30)

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

GUICtrlSetOnEvent($Button_5, "Button5")

GuiSetState()

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case Else

;;;

EndSelect

WEnd

Exit

Func CLOSEClicked()

Exit

EndFunc

Func Button5()

Run ( "c:\windows\notepad.exe" )

Sleep ( 2000 )

WinActivate ( "Untitled - Notepad" )

$Input_1

EndFunc

My problem right now is getting the date I entered passed through in the function. I can't seem to get it even sent to Notepad. What am I doing wrong?

Martin

All advice gratefully accepted except "stop trying to write scripts"

Share this post


Link to post
Share on other sites



look up 'GUICtrlRead'... it'll get u the data from the input boxes n such


AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

look up 'GUICtrlRead'... it'll get u the data from the input boxes n such

I looked this up, read the help, but I still can't figure out how to get the text entered passed as a parameter.

I want my script to ask for the dates and then pass these into the application. I'll use Send to get the menu to the point where I enter the date but how do I get it to send the date?

Sorry for my ignorance. If there is a book or website you can recommend so I can learn I will be on it!

Martin

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You seem to be mixing the MessageLoop and OnEvent GUI modes together. You should only use one or the other, not both. If you want to see examples of the difference between these two modes, read the three topics under "GUI Reference" in the help file.

Secondly, the line "$Input_1" does nothing. You have a variable name, but you're not telling the script what to do with it. I'm guessing that you want to type the contents of the variable into Notepad, in which case you will want to use the "Send" function (look in Function Reference > Keyboard Control for how to do this). However, this still won't work because $Input_1 is the ID of the actual input box, not its contents. You should use the GUICtrlRead function with the ID of the input box to get the text that's inside it.

Edited by Sokko

Share this post


Link to post
Share on other sites

Ah, yes. I'm trying so many examples from the helpfile that i'm cross-eyed.

I figure that OnEvent is what I will use, but GUIBuilder put in the MessageLoop portion. I'll try and resolve that.

I did manage to get my input text through to Notepad. I had tried this before posting but had quotes around the GuiCtrlRead($Input_1) Once I removed them it worked. So now I have :

Send ( GUICtrlRead ( $Input_1 ))

On to the next part, the date format. Either I prompt for the date and enter it in the format it needs, mm/dd/yy or I use the GUICtrlCreateDate but this returns the full written date.

Obviously for my level of experience I am going to use an input box, unless you can teach me how to get from "Saturday, January 7 2006" to 01/07/06.

Martin

Share this post


Link to post
Share on other sites

I did manage to get my input text through to Notepad. I had tried this before posting but had quotes around the GuiCtrlRead($Input_1) Once I removed them it worked. So now I have :

Send ( GUICtrlRead ( $Input_1 ))
That should work well. As you discovered, when checking a function that returns a string (or a variable that contains a string), putting quotes around it will not work because anything inside quotes is taken literally.

On to the next part, the date format. Either I prompt for the date and enter it in the format it needs, mm/dd/yy or I use the GUICtrlCreateDate but this returns the full written date.

Obviously for my level of experience I am going to use an input box, unless you can teach me how to get from "Saturday, January 7 2006" to 01/07/06.

Actually, the Date control has a style called $DTS_SHORTDATEFORMAT that could help you out. It returns values that look like "1/7/2006" (no leading zeroes and a full four-digit year). If that doesn't work for you, there is also another solution which is slightly more complicated, but will return a date exactly as in your example:

$DTM_SETFORMAT = 0x1005
$style = "MM/dd/yy"
GuiCtrlSendMsg($date, $DTM_SETFORMAT, 0, $style)

You should replace "$date" with the variable that contains the ID of your own date control.

Share this post


Link to post
Share on other sites

there is also another solution which is slightly more complicated, but will return a date exactly as in your example:

$DTM_SETFORMAT = 0x1005
$style = "MM/dd/yy"
GuiCtrlSendMsg($date, $DTM_SETFORMAT, 0, $style)

You should replace "$date" with the variable that contains the ID of your own date control.

This worked perfectly, thanks so much. Half my battle is figuring out where to put the pieces of script that I think I need.

I'll post what I ended up with later.

Martin

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