Sign in to follow this  
Followers 0
ubernewb

GUI w/ Input to Word

9 posts in this topic

OK, here goes... I am trying to make a GUI with an input where you can type a word. Once the word is typed I want to be able to push a button and have MS Word open and the word be typed automatically into MS Word. I have tried many different things but I have not figured it out (i am new to Autoit). Here is my code...

#include <GuiConstants.au3>

; GUI
GuiCreate("Current Information", 340, 400)

; Display the GUI
GUISetState()

; Edit input to word
GUICtrlCreateLabel("Enter word below:", 20, 100, 200)
$InputText = GUICtrlCreateInput("", 20, 120, 200, 20)

; Button for input to word
$CheckSpell = GUICtrlCreateButton ("Send Now!",  240, 117, 80)

; Attempt to program button
Do
    $msg = GUIGetMsg()
   
    Select
        Case $msg= $CheckSpell
            Run("notepad.exe")
        ; Run("C:\Program Files\Microsoft Office\OFFICE11\winword.exe")
            WinWaitActive("Untitled - Notepad")
        ; WinWaitActive("Document1 - Microsoft Word")
            Sleep(1000)         
        EndSelect
Until $msg = $GUI_EVENT_CLOSE

I have taken all my feable attempts to make this work out of the above code so as not to confuse anyone. Also, the PC I am on does not have MS Word on it, that is why it is calling on notepad.exe instead. Any fresh ideas on how to make this work? Thanks!


Maybe if I typed something here you would get an idea of what kind of person I am?

Share this post


Link to post
Share on other sites



Run("C:\Program Files\Microsoft Office\OFFICE11\winword.exe")

Is:

Run("C:\Program Files\Microsoft Office\OFFICE10\winword.exe")

On my computer, and it does work.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

here what u wanted but is restricted to 1 line only then opens new one:/

no longer Resticted... :whistle:

#include <GuiConstants.au3>

; GUI

GuiCreate("Current Information", 340, 400)

; Display the GUI

GUISetState()

; Edit input to word

GUICtrlCreateLabel("Enter word below:", 20, 100, 200)

$InputText = GUICtrlCreateInput("", 20, 120, 200, 20)

; Button for input to word

$CheckSpell = GUICtrlCreateButton ("Send Now!",  240, 117, 80)

; Attempt to program button

Do

$msg = GUIGetMsg()
   
Select

Case $msg = $CheckSpell

if WinExists("Untitled - Notepad") = 0 then

Run("notepad.exe")

$IText = GUICtrlRead($InputText) 

WinActivate("Untitled - Notepad")

Send($IText & "{Enter}")

Else 

$IText = GUICtrlRead($InputText) 

WinActivate("Untitled - Notepad")

Send($IText & "{Enter}")

; WinWaitActive("Document1 - Microsoft Word")

EndIf

EndSelect

Until $msg = $GUI_EVENT_CLOSE

and y bother with all the extra letters

Run("C:\Progra~1\Micros~1\OFFICE~1\winword.exe")
Edited by WSCPorts

http://www.myclanhosting.com/defiasVisit Join and contribute to a soon to be leader in Custumized tools development in [C# .Net 1.1 ~ 2.0/C/C++/MFC/AutoIt3/Masm32]

Share this post


Link to post
Share on other sites

and y bother with all the extra letters

It was a cut 'n paste from working on a PC that had MS Office 2003 installed. Thank you very much to both of you. I am really trying to learn all of this stuff. I think AutoIt is great!


Maybe if I typed something here you would get an idea of what kind of person I am?

Share this post


Link to post
Share on other sites

me to thats why i try to figure out other ppls problems, its a way to get hands on expeirence in AutoIt. :whistle:


http://www.myclanhosting.com/defiasVisit Join and contribute to a soon to be leader in Custumized tools development in [C# .Net 1.1 ~ 2.0/C/C++/MFC/AutoIt3/Masm32]

Share this post


Link to post
Share on other sites

$InputText = GUICtrlCreateInput("", 20, 120, 200, 20)

I tried your code and it worked exactly as advertised. However, if I put more than one word into the input box, it sent the words to Notepad multiple times. That is, if I put in two words, it sent the two words twice. If I put in three words, it sent them three times. Why does this happen? I looked through the code, but did not see anything that would cause this.

Curious...


...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

I tried your code and it worked exactly as advertised. However, if I put more than one word into the input box, it sent the words to Notepad multiple times. That is, if I put in two words, it sent the two words twice. If I put in three words, it sent them three times. Why does this happen? I looked through the code, but did not see anything that would cause this.

Curious...

I found the same thing but I don't know why it does that.


Maybe if I typed something here you would get an idea of what kind of person I am?

Share this post


Link to post
Share on other sites

well it dont do it for me unless i hit send 2 times...:whistle: i can place any amount of words and it just write em all out

here my File ... although i dont see any differences in it except spacing

Untitled.au3


http://www.myclanhosting.com/defiasVisit Join and contribute to a soon to be leader in Custumized tools development in [C# .Net 1.1 ~ 2.0/C/C++/MFC/AutoIt3/Masm32]

Share this post


Link to post
Share on other sites

Actually, I was only able to duplicate the problem when using notepad. In MS Word it works great. I did have to add some sleeps because it was opening up multiple instances of MS Word. It needs even longer sleeps for slower computers. Here is my updated code. Note that you will have to change the path to MS Word if you are running anything other than MS Office 2003.

#include <GuiConstants.au3>

; GUI

GuiCreate("Spellchecker", 340, 400)

; Display the GUI

GUISetState()

; Edit input to word

GUICtrlCreateLabel("Enter word below to check spelling:", 20, 100, 200)

$InputText = GUICtrlCreateInput("", 20, 120, 200, 20)

; Button for input to word

$CheckSpell = GUICtrlCreateButton ("Check Now!",  240, 117, 80)

Do

$msg = GUIGetMsg()
   
Select

Case $msg = $CheckSpell

if WinExists("Document1 - Microsoft Word") = 0 then

Sleep(1200)
Run("C:\Program Files\Microsoft Office\OFFICE11\winword.exe")
Sleep(500)

$IText = GUICtrlRead($InputText) 

WinActivate("Document1 - Microsoft Word")

Send($IText & "{Enter}")

Else 

$IText = GUICtrlRead($InputText) 

WinActivate("Document1 - Microsoft Word")

Send($IText & "{Enter}")

EndIf

EndSelect

Until $msg = $GUI_EVENT_CLOSE

What do you think?


Maybe if I typed something here you would get an idea of what kind of person I am?

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