Sign in to follow this  
Followers 0
urmommie

Please help im new to C++

15 posts in this topic

Well im new and I don't understand the tut's but I want to make something like this

MsgBox(1, "Do you want to open notepad?")
If answer yes
Then
Run("Notepad")
Send("Hello{SPACE}Bob!") ;I want the send to be typed in notepad

If someone can tell me what im doing wronge thanks :D!

Share this post


Link to post
Share on other sites



Well Hi and welcome to the forums.

This is the proper formatting for what you posted.

$answer = MsgBox(4, "Open Notepad", "Do you want to open notepad?")
If $answer = 6 Then ; The return value if you hit "yes" is 6
    Run("Notepad")
    WinWait ("Untitled - Notepad") ; Waiting for the Notepad window to exist
    WinWaitActive ("Untitled - Notepad") ; Waiting for it to be active, otherwise Send will fail.
    Send("Hello{SPACE}Bob!") ;I want the send to be typed in notepad
EndIf

I'd highly suggest you go look up all the functions you see used there and see how I did what I did.

Share this post


Link to post
Share on other sites

$answer = MsgBox(4, "Open Notepad", "Do you want to open notepad?")
If $answer = 6 Then ; The return value if you hit "yes" is 6
    Run("Notepad")
    WinWait ("Untitled - Notepad") ; Waiting for the Notepad window to exist
    WinWaitActive ("Untitled - Notepad") ; Waiting for it to be active, otherwise Send will fail.
    Send("Hello{SPACE}Bob!") ;I want the send to be typed in notepad
EndIf
Thanks man ok I have two questions for you what does the $answer = do?

and also how did you know the return value of yes? like if I wanted to also add

If $answer = 5 Then; 5 being no
            MsgBox(1, "Notepad will not open")

this will mean that if he presses no it will send him that but what is the return value and how do you find them out?

Share this post


Link to post
Share on other sites

Well im new and I don't understand the tut's but I want to make something like this

MsgBox(1, "Do you want to open notepad?")
If answer yes
Then
Run("Notepad")
Send("Hello{SPACE}Bob!");I want the send to be typed in notepad

If someone can tell me what im doing wronge thanks :D!

You need to select the notepad window before you continue.

Opt("WinTitleMatchMode",2)
Run("notepad")
WinActivate("Notepad","")
Send("Hello{SPACE}Bob!")

Blah, blah, blah... lip service... lip service.Working on a number of projects right now, just waiting for my time to post them here on AutoIt forums.

Share this post


Link to post
Share on other sites

Why are you asking about C++ here?

Share this post


Link to post
Share on other sites

Why are you asking about C++ here?

Where do I ask?

Share this post


Link to post
Share on other sites

Thanks man ok I have two questions for you what does the $answer = do?

and also how did you know the return value of yes? like if I wanted to also add

If $answer = 5 Then; 5 being no
            MsgBox(1, "Notepad will not open")

this will mean that if he presses no it will send him that but what is the return value and how do you find them out?

return values are in the help file

Share this post


Link to post
Share on other sites

return values are in the help file

I looked i can't find return values :D

Share this post


Link to post
Share on other sites

In your case MsgBox returns 1 if you press "OK" and 2 if you press "cancel"

Return Value

Success: Returns the ID of the button pressed.

Failure: Returns -1 if the message box timed out.

Button Pressed Return Value

OK 1

CANCEL 2

ABORT 3

RETRY 4

IGNORE 5

YES 6

NO 7

TRY AGAIN ** 10

CONTINUE ** 11

Share this post


Link to post
Share on other sites

open the help file then:

Autoit--->Function Reference--->Message Boxes and Dialogs---> MsgBox

Share this post


Link to post
Share on other sites

open the help file then:

Autoit--->Function Reference--->Message Boxes and Dialogs---> MsgBox

Thanks man you own :D!

Share this post


Link to post
Share on other sites

In your case MsgBox returns 1 if you press "OK" and 2 if you press "cancel"

Return Value

Success: Returns the ID of the button pressed.

Failure: Returns -1 if the message box timed out.

Button Pressed Return Value

OK 1

CANCEL 2

ABORT 3

RETRY 4

IGNORE 5

YES 6

NO 7

TRY AGAIN ** 10

CONTINUE ** 11

Thanks :D

Share this post


Link to post
Share on other sites

I'm guessing that he doesn't (or at least didn't) exactly understand that AutoIt is not C++.

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