Jump to content
Sign in to follow this  
b0x4it

ControlSend Problem

Recommended Posts

b0x4it

anybody knows why the first code works and the second code not:

ControlSend("Untitled - Notepad", "", "", "!+{F4}") ; when I run this, it kill the windows where I am running the au3 file.

ControlSend("SyncBackPro", "", "", "!+x") ; but this one works perfectly even for this application that is minimized in systray

why please?

and why this does not work?!!

ControlSend("SyncBack", "", "", "!+x")

does the title needs to have special number of characters? (even "SyncBackPro" is not the whole title, but it works!)

thanks

Share this post


Link to post
Share on other sites
wolf9228

HotKeySet("{F1}", "_SendText")
HotKeySet("{F2}", "_SendKey")
HotKeySet("{ESC}", "Terminate")

While 1
Sleep(150)
WEnd

Func _SendText()
Run("notepad")
WinWait("[CLASS:Notepad]")
Send("!st.+9pI`VR@2",1)
EndFunc

Func _SendKey()
Run("notepad")
WinWait("[CLASS:Notepad]")
Send("{ALTDOWN}",0)
Send("f",1)
Send("{ALTUP}",0)
Send("{CTRLDOWN}",0)
Send("o",1)
Send("{CTRLUP}",0)
EndFunc

Func Terminate()
    Exit 0
EndFunc


صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites
b0x4it

In neither case are you passing a paramater for the control to the function.

That could certainly be the problem.

thanks for the reply. I don't get what exactly you mean. Would you please correct my code?

Share this post


Link to post
Share on other sites
b0x4it

HotKeySet("{F1}", "_SendText")
HotKeySet("{F2}", "_SendKey")
HotKeySet("{ESC}", "Terminate")

While 1
Sleep(150)
WEnd

Func _SendText()
Run("notepad")
WinWait("[CLASS:Notepad]")
Send("!st.+9pI`VR@2",1)
EndFunc

Func _SendKey()
Run("notepad")
WinWait("[CLASS:Notepad]")
Send("{ALTDOWN}",0)
Send("f",1)
Send("{ALTUP}",0)
Send("{CTRLDOWN}",0)
Send("o",1)
Send("{CTRLUP}",0)
EndFunc

Func Terminate()
    Exit 0
EndFunc

thanks for the reply. but this is not related to ControlSend!

Share this post


Link to post
Share on other sites
somdcomputerguy

does the title needs to have special number of characters? (even "SyncBackPro" is not the whole title, but it works!)

Is 'SyncBackPro' a complete word of the partial title? IOW, is the complete title something like 'SyncBackPro - Running'? The complete title I'm asking about here is just an example, note the 'something like' part..


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
JohnOne

thanks for the reply. I don't get what exactly you mean. Would you please correct my code?

Un fortunately, I cannot as I dont have the application.

ControlSend("Untitled - Notepad", "", "", "!+{F4}")

The paramater highlighted should contain a control ID, see the helpfile for controlsend()

If that param is left blank. then autoit is basically guessing where to send, and it will have uncontrolled affect.

Use autoit window info tool to try and get a control ID.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
somdcomputerguy

I use ControlSend without a control id in a script that I run all the time. I am under the impression that without a control id specified, it just controlsends to the specified 'main window'. It may be that it works for me the way it does only for the specific application I do this for, I haven't tried (or used) it this way with any other application.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
b0x4it

Is 'SyncBackPro' a complete word of the partial title? IOW, is the complete title something like 'SyncBackPro - Running'? The complete title I'm asking about here is just an example, note the 'something like' part..

The whole title is "SyncBackPro V5.11.3.0". When I use "SyncBackPro", it works, but when I put "SyncBack" it doesn't, Why? I am trying to find out the logic behind it!

Thank you!

Share this post


Link to post
Share on other sites
somdcomputerguy

TitleMatchMode doesn't match parts of words in a title. SyncBack and SyncBackPro are two different words. See the Helpfile for more description/explanation. edit: nevermind, I was wrong in this statement..<br>

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
Jos

