Jump to content

Sending a keystroke ( {enter} ) to an edit box


Recommended Posts

Hi there, i've been looking at the forums for my problem but couldnt get the script to work

#include <GUIConstants.au3>
#include <controlsendplus.au3>

GUICreate("StOrFoxx", 800, 600, "", "")
$html = GUICtrlCreateButton("<HTML>", 620, 50, 60, 20, $BS_FLAT)
$endhtml = GUICtrlCreateButton("/", 690, 50, 30, 20, $BS_FLAT)
$body = GUICtrlCreateButton("<BODY>", 620, 80, 60, 20, $BS_FLAT)
$endbody = GUICtrlCreateButton("/", 690, 80, 30, 20, $BS_FLAT)
$edit = GUICtrlCreateEdit( "", 10, 50, 600, 540 )
GUISetState(@SW_SHOW)

While 1
  $msg = GUIGetMsg()

  Select
    Case $msg = $html
      ControlSendPlus( "StOrFoxx", "", $edit, "<HTML>", 0 )
    
    Case $msg = $endhtml
      ControlSendPlus( "StOrFoxx", "", $edit, "</HTML>", 0 )
    
    Case $msg = $body
      ControlSendPlus( "StOrFoxx", "", $edit, "<BODY>", 0 )
      
    Case $msg = $endbody
      ControlSendPlus( "StOrFoxx", "", $edit, "</BODY>", 0 )

    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
  EndSelect
WEnd

As you see I'm making a program to help starting webdesigners learning HTML. :(

When I click on a button it will add the text to $edit, but I need to have a {enter} after it so it continues at the next line in $edit.

For example: I press the button for creating the <html> tag in the $edit, this comes at line 1. After that I'll press the button for the <body> tag, with destination line 2

I'm using the ControlSendPlus() function.. ( Thanks :D )

I would be gratefull if anyone knows the answer on this question :)

Edit: Added the include controlsendplus.au3

controlsendplus.au3

Edited by Hideous

[u]Its all about experience...[/u]...

Link to comment
Share on other sites

Try this:

ControlSendPlus( "StOrFoxx", "", $edit, "<HTML>" & @CR, 0 )

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Or you can use:

Chr (13)

That did it :D, didnt knew there was a big difference between ASCII and using {key}. Thnx for the fast reply :( I will post the program as soon it is ready.

:)

Edited by Hideous

[u]Its all about experience...[/u]...

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