Jump to content

Send text to all instances/change window name?


Recommended Posts

Lets say I have 5 notepads open, is there a way to make it send a string of text to each window (no specific order or anything and same message)

I can't seem to get it to work correct, any suggestions?

EDIT: If I open 5 notepads 1 by 1 is it possible to get a script going to rename the window from Notepad to Onei and other windows to: Twoi, Threei, Fouri, and Fivei

This would be better for me then I dont need to worry about the sentence above..

EDIT: Why is search coming up with no results, i am unable to search for info..

Edited by XxXGoD
Link to comment
Share on other sites

EDIT: If I open 5 notepads 1 by 1 is it possible to get a script going to rename the window from Notepad to Onei and other windows to: Twoi, Threei, Fouri, and Fivei

This would be better for me then I dont need to worry about the sentence above..

Didn't see your edit...

Put "One", "Two", "Three", etc... in an array and use WinSetTitle instead of ControlSetText.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

Whats Edit1 for, other than that I understand it :D

Hmm, not as hard as i thought

Edit1 is Notepad's main control. Use the AutoIt Window Info tool to identify the controls you want to interact with.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

$text="some text"

$x=1

While WinExists("[CLASS:Notepad; INSTANCE:"& $x &"]")

ControlSetText("[CLASS:Notepad; INSTANCE:"& $x &"]","","[CLASS:Edit; INSTANCE:1]",$text)

$x+=1

WEnd

Exit

EDIT: ahh, well beaten , lol

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

Jack you know there are autoit code tags

[autoit][/autoit]

Im slightly confused in what you mean, also why is jack using While?

Basically here is what I have to do manually and what I need automatic..

Load 5 up windows (Manual)

Change the window names (makes it easier for me)

Use: $PST19334 as the send... ($PST19334="Not putting real text here lol") (Maybe a hotkey of right alt..)

Press Enter once on all 5 windows

Link to comment
Share on other sites

yea yea, it was such a short script i didn't bother , (maybe 1 to 5 lines i quite often dont)

the while is a cycle that will send the string to each notepad window one at a time until there are no more notepad windows open.

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

yea yea, it was such a short script i didn't bother , (maybe 1 to 5 lines i quite often dont)

the while is a cycle that will send the string to each notepad window one at a time until there are no more notepad windows open.

I only want the string sent once, and It would be handy if all at once without having to switch windows..

Link to comment
Share on other sites

it wont actually switch or activate windows just put the text into the Edit controls of each Notepad window, it will paste the text even if the Notepad windows are minimised.

EDIT: didn't see you have edited you request to "rename the window from Notepad"

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

$text="some text"
$x=1
While WinExists("[CLASS:Notepad; INSTANCE:"& $x &"]")
ControlSetText("[CLASS:Notepad; INSTANCE:"& $x &"]","","[CLASSNN:Edit1]",$text)
WinSetTitle("[CLASS:Notepad; INSTANCE:"& $x &"]","","Number - "& $x)
$x+=1
WEnd
Exit

will change the windows names as well as set the text within them.

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

Doesn't work...

Im not sure how to change from ControlSetText to just ControlSend or Send 1 by 1 each window

So Window 1, send

Select Window 2, wait 50ms, send

Select Window 3... etc

>>>> Window <<<<

Title: PCS

Class: GxWindowClassD3d

Position: 0, 0

Size: 1680, 1050

Style: 0x160B0000

ExStyle: 0x00040000

Handle: 0x000000000003043C

>>>> Control <<<<

Class:

Instance:

ClassnameNN:

Advanced (Class):

ID:

Text:

Position:

Size:

ControlClick Coords:

Style:

ExStyle:

Handle: 0x00000000000100D8

>>>> Mouse <<<<

Position: 1188, 240

Cursor ID: 0

Color: 0x000000

>>>> StatusBar <<<<

>>>> Visible Text <<<<

>>>> Hidden Text <<<<

Link to comment
Share on other sites

Notepad_send("some text 1",1)
Sleep(1000); wait 50ms , not sure why but there you go :)
Notepad_send("some more text 2ddd",2)
Exit

Func Notepad_send($string = "", $instance = 1)
    If WinExists("[CLASS:Notepad; INSTANCE:" & $instance & "]") Then
        ControlSend("[CLASS:Notepad; INSTANCE:" & $instance & "]", "", "[CLASSNN:Edit1]", $string)
        WinSetTitle("[CLASS:Notepad; INSTANCE:" & $instance & "]", "", "Number - " & $instance)
    EndIf
EndFunc;==>Notepad_send

well what about this way, make a function and just call it for each window.

EDIT: changed the ControlSetText to ControlSend (maybe your trying to add text to text thats already there)

EDIT: minor mistake , soz (fixed now)

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

Hmm Nearly got it...

By the way the programs called PCS not Notepad, i was using it as an example.

It doesn't function how I need it to I just tried to change bits but it comes up with errors for me :D

Let me re-explain:

I load 5 programs 1 by 1, The first one to load I need that changed window name from PCS to Onei

Second one I load needs to be changed to Twoi and so on... (PCS can take upto 30 seconds per window to load)

Once all are loaded, I want to use I want it to enter the text (one string) but I want to have to initiate this part using:

HotKeySet("{ALT}}", "WriteNotePST19334")
and after sending for it to Exit.

Note: When switching windows or trying to send to other windows the 50ms is there to prevent the program from sending incorrectly as the program lags a tad.

Edited by XxXGoD
Link to comment
Share on other sites

hmm, well this might work as long as you are starting with no "notepad" windows open to start with, as you open each new window it will rename it, then when your finished opening as many windows as you want if your hit "enter" it will fill ALL of them with the $text

(im guna assume you can transcribe my use of notepad to your PCS)

HotKeySet("{ENTER}", "send_text")
Global $window_count = 1
Global $text = "some text"
While 1
    Sleep(200)
    If WinExists("Untitled - Notepad") Then
        Notepad_change_title($window_count)
        $window_count += 1
    EndIf
WEnd

Func Notepad_change_title($instance = 1)
    WinSetTitle("[CLASS:Notepad; INSTANCE:1]", "", "Number - " & $instance)
EndFunc  ;==>Notepad_change_title

Func send_text()
    $x = 1
    While WinExists("[CLASS:Notepad; INSTANCE:" & $x & "]")
        ControlSend("[CLASS:Notepad; INSTANCE:" & $x & "]", "", "[CLASSNN:Edit1]", $text)
        $x += 1
    WEnd
    Exit
EndFunc  ;==>send_text

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

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