The whole title is "SyncBackPro V5.11.3.0". When I use "SyncBackPro", it works, but when I put "SyncBack" it doesn't, Why? I am trying to find out the logic behind it!

Maybe there are more windows that start with "SyncBack"?

..but what is the problem when "SyncBackPro" works?


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

Share this post


Link to post
Share on other sites
b0x4it

TitleMatchMode doesn't match parts of words in a title. SyncBack and SyncBackPro are two different words. See the Helpfile for more description/explanation.

Yes, that was the problem. Thank you so much!

Share this post


Link to post
Share on other sites
somdcomputerguy

You bet. Good luck with your endeavor.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
eyc

Yes, that was the problem. Thank you so much!

that's wierd. the help file seems to suggest that "SyncBack" should also work. the following is an excerpt from the "Window Titles and Text (Advanced)" section of the help file:

Mode 1 (default)

Matches partial titles from the start.

In this mode the a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Un", etc.

is this a bug?

Share this post


Link to post
Share on other sites
b0x4it

that's wierd. the help file seems to suggest that "SyncBack" should also work. the following is an excerpt from the "Window Titles and Text (Advanced)" section of the help file:

Mode 1 (default)

Matches partial titles from the start.

In this mode the a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Un", etc.

is this a bug?

if you want to use "Untitled - Notepad", "Untitled", "Un" then you have to use Mode 2 (SubStr). Of course in Mode 1 you can use all "Untitled - Note", "Untitled - N", or "Untitle". So in the default Mode 1, both "SyncBackPro V5.11.3.0" and "SyncBack" should work, but "SyncBack" doesn't which is strange!

Share this post


Link to post
Share on other sites
Jos

if you want to use "Untitled - Notepad", "Untitled", "Un" then you have to use Mode 2 (SubStr). Of course in Mode 1 you can use all "Untitled - Note", "Untitled - N", or "Untitle". So in the default Mode 1, both "SyncBackPro V5.11.3.0" and "SyncBack" should work, but "SyncBack" doesn't which is strange!

So, let me try again: Maybe you have another window that starts with "SyncBack"?

These both work fine for me with Notepad:

ControlSend("Untitled", "", "Edit1", "This is a line of text in the notepad window")
ControlSend("Untit", "", "Edit1", "This is a line of text in the notepad window")

Jos


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

Share this post


Link to post
Share on other sites
b0x4it

So, let me try again: Maybe you have another window that starts with "SyncBack"?

These both work fine for me with Notepad:

ControlSend("Untitled", "", "Edit1", "This is a line of text in the notepad window")
ControlSend("Untit", "", "Edit1", "This is a line of text in the notepad window")

Jos

Thanks Jos for your replies,

There is no windows with similar title, but there is one in the list of processes. When I put the title completely it works! so I reckon that's the problem, isn't it?

Share this post


Link to post
Share on other sites
Jos

There is no windows with similar title, but there is one in the list of processes. When I put the title completely it works! so I reckon that's the problem, isn't it?

No, not really.

An easy way to check all window titles is to run something like this:

$var = WinList()
For $i = 1 to $var[0][0]
  If Stringleft($var[$i][0], 8)= "SyncBack" Then
    ConsoleWrite("Title=" & $var[$i][0] & "    Handle=" & $var[$i][1] & @CRLF)
  EndIf
Next

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

Share this post


Link to post
Share on other sites
b0x4it

No, not really.

An easy way to check all window titles is to run something like this:

$var = WinList()
For $i = 1 to $var[0][0]
  If Stringleft($var[$i][0], 8)= "SyncBack" Then
    ConsoleWrite("Title=" & $var[$i][0] & "    Handle=" & $var[$i][1] & @CRLF)
  EndIf
Next

Thanks Jos for the code,

Interestingly, it finds two windows with exact title but different handles, and I do not understand why?!

Share this post


Link to post
Share on other sites
monoscout999

some applications have that behavior. for example MyPony do that, if i use the AutoIt window info tool on it, i see one window, but if i try to grab the controls inside that window i get an error, to get the correct controls i must specify the instance 2 of the main window, there are the controls.

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  

×