UnknownWarrior Posted September 12, 2012 Share Posted September 12, 2012 The reason I say 'Automating Calculator' is because it's something we can all relate to and provide insight on. I've searched everywhere and beyond for ANY examples of simply automating a program and came up with nothing at all - except the traditional ControlClick stuff. So, from my research, I came up with three methods of automating a program, but I'm not sure which one is really the most efficient (and in my case, the most easiest). If anyone could provide me with some insight on which one I should use and maybe a small example of it applied to Calculator, that would be tremendously appreciated! Obviously the program I'm trying to automate isn't calculator (it's a data-mining program that lacks a scheduler... so I'm making one for my friend), but the theories will be the same. Something like: Help > View Help (in Calculator) 1 + 2 = (and maybe even grab the result via the result box in Calculator?) From what I understand, I'll need to first record, or 'listen', to these events as I do them. Then simply reproduce them by sending them back into the program via one of these methods: 1. COM Object Automation -- Researched this and the only thing I don't quite understand would be how to get the Object of all sorts of buttons on my program? 2. Win API -- Didn't look too much into this, but I think this is another solution to automate any windows program? 3. Injecting DLL/Hooking -- This seemed the most promising - but also the most difficult. I understood slightly what was going on in the HelpFile, but I didn't really understand how to send my own events as if the program were doing it. Also, I don't think AutoIt can create dlls and I don't know how to make one. Thanks for any help! Link to comment Share on other sites More sharing options...
UnknownWarrior Posted September 13, 2012 Author Share Posted September 13, 2012 bump Link to comment Share on other sites More sharing options...
Kidney Posted September 14, 2012 Share Posted September 14, 2012 this will add 12 + 3 = 15 step by step Run("Calc.exe") WinWaitActive("Calculator") WinActive("Calculator") Sleeper() ControlClick("Calculator", "", "Button5", "Left") ;Click the number 1 Sleeper() ControlClick("Calculator", "", "Button11", "Left") ;Click the number 2 Sleeper() ControlClick("Calculator", "", "Button23", "Left") ;Click the + button Sleeper() ControlClick("Calculator", "", "Button16", "Left") ;Click the number 3 Sleeper() ControlClick("Calculator", "", "Button28", "Left") ;Click the Equal button Func Sleeper() Sleep(1000) EndFunc Link to comment Share on other sites More sharing options...
UnknownWarrior Posted September 14, 2012 Author Share Posted September 14, 2012 Thanks, but I asked for a way to do it without using any kind of clicking . Anyone else? Or is this too difficult to do in AutoIt? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 14, 2012 Moderators Share Posted September 14, 2012 Thanks, but I asked for a way to do it without using any kind of clicking .Anyone else? Or is this too difficult to do in AutoIt?It's a little unclear what you are trying to accomplish. A GUI, like Calculator, is there for a user to interact with - otherwise you would just do the math in AutoIt and return the values. It sounds like you want to do something the user can interact with, but without "any kind of clicking", how do you envision them interacting with the program? Just trying to get a better sense of what you're trying to accomplish. "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 More sharing options...
UnknownWarrior Posted September 14, 2012 Author Share Posted September 14, 2012 It's a little unclear what you are trying to accomplish. A GUI, like Calculator, is there for a user to interact with - otherwise you would just do the math in AutoIt and return the values. It sounds like you want to do something the user can interact with, but without "any kind of clicking", how do you envision them interacting with the program? Just trying to get a better sense of what you're trying to accomplish.Let's say I have a function in AutoIt to do this:Func clicker()MouseClick("Left", 100, 100)EndFuncI want to be able to send that function via my program as if that function were actually called itself. Of course, the program I'm trying to automate is not AutoIt.In Calculator I would assume it looks something like this:If $button1 = pressed Thendisplay "1"endifI want to 'send' (by whatever method) that $button1 was pressed... without actually clicking on it.I think another form to explain it would be "sending packets" with certain software.Hard to explain, let me know if that cleared some things up Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted September 14, 2012 Share Posted September 14, 2012 Have you tried the window info tool? Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
UnknownWarrior Posted September 14, 2012 Author Share Posted September 14, 2012 Yes. I have a major dilemna with ControlClick (besides not being able to find a few controls)... For whatever reason, it will randomly not click a certain button. Save I have 5 different buttons. Sometimes it won't click button 1, next time it won't click button 2 but it will click button 1... it's really screwy . I even tried ControlFocus with no luck. Link to comment Share on other sites More sharing options...
trancexx Posted September 14, 2012 Share Posted September 14, 2012 ControlClick posts message in the message queue of your window. It does exactly what you want it to do.If it doesn't work correctly then maybe you are doing something wrong. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
UnknownWarrior Posted September 15, 2012 Author Share Posted September 15, 2012 (edited) ControlClick posts message in the message queue of your window. It does exactly what you want it to do.If it doesn't work correctly then maybe you are doing something wrong.I hate to sound offensive, but there isn't anything to mess up -- and it proves that when it works 'sometimes' with certain buttons and sometimes not.What I've noticed it doing is it presses down the button and releases the button, but for whatever reason it doesn't register it sometimes.I've tried with and without ControlFocus before using it (with Focus it seemed to do even worse).I did find this: Which, in some of my cases is true (I'm trying to open a file). But in other cases, they are just plain Windows' message boxes.That's why I'm trying to turn to automating it with hooks/etc, seems it would be more reliable :/.Edit: I do want to note that the windows that it fails on are child windows that aren't actually 'New Windows' at all - but just a window message inside of the main program. I can however still get the ControlId/etc of everything on the window. Edited September 15, 2012 by UnknownWarrior Link to comment Share on other sites More sharing options...
JohnOne Posted September 15, 2012 Share Posted September 15, 2012 Why don't you go ahead and show us the code you tried for 1. COM Object Automation-- Researched this and the only thing I don't quite understand would be how to get the Object of all sorts of buttons on my program?Perhaps someone might be able to help you with that. 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...
UnknownWarrior Posted September 15, 2012 Author Share Posted September 15, 2012 I didn't try it because I knew I needed the object - which I can't seem to figure out how I would extract it from any window Link to comment Share on other sites More sharing options...
Kidney Posted September 15, 2012 Share Posted September 15, 2012 notice how i put sleep timers in between the controlclicks? since calculator is so lightweight, the controlclicks happen almost instantly. however, if you are trying to do controlclicks on something a little heavier, then autoIT could be sending the clicks too fast for the program you are actually trying to automate. Link to comment Share on other sites More sharing options...
UnknownWarrior Posted September 15, 2012 Author Share Posted September 15, 2012 I put an entire second between each ControlClick happening... I guess I can try adding more, but that's going to make the program hella slow (2 seconds every click for about 200 clicks). Link to comment Share on other sites More sharing options...
Kidney Posted September 15, 2012 Share Posted September 15, 2012 I put an entire second between each ControlClick happening... I guess I can try adding more, but that's going to make the program hella slow (2 seconds every click for about 200 clicks).well its gonna take just as long any other way. if the program you r trying to automate is slow itself, then the automation will be slow as well. Link to comment Share on other sites More sharing options...
UnknownWarrior Posted September 15, 2012 Author Share Posted September 15, 2012 That's the thing though, I have a WinWait for the window to be active, I wait .3 seconds, then send the click. So, there should be no excuse for it not registering that click :/. (It DOES click it, it just doesn't register it... it's like a human holding down a button and dragging the mouse off of the button and letting go) Link to comment Share on other sites More sharing options...
Kidney Posted September 16, 2012 Share Posted September 16, 2012 Then change the number of clicks to 2..... Link to comment Share on other sites More sharing options...
kylomas Posted September 16, 2012 Share Posted September 16, 2012 unknownwarrior,By thisI want to 'send' (by whatever method) that $button1 was pressed... without actually clicking on it.do you mean that you want to detect when the user has pressed $button1 in some application other than the script that you are running?kylomas Forum Rules        Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnOne Posted September 16, 2012 Share Posted September 16, 2012 I didn't try it because I knew I needed the object - which I can't seem to figure out how I would extract it from any window Can you explain in your own words what your research did teach you about this method? 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...
UnknownWarrior Posted September 16, 2012 Author Share Posted September 16, 2012 Then change the number of clicks to 2.....There are some places that aren't buttons that I just need to click on (like drop down boxes -- clicking on them twice would make it do nothing then)unknownwarrior,By thisdo you mean that you want to detect when the user has pressed $button1 in some application other than the script that you are running?kylomasNo, I don't need to detect anything (although I will need to 'record' or detect the functions so I can program them in to do the same thing later on)Can you explain in your own words what your research did teach you about this method?About COM? After looking at the lengthy note about it in the HelpFile, all the examples were just giving us the objects - pulled out of no where with no explanation of how to achieve our own. So I searched this forum for "find COM objects" and other related search terms and it seems that is something EVERYONE on here wishes could be possible. It seemed that IF you were able to have some kind of recorder (such as AU3Info) to tell you every object on the screen, you could manipulate windows SO much easier than any other method.In short -- I learned that since I cannot find the objects, (at least I don't know how to) I can't really use this method 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