Jump to content

noob needs help to repeat script


empach
 Share

Recommended Posts

hi everyone!!

firstly, before anyone tells me to search the help section, please let me explain my situation. i am completely new to programming and have only downloaded autoit yesterday, i have been trying out the tuturials and they have got me hooked!! i do not understand all the terminology in the program and have looked through the forum for the answer but i dont understand some of the topics so i thought i just blurt it out in the form of a question to you guys!

working on the tutorial to open up notepad, is there a way of asking the user to input a number of instances that would open notepad?? say if the user wanted 3 instances of notepad, there would be a popup asking this and the number inputted would then launch 3 notepad instances.

this to me in english terms sounds so simple yet i cannot find a script that does this and there must be a way of doing it. i get the msgbox script but not sure how to adapt it to input nembers.

any help on this would be fantastic, even though its not for anything important!

thanks in advance

Link to comment
Share on other sites

If you look at loops, for instance for...next, you would put the code you want to loop, where the msgbox "countdown" is, and the script after that where "blast off" is.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Moderators

empach,

First, welcome to the AutoIt forums. :) Now guess what I am going to say!

Read the Help file! ;)

Seriously, if you are that new to programming/coding (and that is not a problem -everyone has to start somewhere!) you do need to understand how some of the basic functions work or both you and we are going to get frustrated very quickly. You need to work through the tutorials you have started - the answers to many of the questions you will want to ask are covered there. There are even video tutorials on YouTube if you prefer watching to reading.

The best way to learn is to study the simple examples in the Help file until you are sure you understand what is going on and, more importantly, why. Change something in the examples to see if what happens is what you expect (not always the case).

Anyway, as to your specific question - take a look at this:

; Ask how many Notepads to open
$sCount = InputBox("Multiple Notepads", "How many Notepads do you want to open (1-3)", "", "", 200, 150)

; The result is in string form, so convert to a number
$iCount = Number($sCount)

; Check it is in range 1-3
If $iCount >= 1 And $iCount <= 3 Then

    ; Open the correct number of notepads
    For $i = 1 To $iCount
        Run("notepad.exe")
        WinWaitActive("Untitled - Notepad")
    Next
EndIf

Read the Help file pages for the various commands carefully and I am sure you will soon see what is going on.

Have fun!

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:

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

 

Link to comment
Share on other sites

If you look at loops, for instance for...next, you would put the code you want to loop, where the msgbox "countdown" is, and the script after that where "blast off" is.

thanks,

i did look at this but this example makes you click before the next countdown number appears, and being completely new i didnt - and still dont understand the loop function fully. i wanted to automatically launch a usder suggested number of instances ans wasnt sure how i could change the loop script to my favour. thanks for your help anyway!!

Link to comment
Share on other sites

empach,

First, welcome to the AutoIt forums. :) Now guess what I am going to say!

Read the Help file! B)

Seriously, if you are that new to programming/coding (and that is not a problem -everyone has to start somewhere!) you do need to understand how some of the basic functions work or both you and we are going to get frustrated very quickly. You need to work through the tutorials you have started - the answers to many of the questions you will want to ask are covered there. There are even video tutorials on YouTube if you prefer watching to reading.

The best way to learn is to study the simple examples in the Help file until you are sure you understand what is going on and, more importantly, why. Change something in the examples to see if what happens is what you expect (not always the case).

Anyway, as to your specific question - take a look at this:

; Ask how many Notepads to open
$sCount = InputBox("Multiple Notepads", "How many Notepads do you want to open (1-3)", "", "", 200, 150)

; The result is in string form, so convert to a number
$iCount = Number($sCount)

; Check it is in range 1-3
If $iCount >= 1 And $iCount <= 3 Then

    ; Open the correct number of notepads
    For $i = 1 To $iCount
        Run("notepad.exe")
        WinWaitActive("Untitled - Notepad")
    Next
EndIf

Read the Help file pages for the various commands carefully and I am sure you will soon see what is going on.

Have fun!

M23

WOW!!!!!! THIS IS PERFECT!!!!!!

i had searched the "does not understand functions" like cycle, repeat, goto line, again etc, but couldnt get anywhere!!

i take on board about the self searching for help, and i know i would upset lots of people if i just asked a question to any problem i had or did not understand, and in any case i do see that as cheating cos i would be asking you guys to write my script for me!!

but thanks again for your assistance, it has shown me the light of my problem (however small it may seem!!)

THANKYOU!! ;)

Link to comment
Share on other sites

  • Moderators

empach,

Glad I could be of help.

A small suggestion - if you use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button at the bottom of the post, you do not include the text of the previous post in your reply. I am sure you can see how this makes reading the thread much easier - and saves on server space. :)

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:

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

 

Link to comment
Share on other sites

no probs M23, thanks again!!

just to let youknow how much ive played with your script - yes! i am impressed!! - i now have it opening a selected number then sleeping then closing the same amount of instances opened, then exitting with a task complete message box!! wahey!! it may sound stupid and so trivial to some people but this is only the start of my programming!! and its very addictive!! :)

Link to comment
Share on other sites

  • Moderators

empach,

I have been coding as a hobby for over 40 years - it stays addictive! :)

Welcome to our world.

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:

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

 

Link to comment
Share on other sites

I have been coding as a hobby for over 40 years - it stays addictive! :)

Welcome to our world.

As we have already turned the General help and support into an extra chat section a few times...

How many of those 40 is AutoIt?? I only see you as being on the forums since Aug 08, so just entering your second year.

As to addiction - I'm supposed to be studying at the moment, but it's really hard with a computer in front of you all the time. But I will continue to argue how educational it is.

Mat

Link to comment
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
 Share

  • Recently Browsing   0 members

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