Jump to content

Multiple Notepad Windows Open


Rawox
 Share

Recommended Posts

Hi,

Is there an possible option to open 2 notepad windows beside each other and switch between them...

Detailed Idea:

Script opens 2 notepad windows, 1 on the left of the screen and one on the right.

Script activates the first window, types some text.

Script activates second window, types some text.

etc.

Any Ideas, or simple scripts? I'm not really good with AutoIt!!

Tnx! :)

Link to comment
Share on other sites

@Rawox

Script opens 2 notepad windows, 1 on the left of the screen and one on the right.

WinMove("[CLASS:Notepad]",'',x,y)

Script activates the first window, types some text.

WinActivate("[CLASS:Notepad]")
WinWaitActive("[CLASS:Notepad]",'',3)
ControlSend("[CLASS:Notepad]",'',15,"your text")

Cheers, FireFox.

Link to comment
Share on other sites

Hi,

Is there an possible option to open 2 notepad windows beside each other and switch between them...

Detailed Idea:

Script opens 2 notepad windows, 1 on the left of the screen and one on the right.

Script activates the first window, types some text.

Script activates second window, types some text.

etc.

Any Ideas, or simple scripts? I'm not really good with AutoIt!!

Tnx! :)

This is an example script you can experiment with.

#include <SendMessage.au3>
#include <WindowsConstants.au3>

Opt("WinWaitDelay", 0)

If Not WinExists('[CLASS:Notepad]') Then Run(@WindowsDir & '\Notepad.exe')
WinActivate('[CLASS:Notepad]')
WinWait('[CLASS:Notepad]')
$hRNotepad = WinGetHandle('[CLASS:Notepad]')
$iWidth = (@DesktopWidth / 2) - 10
$iHeight = (@DesktopHeight / 2)
$y = (@DesktopHeight / 4)
WinMove($hRNotepad, "", (@DesktopWidth / 2) + 5, $y, $iWidth, $iHeight)
WinSetTitle(WinGetTitle($hRNotepad), "", "R")

Run(@WindowsDir & '\Notepad.exe')
WinActivate("Untitled - ")
WinWait("Untitled - ")

$hLNotepad = WinGetHandle("Untitled - ")
$iWidth = (@DesktopWidth / 2) - 10
$iHeight = (@DesktopHeight / 2)
$y = (@DesktopHeight / 4)

WinMove($hLNotepad, "", 5, $y, $iWidth, $iHeight)
ControlSetText($hLNotepad, "", "", "Left Notepad 1st entry")

WinActivate($hRNotepad)
WinWait($hRNotepad)
Send("{ENTER}")
WinWait($hRNotepad)
ControlSend($hRNotepad, "", "", "ControlSend Right Notepad N0. 1.{ENTER}")
WinWait($hRNotepad)
Send("{ENTER}")
ControlSend($hRNotepad, "", "", "ControlSend Right Notepad No 2.{ENTER}")

WinActivate($hLNotepad)
WinWait($hLNotepad)
Send("^{END}{ENTER}")
ControlSend($hLNotepad, "", "", "ControlSend left Notepad 2nd Entry A{ENTER}B")
WinWait($hLNotepad)

WinActivate($hRNotepad)
WinWait($hRNotepad)
Send("{ENTER}")
ClipPut("ClipPut Right Notepad.")
_SendMessage($hRNotepad, $WM_COMMAND, $WM_PASTE, 0) ; $WM_PASTE, 0)
Send("{ENTER}")

WinActivate($hLNotepad)
WinWait($hLNotepad)
Send("{ENTER}")
ControlSend($hLNotepad, "", "", "Last ControlSend Left Notepad ")
WinWait($hLNotepad)
Send("^{END}{ENTER}")
WinWait($hLNotepad)
ClipPut("ClipPut left Notepad.")
Send("^v")
Link to comment
Share on other sites

@trinitrotoluen

I dont see other way to do that :

For $i = 1 To 4
    Run("notepad.exe")
Next

