Jump to content

Typing in Notepad


AlmarM
 Share

Recommended Posts

Again a simple made script :)

xxx = notepad name

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.6.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

HotKeySet('{ESC}', '_Exit') 
Run("notepad.exe") 

WinWait("xxx") 
If Not WinActive("xxx") Then WinActivate("xxx") 

Send("    ___,  _____ ______ ___ ___     ___,   ____  ______{ENTER}") 
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100) 
Send("   /   | / ___// ____/  _/  _/    /   |  / __ \/_  __/{ENTER}") 
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100) 
Send("  / /| | \__ \/ /    / / / /     / /| | / /_/ / / /   {ENTER}") 
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100) 
Send(" / ___ |___/ / /____/ /_/ /     / ___ |/ _, _/ / /    {ENTER}") 
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100) 
Send("/_/  |_/____/\____/___/___/    /_/  |_/_/ |_| /_/{ENTER 2}") 
If Not WinActive("xxx") Then WinActivate("xxx") 

Sleep(500) 

Send("    _    ____   ____ ___ ___      _         _     _____          _       {ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(200)
Send("   / \  / ___| / ___|_ _|_ _|    / \   _ __| |_  |  ___|_ _ _ __| |_ ___ {ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(200)
Send("  / _ \ \___ \| |    | | | |    / _ \ | '__| __| | |_ / _` | '__| __/ __|{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(200)
Send(" / ___ \ ___) | |___ | | | |   / ___ \| |  | |_  |  _| (_| | |  | |_\__ \{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(200)
Send("/_/   \_\____/ \____|___|___| /_/   \_\_|   \__| |_|  \__,_|_|   \__|___/{ENTER 2}")
If Not WinActive("xxx") Then WinActivate("xxx") 

Sleep(500)

Send("          _____             _____            _____{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("         /\    \           /\    \          /\    \{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("        /::\    \         /XX\    \        /%%\    \ {ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("       /::::\    \       /XXXX\    \      /%%%%\    \      _____      _____{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("      /::::::\    \     /XXXXXX\    \    /%%%%%%\    \    /\    \    /\    \{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("     /:::/\:::\    \   /XXX/\XXX\    \  /%%%/\%%%\    \  /..\    \  /;;\    \{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("    /:::/__\:::\    \ /XXX/__\XXX\    \/%%%/  \%%%\    \ \...\    \ \;;;\    \{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("   /::::\   \:::\    \\XXX\   \XXX\    \%%/    \%%%\    \/....\____\/;;;;\____\{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("  /::::::\   \:::\    \\XXX\   \XXX\    \/    / \%%%\    \..../    /;;;;;/    /{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send(" /:::/\:::\   \:::\    \\XXX\   \XXX\    \   /   \%%%\    \/\/____/;;;/\/____/{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("/:::/  \:::\   \:::\____\\XXX\   \XXX\____\_/     \%%%\____\   / /;;;/    /{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("\::/    \:::\  /:::/    / \XXX\   \XX/    / \      \%%/    /  /_/;;;/    /{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send(" \/____/ \:::\/:::/    /   \XXX\   \/____/   \    /\\/____/  /\/;;;/    /{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("          \::::::/    /X\   \XXX\    \%%%\    \  /...../    /;;;;;/    /{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("           \::::/    /XXX\   \XXX\____\%%%\    \ \..../____/\;;;;/____/{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("           /:::/    / \XXX\  /XXX/    /\%%%\    \ \...\____\ \;;;\____\{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("          /:::/    /   \XXX\/XXX/    /  \%%%\    \ \../    /  \;;/    /{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("         /:::/    /     \XXXXXX/    /    \%.%\    \ \/____/    \/____/{ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("        /:::/    /       \XXXX/    /      \%%%\____\  {ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("        \::/    /         \XX/    /        \%%/    /      {ENTER}")
If Not WinActive("xxx") Then WinActivate("xxx") 
Sleep(100)
Send("         \/____/           \/____/          \/____/        {ENTER 2}") 

Sleep(500) 



Func _Exit()
;ToolTip(' '&@CRLF&' EXITING '&@CRLF&' ')
Sleep(500)
Exit
EndFunc

EDIT: I have put If Not WinActive("xxx") Then WinActivate("xxx") afther every Send()

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

Cool. :) Although you have a lot to learn.

Edit: I might as well tell you what to change.. Always use variables, instead of deleting xxx three times and pasting the notepad name, you could have used a variable on the top. Best know as a 'Setting'. Also have a go with Opt("WinTitleMatchMode", #) look it up in the help file. :)

Edited by Manadar
Link to comment
Share on other sites

You should check if the window is active after every send because you can just click somewhere else by accident and it will send the text to that window.

Ty for the reply :)

I will EDIT it :)

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

You could also use a function. So instead to retyping;

If Not WinActive("xxx") Then WinActivate("xxx")

over and over, you can make something like this;

Func ForceWin()
       $xxx = "some window name"
       If Not WinActive("" & $xxx) Then WinActivate("" & $xxx)
EndFunc

So in your script you'll have something like this instead.

Send("  ___,  _____ ______ ___ ___   ___,   ____  ______{ENTER}") 
ForceWin()
Sleep(100) 
Send("   /   | / ___// ____/  _/  _/    /   |  / __ \/_  __/{ENTER}") 
ForceWin()
Sleep(100) 
Send("  / /| | \__ \/ / / / / /  / /| | / /_/ / / /   {ENTER}") 
ForceWin()
Sleep(100) 
Send(" / ___ |___/ / /____/ /_/ /    / ___ |/ _, _/ / / {ENTER}") 
ForceWin()
Sleep(100) 
Send("/_/  |_/____/\____/___/___/   /_/  |_/_/ |_| /_/{ENTER 2}") 
ForceWin()

This will save you a lot of time editing if you ever want to change the value of $xxx.

Hope that helps.

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

Func ForceWin()

$xxx = "some window name"

If Not WinActive("" & $xxx) Then WinActivate("" & $xxx)

EndFunc

So if i put that in my script... You guys dont need to change xxx ?

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

Opt("WinTitleMatchMode", 4)

HotKeySet('{ESC}', '_Exit')

Run("notepad.exe")

$sTitle = "[CLASS:Notepad]"

Send("#d")
WinSetOnTop($sTitle,"",1)

WinWait($sTitle)
Activate()

Send("    ___,  _____ ______ ___ ___     ___,   ____  ______{ENTER}")
Activate()
Sleep(100)
Send("   /   | / ___// ____/  _/  _/    /   |  / __ \/_  __/{ENTER}")
Activate()
Sleep(100)
Send("  / /| | \__ \/ /    / / / /     / /| | / /_/ / / /   {ENTER}")
Activate()
Sleep(100)
Send(" / ___ |___/ / /____/ /_/ /     / ___ |/ _, _/ / /    {ENTER}")
Activate()
Sleep(100)
Send("/_/  |_/____/\____/___/___/    /_/  |_/_/ |_| /_/{ENTER 2}")
Activate()

Sleep(500)

Send("    _    ____   ____ ___ ___      _         _     _____          _       {ENTER}")
Activate()
Sleep(200)
Send("   / \  / ___| / ___|_ _|_ _|    / \   _ __| |_  |  ___|_ _ _ __| |_ ___ {ENTER}")
Activate()
Sleep(200)
Send("  / _ \ \___ \| |    | | | |    / _ \ | '__| __| | |_ / _` | '__| __/ __|{ENTER}")
Activate()
Sleep(200)
Send(" / ___ \ ___) | |___ | | | |   / ___ \| |  | |_  |  _| (_| | |  | |_\__ \{ENTER}")
Activate()
Sleep(200)
Send("/_/   \_\____/ \____|___|___| /_/   \_\_|   \__| |_|  \__,_|_|   \__|___/{ENTER 2}")
Activate()

Sleep(500)

Send("          _____             _____            _____{ENTER}")
Activate()
Sleep(100)
Send("         /\    \           /\    \          /\    \{ENTER}")
Activate()
Sleep(100)
Send("        /::\    \         /XX\    \        /%%\    \ {ENTER}")
Activate()
Sleep(100)
Send("       /::::\    \       /XXXX\    \      /%%%%\    \      _____      _____{ENTER}")
Activate()
Sleep(100)
Send("      /::::::\    \     /XXXXXX\    \    /%%%%%%\    \    /\    \    /\    \{ENTER}")
Activate()
Sleep(100)
Send("     /:::/\:::\    \   /XXX/\XXX\    \  /%%%/\%%%\    \  /..\    \  /;;\    \{ENTER}")
Activate()
Sleep(100)
Send("    /:::/__\:::\    \ /XXX/__\XXX\    \/%%%/  \%%%\    \ \...\    \ \;;;\    \{ENTER}")
Activate()
Sleep(100)
Send("   /::::\   \:::\    \\XXX\   \XXX\    \%%/    \%%%\    \/....\____\/;;;;\____\{ENTER}")
Activate()
Sleep(100)
Send("  /::::::\   \:::\    \\XXX\   \XXX\    \/    / \%%%\    \..../    /;;;;;/    /{ENTER}")
Activate()
Sleep(100)
Send(" /:::/\:::\   \:::\    \\XXX\   \XXX\    \   /   \%%%\    \/\/____/;;;/\/____/{ENTER}")
Activate()
Sleep(100)
Send("/:::/  \:::\   \:::\____\\XXX\   \XXX\____\_/     \%%%\____\   / /;;;/    /{ENTER}")
Activate()
Sleep(100)
Send("\::/    \:::\  /:::/    / \XXX\   \XX/    / \      \%%/    /  /_/;;;/    /{ENTER}")
Activate()
Sleep(100)
Send(" \/____/ \:::\/:::/    /   \XXX\   \/____/   \    /\\/____/  /\/;;;/    /{ENTER}")
Activate()
Sleep(100)
Send("          \::::::/    /X\   \XXX\    \%%%\    \  /...../    /;;;;;/    /{ENTER}")
Activate()
Sleep(100)
Send("           \::::/    /XXX\   \XXX\____\%%%\    \ \..../____/\;;;;/____/{ENTER}")
Activate()
Sleep(100)
Send("           /:::/    / \XXX\  /XXX/    /\%%%\    \ \...\____\ \;;;\____\{ENTER}")
Activate()
Sleep(100)
Send("          /:::/    /   \XXX\/XXX/    /  \%%%\    \ \../    /  \;;/    /{ENTER}")
Activate()
Sleep(100)
Send("         /:::/    /     \XXXXXX/    /    \%.%\    \ \/____/    \/____/{ENTER}")
Activate()
Sleep(100)
Send("        /:::/    /       \XXXX/    /      \%%%\____\  {ENTER}")
Activate()
Sleep(100)
Send("        \::/    /         \XX/    /        \%%/    /      {ENTER}")
Activate()
Sleep(100)
Send("         \/____/           \/____/          \/____/        {ENTER 2}")

Sleep(2000)
_Exit()

Func Activate()
    If Not WinActive($sTitle) Then 
        WinActivate($sTitle)
        If Not WinActive($sTitle) Then 
            _Exit()
        EndIf
    EndIf
EndFunc

Func _Exit()
    WinClose($sTitle)
    Send("n")
    Exit
EndFunc

Link to comment
Share on other sites

Opt("WinTitleMatchMode", 4)

HotKeySet('{ESC}', '_Exit')

Run("notepad.exe")

$sTitle = "[CLASS:Notepad]"

Send("#d")
WinSetOnTop($sTitle,"",1)

WinWait($sTitle)
Activate()

Send("    ___,  _____ ______ ___ ___     ___,   ____  ______{ENTER}")
Activate()
Sleep(100)
Send("   /   | / ___// ____/  _/  _/    /   |  / __ \/_  __/{ENTER}")
Activate()
Sleep(100)
Send("  / /| | \__ \/ /    / / / /     / /| | / /_/ / / /   {ENTER}")
Activate()
Sleep(100)
Send(" / ___ |___/ / /____/ /_/ /     / ___ |/ _, _/ / /    {ENTER}")
Activate()
Sleep(100)
Send("/_/  |_/____/\____/___/___/    /_/  |_/_/ |_| /_/{ENTER 2}")
Activate()

Sleep(500)

Send("    _    ____   ____ ___ ___      _         _     _____          _       {ENTER}")
Activate()
Sleep(200)
Send("   / \  / ___| / ___|_ _|_ _|    / \   _ __| |_  |  ___|_ _ _ __| |_ ___ {ENTER}")
Activate()
Sleep(200)
Send("  / _ \ \___ \| |    | | | |    / _ \ | '__| __| | |_ / _` | '__| __/ __|{ENTER}")
Activate()
Sleep(200)
Send(" / ___ \ ___) | |___ | | | |   / ___ \| |  | |_  |  _| (_| | |  | |_\__ \{ENTER}")
Activate()
Sleep(200)
Send("/_/   \_\____/ \____|___|___| /_/   \_\_|   \__| |_|  \__,_|_|   \__|___/{ENTER 2}")
Activate()

Sleep(500)

Send("          _____             _____            _____{ENTER}")
Activate()
Sleep(100)
Send("         /\    \           /\    \          /\    \{ENTER}")
Activate()
Sleep(100)
Send("        /::\    \         /XX\    \        /%%\    \ {ENTER}")
Activate()
Sleep(100)
Send("       /::::\    \       /XXXX\    \      /%%%%\    \      _____      _____{ENTER}")
Activate()
Sleep(100)
Send("      /::::::\    \     /XXXXXX\    \    /%%%%%%\    \    /\    \    /\    \{ENTER}")
Activate()
Sleep(100)
Send("     /:::/\:::\    \   /XXX/\XXX\    \  /%%%/\%%%\    \  /..\    \  /;;\    \{ENTER}")
Activate()
Sleep(100)
Send("    /:::/__\:::\    \ /XXX/__\XXX\    \/%%%/  \%%%\    \ \...\    \ \;;;\    \{ENTER}")
Activate()
Sleep(100)
Send("   /::::\   \:::\    \\XXX\   \XXX\    \%%/    \%%%\    \/....\____\/;;;;\____\{ENTER}")
Activate()
Sleep(100)
Send("  /::::::\   \:::\    \\XXX\   \XXX\    \/    / \%%%\    \..../    /;;;;;/    /{ENTER}")
Activate()
Sleep(100)
Send(" /:::/\:::\   \:::\    \\XXX\   \XXX\    \   /   \%%%\    \/\/____/;;;/\/____/{ENTER}")
Activate()
Sleep(100)
Send("/:::/  \:::\   \:::\____\\XXX\   \XXX\____\_/     \%%%\____\   / /;;;/    /{ENTER}")
Activate()
Sleep(100)
Send("\::/    \:::\  /:::/    / \XXX\   \XX/    / \      \%%/    /  /_/;;;/    /{ENTER}")
Activate()
Sleep(100)
Send(" \/____/ \:::\/:::/    /   \XXX\   \/____/   \    /\\/____/  /\/;;;/    /{ENTER}")
Activate()
Sleep(100)
Send("          \::::::/    /X\   \XXX\    \%%%\    \  /...../    /;;;;;/    /{ENTER}")
Activate()
Sleep(100)
Send("           \::::/    /XXX\   \XXX\____\%%%\    \ \..../____/\;;;;/____/{ENTER}")
Activate()
Sleep(100)
Send("           /:::/    / \XXX\  /XXX/    /\%%%\    \ \...\____\ \;;;\____\{ENTER}")
Activate()
Sleep(100)
Send("          /:::/    /   \XXX\/XXX/    /  \%%%\    \ \../    /  \;;/    /{ENTER}")
Activate()
Sleep(100)
Send("         /:::/    /     \XXXXXX/    /    \%.%\    \ \/____/    \/____/{ENTER}")
Activate()
Sleep(100)
Send("        /:::/    /       \XXXX/    /      \%%%\____\  {ENTER}")
Activate()
Sleep(100)
Send("        \::/    /         \XX/    /        \%%/    /      {ENTER}")
Activate()
Sleep(100)
Send("         \/____/           \/____/          \/____/        {ENTER 2}")

Sleep(2000)
_Exit()

Func Activate()
    If Not WinActive($sTitle) Then 
        WinActivate($sTitle)
        If Not WinActive($sTitle) Then 
            _Exit()
        EndIf
    EndIf
EndFunc

Func _Exit()
    WinClose($sTitle)
    Send("n")
    Exit
EndFunc
Ty :)

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

So if i put that in my script... You guys dont need to change xxx ?

Yes, you can (and you need to, because this is the correct way) declare the variable at the begining of your script globaly...

Opt("WinTitleMatchMode", 2)
Run("notepad.exe")

Global $MainTitle = WinGetTitle("- Notepad")

;............

ForceWin()
Send("    ___,  _____ ______ ___ ___     ___,   ____  ______{ENTER}") 
ForceWin()
Sleep(100) 
Send("   /   | / ___// ____/  _/  _/    /   |  / __ \/_  __/{ENTER}")
ForceWin()

;...........

Func ForceWin()
       If Not WinActive($MainTitle) Then WinActivate($MainTitle)
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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