Jump to content
Sign in to follow this  
CarlKing

How to send contents of a string variable to Notepad

Recommended Posts

How do I send the contents of a string variable to Notepad?

Yes I am a total newbie to AutoIt.

$answer = MsgBox(4, "Split Text", "This script will run Notepad type in some text and then quit. Run?")

If $answer = 7 Then

MsgBox(0, "AutoIt", "OK. Bye!")

Exit

EndIf

Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

$days = StringSplit(" Sun Mon Tue Wed Thu Fri Sat", " ")

send, $days[0]

send, $days[1]

send ("{enter}")

for $i=0 to $days[0]

$i += 1

send($i)

if $days[$i] <> "" Then

if $days[$i] <> " " Then

send("{$days[$i]}{enter} {enter}")

EndIf

endif

Next

Share this post


Link to post
Share on other sites

#include <GuiConstants.au3>

GuiCreate("MyGUI", 235, 190,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input = GuiCtrlCreateInput("", 20, 30, 200, 20)
$copy = GuiCtrlCreateButton("Copy", 20, 150, 60, 30)
$exit = GuiCtrlCreateButton("Exit", 160, 150, 60, 30)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $exit
            Exit
        Case $msg = $copy
            $readme = GuiCtrlRead($Input)
            run("notepad.exe")
            WinActivate("Untitled - Notepad")
            Sleep(1000)
            Send($readme)
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;
    EndSelect
WEnd
Exit

Secure

Share this post


Link to post
Share on other sites

Also, look up Control in the helpfile, there are various examples .. ControlSend, ControlClick, etc.

yes, i typically use
controlsettext("Untitled - Notepad","",15,$var)

for notepad, because then i don't have to worry about other keystrokes affecting the string to be set, and i don't have to have the notepad as the active window, etc etc etc.

Edited by cameronsdad

Share this post


Link to post
Share on other sites

Thank you all. I really appreciate your help!

I can see I will be writing a bunch of functions to simplify things

to the level I am used to (mainframe assembler).

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  

×
×
  • Create New...