Jump to content

Is controlsend bugged?


Recommended Posts

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.

Link to comment
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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

 

Link to comment
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.

Link to comment
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

 

Link to comment
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

Link to comment
Share on other sites

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

 

Link to comment
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

 

Link to comment
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

 

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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
Link to comment
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

 

Link to comment
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.
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...