For $i = 1 To 4
    Sleep(250)
    WinActivate("[CLASS:Notepad]", '')
    WinWaitActive("[CLASS:Notepad]", '', 3)
    Send("Notepad " & $i)
    WinSetState("[CLASS:Notepad]", '', @SW_MINIMIZE)
Next

Sleep(3000)
For $i = 1 To 4
    Sleep(300)
    ProcessClose("notepad.exe")
Next

Cheers, FireFox.

Link to comment
Share on other sites

@FireFox

Not possible...

Are you sure? :o i once also thought that many thing are not possible with AutoIt, but i was so wrong :)

Check this example.

Edited by MrCreatoR

 

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

@MrCreatoR

At the same time is at the same time... you have min 1ms between 2 function so its impossible :D

Cheers, FireFox.

You have a (bad?) habit to "judge" scripts only by looking at them on the surface :D - Please, check first the concept/idea that someone trying to show/pass, before you say how stuff works in other's scripts :o ...

And actualy i have there 10 ms delay :D, but i could remove the sleep completely (with a "price" of CPU load), and it's not the point here... the concept here is quit simple: First we executing few scripts that waiting for the main Edit (of the "parent" GUI) to have specific data (in our case it is a Notepad Instances = 5), and when the last notepad process is executed, this data is set and then all scripts will "fire" (send) some string to the notepad that was preserved (by title) for this current script - so the bottom line here is that the strings are sent in the same time (for the human eye anyway, i don't think that we need here an atomic precision :) ).

 

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

@MrCreatoR

You have a (bad?) habit to "judge" scripts only by looking at them on the surface wink.gif - Please, check first the concept/idea that someone trying to show/pass, before you say how stuff works in other's scripts :D ...

You're Right... :)

And actualy i have there 10 ms delay :D

Edit : I am not totally right :(

(for the human eye anyway, i don't think that we need here an atomic precision :o )

of course but I understand that by "the same time" :D

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

@FireFox

I am right

Nope, you talking about a delay between functions in the same script, and in my example it's not the case... but it's not really matter, as someone said once :o : “Be smart, not right” :) ... or something like this.

P.S

Sorry for the offtopic.

 

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

In all reality, it's theoretically impossible to do more than one thing at once, because the processor deals with things round-robin style, therefore two things can never be done at the same time.. unless you're working with multiple processors.. ;D

Global $arr[2]

$arr[0]="hip"
$arr[1]="hip"
;^^ hip hip array. ^^
Link to comment
Share on other sites

Hi,

Is there an possible option to open 2 notepad windows beside each other and switch between them...

Detailed Idea:

Script opens 2 notepad windows, 1 on the left of the screen and one on the right.

Script activates the first window, types some text.

Script activates second window, types some text.

etc.

Any Ideas, or simple scripts? I'm not really good with AutoIt!!

Tnx! :)

Like this perhaps:

;============= Open Notepads part =============
$iPID1 = Run(@WindowsDir & "\Notepad.exe")
$hNotepad1 = _WinWaitByPID($iPID1)

WinMove($hNotepad1, "", 0, 0, 300, @DesktopHeight-30)

$iPID2 = Run(@WindowsDir & "\Notepad.exe")
$hNotepad2 = _WinWaitByPID($iPID2)
;============= Open Notepads part =============


;============= Set text part =============
WinMove($hNotepad2, "", @DesktopWidth-300, 0, 300, @DesktopHeight-30)

WinActivate($hNotepad1)
ControlSetText($hNotepad1, "", "Edit1", "Notepad Test 1")

WinActivate($hNotepad2)
ControlSetText($hNotepad2, "", "Edit1", "Notepad Test 2")
;============= Set text part =============

Func _WinWaitByPID($iPID, $iWaitTime=-1)
    Local $iTimer = TimerInit()
    Local $aWinList
    
    While 1
        $aWinList = WinList()
        
        For $i = 1 To $aWinList[0][0]
            If WinGetProcess($aWinList[$i][1]) = $iPID Then Return $aWinList[$i][1]
        Next
        
        If $iWaitTime > 0 And TimerDiff($iTimer) >= $iWaitTime * 1000 Then ExitLoop
    WEnd
    
    Return 0
EndFunc

?

:o

 

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