Jump to content

Please help im new to C++


Recommended Posts

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!

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

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

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

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

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