Jump to content

Controlsend to many windows with the same title


Gadoz
 Share

Recommended Posts

Hello,

I've already tried myself to create a autoit script, which can send through controlsend keys (like Shift + S for save) or (just pressing Spacebar).

The problem is, I can't send keys in the background special to this window. Because I have open this editor to work on it and this script should doing this steps on the background, while I can work on the same editor on a new document. If I have opened this script, this script is just pressing shift + s or just pressing the spacebar till I paused this. On a another editor, I need to send "." after every 30 seconds and save it (with shift+s) .

I've already tried this with handle ($handle):

https://stackoverflow.com/questions/14783920/autoit-controlsend

 

This worked only to active windows and I also put the handle id (autoit windows info tool) between the gaps, but its not working.

I'm just wondering, why this won't work, because if $handle is working on a active window, this should working on active window aswell?

HotKeySet("{S}", "Starting")
HotKeySet("{P}", "Paused")
HotKeySet("{ESC}", "Exit")

While 1
Sleep(300)
WEnd

Func Starting ()
While 1
ControlSend(0x00000000001111FE, Default, 0x00000000001111FE, "{SPACE}")
ControlSend(0x00000000001110EF, Default, 0x00000000001110EF, "{.}")
WEnd
EndFunc

Func Paused ()
While 1
Sleep(10)
WEnd
EndFunc

Func Exit ()
Exit
EndFunc

 

I hope, someone can understand and help me.

Link to comment
Share on other sites

  • Moderators

@Gadoz welcome to the forum. First and foremost, what type of window are you dealing with? And why do you need to have so many of them? The more info you can provide the better suited we are to assist. Screenshots of the window(s) and the field where you're trying to send the text or space would be helpful as well.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hey!

It's just a editor like notepad, which is used on my job. This editor is developed by our IT.

It's compared with the notepad.exe with some additional extras, so if someone can help me, you can demonstrate it with notepad.exe.

Every notepad.exe has different PID, different handle.

We are don't using autoit yet, but for a new project, we need a tool/script, which can save and sending "spacebars" and dots every 30 seconds in a 2-3 documents on our editor. A databank is loading this .txt file every after 30 seconds and put it on a form.

We are spending so much time to do this manual, a script will saves a lot of time...

 

I'm sorry, If I can't write more, because I'm working in a data protection area and any names / screenshots aren't allowed..

 

 

Link to comment
Share on other sites

WinList returns an array, loop through that.  Use CLASS as the identifier, or something else that's common between each window.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

7 minutes ago, jdelaney said:

WinList returns an array, loop through that.  Use CLASS as the identifier, or something else that's common between each window.

I have checked the editor, every editor has the same CLASS (NEFeditorh)

Link to comment
Share on other sites

  • Moderators

So there you go, look at the helpfile for WinList, as jdelaney suggests. You can use the classname to narrow your search.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

On 5.12.2017 at 9:18 PM, Gadoz said:

Alright, I will try and post my result. Thanks.

First of all, I want try to send just spaces, till this script is paused, to test if this works.

HotKeySet("{S}", "Starting")
HotKeySet("{P}", "Paused")
HotKeySet("{ESC}", "Exit")

While 1
Sleep(300)
WEnd


Func Starting ()
While 1
   $handle = 0x000000000007126F ;handle ID from from this editor window, every new window of this editor has a unique handle ID (autoit v3 window tool)
   $handle2 = 0x0000000000060170
ControlSend($handle, Default, $handle, "{SPACE}")
ControlSend($handle2, Default, $handle2, "{.}")
WEnd
EndFunc

Func Paused ()
While 1
Sleep(10)
WEnd
EndFunc

Func Exit ()
Exit
EndFunc

 

On 5.12.2017 at 9:03 PM, jdelaney said:

WinList returns an array, loop through that.  Use CLASS as the identifier, or something else that's common between each window.

 

#RequireAdmin

HotKeySet("{S}", "Starting")
HotKeySet("{P}", "Paused")
HotKeySet("{ESC}", "Exit")

While 1
Sleep(300)
WEnd



Func Starting ()
   Func array()
   while 1
    
    Local $aList = WinList()

    
    For $i = 1 To $aList[0][0]
        If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
           ControlSend($aList, Default, $aList, "{SPACE}")
        EndIf
    Next
EndFunc   ;==>Example
While 1


WEnd
EndFunc

Func Paused ()
While 1
Sleep(10)
WEnd
EndFunc

Func Exit ()
Exit
EndFunc

This doesn't work aswell.

Link to comment
Share on other sites

  • Developers

I am not so surprised these scripts don't work.
For starters: Install the full version of SciTE4AutoIt3 which will run au3check for you telling you about all syntax errors.
Fix those errors and while you are at it: what is your idea around using all these While 1 loops?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I've installed SciTE4AutoIt3  but where I can see, that I have a syntax error?

 

Oh, the first while can be removed,

 

the other while after array (for the loop) as jdelaney mentioned .

 

I just don't understand this file.

Is here a marketplace, where I can post a order, that someone can do it for me, for some $?

I just don't want waste time anymore, since we will working only for one month to this project.

Link to comment
Share on other sites

  • Developers
1 minute ago, Gadoz said:

I've installed SciTE4AutoIt3  but where I can see, that I have a syntax error?

 

have you run the script from scite?
All information will show in the bottom part of the screen.

Jos

2 minutes ago, Gadoz said:

I just don't understand this file.

Is here a marketplace, where I can post a order, that someone can do it for me, for some $?

I just don't want waste time anymore, since we will working only for one month to this project.

Not in these forums.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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