Jump to content

Recommended Posts

Posted

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

Posted

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:

  Reveal hidden contents

 

  • Moderators
Posted

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. :)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

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.

Posted (edited)

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:

  Reveal hidden contents

 

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...