Walrus Posted March 23, 2015 Share Posted March 23, 2015 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 More sharing options...
JohnOne Posted March 23, 2015 Share Posted March 23, 2015 You have other problems. The above code will cause no such issues. For a start, it exits after about 20 milliseconds. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
MikahS Posted March 23, 2015 Share Posted March 23, 2015 Sounds like you have it in a loop. Post code? Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy 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 More sharing options...
Walrus Posted March 23, 2015 Author Share Posted March 23, 2015 (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 March 23, 2015 by Walrus Link to comment Share on other sites More sharing options...
MikahS Posted March 23, 2015 Share Posted March 23, 2015 (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 March 23, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy 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 More sharing options...
Walrus Posted March 23, 2015 Author Share Posted March 23, 2015 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 More sharing options...
MikahS Posted March 23, 2015 Share Posted March 23, 2015 Ah, my apologies for not understanding. Try: ControlSend("[CLASS:Notepad]", "", "[CLASS:Edit]", "D") Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy 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 More sharing options...
SorryButImaNewbie Posted March 23, 2015 Share Posted March 23, 2015 Wouldn't this code send D's and spaces all the time? Why would it wait for 3 minutes to send them to firefox? Link to comment Share on other sites More sharing options...
JohnOne Posted March 23, 2015 Share Posted March 23, 2015 One reason could be that firefox is at a webpage with notepad in the title. It might be doubtful though, more likely that not specifying the control was the issue. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Walrus Posted March 23, 2015 Author Share Posted March 23, 2015 @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 More sharing options...
MikahS Posted March 23, 2015 Share Posted March 23, 2015 (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: Edited March 23, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy 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 More sharing options...
Walrus Posted March 23, 2015 Author Share Posted March 23, 2015 @MikahS So, probably my au3 window info is bugged, becuse in group "Basic control info" I'm having nothing to see. Link to comment Share on other sites More sharing options...
MikahS Posted March 23, 2015 Share Posted March 23, 2015 It's probably because you are hovering on the title bar, instead of inside the actual notepad edit control. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy 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 More sharing options...
Walrus Posted March 23, 2015 Author Share Posted March 23, 2015 Ok, I updated my au3 and it is working for notepad, but for example it isn't working for Firefox, MS Word etc, why? Link to comment Share on other sites More sharing options...
MikahS Posted March 23, 2015 Share Posted March 23, 2015 Post your code, as I don't think I quite understand what you are asking. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy 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 More sharing options...
jdelaney Posted March 23, 2015 Share Posted March 23, 2015 (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 March 23, 2015 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 More sharing options...
Walrus Posted March 23, 2015 Author Share Posted March 23, 2015 (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 March 23, 2015 by Walrus Link to comment Share on other sites More sharing options...
MikahS Posted March 23, 2015 Share Posted March 23, 2015 jdelaney said it best. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy 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 More sharing options...
jdelaney Posted March 23, 2015 Share Posted March 23, 2015 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 More sharing options...
JohnOne Posted March 23, 2015 Share Posted March 23, 2015 Ff was only example. Lets stop farting about then, and tell us the actual program you are dealing with. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now