Sign in to follow this  
Followers 0
Walrus

Is controlsend bugged?

26 posts in this topic

Hi, I'm having problem with script in au3. For example when I run code like this below:

ControlSend("Notepad", "", "", "D")

it is working, but after 3 minutes it is sending "D" everywhere, to Firefox, wordpad etc. When i press "Shift/ctrl/alt" my keyboard is getting bug, and it doing some crazy things.

Thanks for help, sorry for my english.

Walrus.

Share this post


Link to post
Share on other sites



Sounds like you have it in a loop. Post code?


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I just copied one of 100 lines, I'm having loops, gui etc. This isn't the problem (probably)

@UP Ok, example code:

$notepad = "Notepad"
While 1
ControlSend($notepad, "", "", "D")
Sleep(100)
ControlSend($notepad, "", "", " ")
Sleep(100)
ControlSend($notepad, "", "", "?")
WEnd

I tested it, and for example after 5 minutes script is pressing space in Firefox.

Edited by Walrus

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

That while loop will make it run continuously unless you put in a condition for stopping.

Something like a

HotKeySet("{ESC}", "Quit") ; press escape and it will run the Quit function
 
Func Quit()
    Exit ; get out of the script for good
EndFunc

will let you exit whenever you are done with using the controlsend. 

:)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Yes, i know it, but i want putting chars in notepad for 1h (example), and when script is running I want writing post here, but i can't do it, because program is sending "D " " and "?" to Firefox(my browser) too.

Share this post


Link to post
Share on other sites

Ah, my apologies for not understanding.

Try:

ControlSend("[CLASS:Notepad]", "", "[CLASS:Edit]", "D")

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Wouldn't this code send D's and spaces all the time? Why would it wait for 3 minutes to send them to firefox?

Share this post


Link to post
Share on other sites

@MikahS

Hmm, thank you! Probably working fine, but i have next ask, why your first parametr is "Class[Notepad]" (i mean why it isn't Untitled - Notepad), and why your third parametr is [Class:Edit], where you found it? Autoit Window Info is telling that notepad is in [Class:Instance]

@SorryButImaNewbie

I don't know that's the reason why I asked

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

No problem. The first parameter is the window's class (don't know if title will always stay "Untitled - Notepad) and the third parameter is the Control class. I have included a picture to go along with:

post-86910-0-49460500-1427122364_thumb.p

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

@MikahS

So, probably my au3 window info is bugged, becuse in group "Basic control info" I'm having nothing to see. :(

Share this post


Link to post
Share on other sites

It's probably because you are hovering on the title bar, instead of inside the actual notepad edit control. :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Ok, I updated my au3 and it is working for notepad, but for example it isn't working for Firefox, MS Word etc, why?

Share this post


Link to post
Share on other sites

Post your code, as I don't think I quite understand what you are asking.  :geek:


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

There are DOM objects on your two other applications....you must interact with those via COM, and not controlsend.  ControlSend will be unreliable...

Got to the examples forum, and download the firefox udf (ff.au3).  Or, just use the Internet Explorer functions, which come native:

_IEAttach

Word, you can use functions like (look them all up in the help file):

_WordCreate

Also, controlsend is unreliable anyways, use this when you can (you will not be able to use this reliably on word or firefox either)

ControlSetText

Example:

Run("notepad.exe")
$h = WinWait("[CLASS:Notepad]")
Sleep(150)
$c = ControlGetHandle($h,"",15)

ControlSetText($h,"",$c,"Adding some text to notepad.")
Sleep(1000)
ControlSetText($h,"",$c,ControlGetText($h,"",$c) & @CRLF & "Adding MORE text to notepad.")
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.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Ok. I'm having Autoit v3 Window Info. But in programs like firefox the 'Basic Control Info' is empty. Why?

BtW. Try run this Code:

While 1
ControlSend("Untitled - Notepad", "", "[CLASSNN:Edit1]", "This is some text")
Sleep(500)
WEnd

Wait 1min, go to notepad++(for example) and press A "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAaaaaaaaaaaaaaaaaaaaaAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAaaaaaaaaaaaaaaaa" why I'm sometimes getting big letter?

@UP

Ff was only example.

Edited by Walrus

Share this post


Link to post
Share on other sites

jdelaney said it best. :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

You will almost never get exactly what you want with controlsend...Something else might take focus, the application may not pick up the key sends, its the wrong way to go.  I think the helpfile for that function should re-direct to controlsettext in 95% of cases.


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.

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