Sign in to follow this  
Followers 0
Rawox

Clearing Notepad Window

10 posts in this topic

#1 ·  Posted (edited)

This Script opens 4 notepad windows beside each other, clicks on them, writes something in them, closes first 3 and maximizes last one.

All I need is something to clear the last notepad file :)... Not creating an new one.

; ========================================================== 4 NOTEPAD WINDOWS TRICK ========================================================== End Line = 

; Opens 4 Different Notepad Files with Text in it!
Const $WINDOWS = 4
$x = @DesktopWidth/4
For $i=0 To $WINDOWS-1 Step 1
    Run("notepad")
    WinWaitActive("Untitled - Notepad")
    WinMove("Untitled - Notepad","",$i*$x,0,$x)
    Send("Window "&$i+1)
Next

; ---------------------------- Notepad File 1 ----------------------------
MouseClick ( "left" , 100, 400 , 1 , 25 );Clicks on first Notepad File...
Sleep( 1000 )
MouseClick ( "left" , 100, 400 , 1 , 25 );Backup
Send("{ENTER}")
Send("{ENTER}")
Send("Ok, We've done the first window.")
Sleep( 2000 )

; ---------------------------- Notepad File 2 ----------------------------
MouseClick ( "left" , 400, 400 , 1 , 25 );Clicks on second Notepad File...
Sleep( 1000 )
MouseClick ( "left" , 400, 400 , 1 , 25 );Backup
Send("{ENTER}")
Send("{ENTER}")
Send("Now We've also done the second window.")
Sleep( 2000 )

; ---------------------------- Notepad File 3 ----------------------------
MouseClick ( "left" , 750, 400 , 1 , 25 );Clicks on third Notepad File...
Sleep( 1000 )
MouseClick ( "left" , 750, 400 , 1 , 25 );Backup
Send("{ENTER}")
Send("{ENTER}")
Send("I Think this is the third window.")
Sleep( 2000 )

; ---------------------------- Notepad File 4 ----------------------------
MouseClick ( "left" , 1100, 400 , 1 , 25 );Clicks on fourth Notepad File...
Sleep( 1000 )
MouseClick ( "left" , 1100, 400 , 1 , 25 );Backup
Send("{ENTER}")
Send("{ENTER}")
Send("Yeah, we made it. The Fourth window.")
Sleep( 3000 )
Send("{ENTER}")
Send("We Also need to Clean it up, so let's do that")
Sleep( 2500 )

; ---------------------------- Cleaning ----------------------------

; Select File 1 ----------------
MouseClick ( "left" , 100, 400 , 1 , 25 );Clicks on first Notepad File...
Sleep( 1000 )
MouseClick ( "left" , 100, 400 , 1 , 25 );Backup
; Close File 1
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do you want to save")
Sleep ( 1 )
Send("!n")

; Select File 2 ----------------
MouseClick ( "left" , 400, 400 , 1 , 25 );Clicks on second Notepad File...
Sleep( 1000 )
MouseClick ( "left" , 400, 400 , 1 , 25 );Backup
; Close File 2
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do you want to save")
Sleep ( 1 )
Send("!n")

; Select File 3 ----------------
MouseClick ( "left" , 750, 400 , 1 , 25 );Clicks on third Notepad File...
Sleep( 1000 )
MouseClick ( "left" , 750, 400 , 1 , 25 );Backup
; Close File 3
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do you want to save")
Sleep ( 1 )
Send("!n")

; Select File 4 ----------------
MouseClick ( "left" , 1100, 400 , 1 , 25 );Clicks on fourth Notepad File...
Sleep( 1000 )
MouseClick ( "left" , 1100, 400 , 1 , 25 );Backup
; Maximize
WinSetState("Untitled - Notepad", "", @SW_MAXIMIZE)
; Clear
Edited by Rawox

Share this post


Link to post
Share on other sites



get the notepad-text-control-class with au3info.exe and use it with this function

ControlSetText ("Untitled - Notepad", "", heregoestheclass, "")

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

get the notepad-text-control-class with au3info.exe and use it with this function

ControlSetText ("Untitled - Notepad", "", heregoestheclass, "")

WOW! Sorry, I can't really understand this. Could be more simple or something like that

Wait, I think I got it :) Tnx, I'm starting to learn it

Edited by Rawox

Share this post


Link to post
Share on other sites

What is it you are trying to accomplish here? There is probably a better way to go about it.

Share this post


Link to post
Share on other sites

Sorry for the new topic, but no one was replying it...

But, can the class be: just: Notepad

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Man you got a reply on an average of every 6minutes... Thats pretty good IMO. If someone doesn't reply, DO NOT create a new topic, bump it after 24hours.... >_<

EDIT: Have a close look at my reply in your original topic. You'll find I use the CLASS/INSTANCE in the script. :)

Edited by BrettF

Share this post


Link to post
Share on other sites

