Jump to content
Sign in to follow this  
senormiggy

Simple autoit script but doesn't work.

Recommended Posts

senormiggy

Hello,

I am totally new to Autoit.

I want to know how to preform a simple script:

$value = InputBox("Test", "Input", 0)

sleep(500)

Run(@WindowsDir & "\Notepad.exe", "", @SW_MAXIMIZE)

WinActivate("Untitled - Notepad")

SEND("{$VALUE}")

Except it doesn't send what i typed in the input box.

How can i change this?

Thanks in advance,

Mick

Share this post


Link to post
Share on other sites
water

This works for me:

$value = InputBox("Test", "Input", 0)
Sleep(500)
Run(@WindowsDir & "\Notepad.exe", "", @SW_MAXIMIZE)
WinActivate("Untitled - Notepad")
WinWaitActive("Untitled - Notepad")
Send($value)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Melba23

senormiggy,

Welcome to the AutoIt forum. :graduated:

You need to wait until NotePad is open - like this:

$value = InputBox("Test", "Input")
sleep(500)
Run(@WindowsDir & "\Notepad.exe", "", @SW_MAXIMIZE)
WinWaitActive("Untitled - Notepad") ; Wait for NotePad to open
SEND($value) ; You only need the "{ }" for literal text

All clear? Please ask if not. ;)

M23

P.S. When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code. :)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
senormiggy

Thanks that works !!

Could you help me with the following:

$test = MsgBox(2,"OK", "OK", 0)

if $test = 1 then

Send("OK")

Endif $test = 2 then

Send("CANCEL")

Thanks , this also doesn't work.

Share this post


Link to post
Share on other sites
senormiggy

$test = MsgBox(2,"OK", "OK", 0)

WinActivate("Untitled - Notepad")

if $test = 1 then

Send("OK")

Endif $test = 2 then

Send("CANCEL")

This should be it sorry.

Share this post


Link to post
Share on other sites
water

You use flag = 2 in your MsgBox. This displays buttons Abort, Retry, and Ignore. Abort, Retry, and Ignore set $test to values 3, 4 and 5.

Please check the help file.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Melba23

senormiggy,

Go and look in the Help file at what MsgBox returns as values. :)

In this case the 3 buttons return 3,4 or 5, so your code would need to look like this:

$test = MsgBox(2, "OK", "OK", 0)
If $test = 3 Then
    Send("Abort")
ElseIf $test = 4 Then
    Send("Retry")
ElseIf $test = 5 Then
    Send("Ignore")
EndIf

But you need to learn some more about AutoIt. Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading. :graduated:

I know you want to start coding NOW, but a little study will save you a lot of trouble later on, believe me. ;)

Good luck. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
senormiggy

Still a error

Endif $test = 0 then

Endif ^ ERROR

Error: Illegal text at the end of statement ( one statement per line )

Share this post


Link to post
Share on other sites
senormiggy

Ah, added the EndIf now it works, thanks everybody !!

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  

×