From what I think you mean, you could do something like:

Send("^a")
Send("{DELETE}")

Would that work?


For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites

From what I think you mean, you could do something like:

Send("^a")
Send("{DELETE}")

Would that work?

That's what I needed, is an ^ For Control... I Think So! Tnx...

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

The reason I asked earlier why you were doing this is because depending on your reasoning for using notepad, I think you may be happier using your own GUI:

#include<WindowsConstants.au3>
#include <GUIEdit.au3>
Global $TextNumber, $textHeight, $Text[1], $exit, $GUIBGColor = 0x000000
Opt("GUIOnEventMode", 1)

$GUI = GUICreate('Test GUI', @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
GUISetBkColor( $GUIBGColor )
GUISetState(@SW_SHOW)

While 1
    Demo()  
WEnd

Func SetupTextCtrl($Num, $Height, $scroll = 0)
    If $Num < 1 Then Return SetError(1)
    $scrollbar = 0
    If $scroll = 1 Then $scrollbar = $WS_VSCROLL
    $TextNumber = $Num
    $textHeight = $Height
    GUICtrlDelete($exit)
    For $a = 1 To $Text[0]
        GUICtrlDelete( $Text[$a] )
    Next
    ReDim $Text[$TextNumber + 1]
    $Text[0] = $TextNumber
    For $a = 1 To $Text[0]
        $Text[$a] = GUICtrlCreateEdit('', ($a - 1) * (@DesktopWidth / $Text[0]), 0, @DesktopWidth / $Text[0], $textHeight, $ES_READONLY + $scrollbar)
    Next
    $exit = GUICtrlCreateButton( 'EXIT', (@DesktopWidth / 2) - 150, $textHeight, 300, 50 )
    GUICtrlSetOnEvent( -1, "MyExit" )
EndFunc   ;==>SetText

Func SetText($Num, $String)
    If $Num > $Text[0] or $Num < 1 Then Return SetError(1)
    GUICtrlSetData( $Text[$Num], $String )
EndFunc

Func SetColor( $Num, $TextColor, $BGColor )
    If $Num > $Text[0] or $Num < 1 Then Return SetError(1)
    GUICtrlSetColor( $Text[$Num], $TextColor )
    GUICtrlSetBkColor( $Text[$Num], $BGColor )
EndFunc

Func SetAllColor( $TextColor, $BGColor )
    For $a = 1 To $Text[0]
        SetColor( $a, $TextColor, $BGColor )
    Next
EndFunc

Func ClearAll()
    For $a = 1 To $Text[0]
        SetText($a, '')
    Next
EndFunc

Func SetSize( $Num, $size )
    If $Num > $Text[0] or $Num < 1 Then Return SetError(1)
    GUICtrlSetFont( $Text[$Num], $size )
EndFunc

Func SetAllSize( $size )
    For $a = 1 To $Text[0]
        SetSize( $a, $size )
    Next
EndFunc

Func MyExit()
    Exit
EndFunc

Func Demo()
    SetupTextCtrl(4, @DesktopHeight * .9)
    SetText(1, 'Box 1')
    SetText(2, 'This is Box 2')
    SetText(3, 'TextBox 3')
    SetText(4, 'Number 4')
    SetText(5, "5... Ooops, this one doesn't exist")
    SetColor(1, 0xFF0000, 0x000000 )
    SetColor(2, 0x00FF00, 0xFFFFFF )
    SetColor(3, 0x0000FF, 0x000000 )
    SetColor(4, 0x000000, 0xFFFFFF )
    SetColor(5, 0xFF0000, 0x000000 )
    Sleep(3000)
    SetupTextCtrl( 10, @DesktopHeight * .5 )
    SetAllSize( 20 )
    For $a = 1 To 10
        SetText($a, "Number " & $a)
    Next
    SetAllColor( 0x000000, 0xFFFFFF )
    Sleep(3000)
    ClearAll()
    Sleep(3000)
    For $a = 1 To 10
        SetText($a, "cleared")
    Next
    SetAllColor( 0xFFFFFF, 0x0000 )
    Sleep(3000)
    SetupTextCtrl(2, @DesktopHeight * .9, 1)
    SetAllSize( 200 )
    SetText(1, "You can create them with scrollbars as well if the text is increadibly long-You can create them with scrollbars as well if the text is increadibly long-You can create them with scrollbars as well if the text is increadibly long-You can create them with scrollbars as well if the text is increadibly long-You can create them with scrollbars as well if the text is increadibly long")
    SetText(2, "You can create them with scrollbars as well if the text is increadibly long-You can create them with scrollbars as well if the text is increadibly long")
    Sleep(5000)
    SetupTextCtrl(1, @DesktopHeight * .9)
    SetAllSize( 50 )
    SetText(1, "I think you get the point.")
    Sleep(3000)
    MyExit()
EndFunc

EDIT: Added a little

Edited by danwilli

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