ayatest Posted January 23, 2015 Share Posted January 23, 2015 Let sa that I have series of mouse clicks (and other operations), like below (this is for recording videos as well): ... MouseClick("left",734,75,1) Sleep(2000) MouseClick("left",763,76,1) Sleep(2000) MouseClick("left",307,70,1) Sleep(2000) MouseClick("left",733,75,1) Sleep(2000) MouseClick("left",758,75,1) Sleep(2000) ... I'd like to define these operations in one place as an "item", that I can place in multiple places of the script later. Thus - I could edit the list separately, and use the whole item wen needed. Could someone post an example on how to make it? Thanks. functional testing. multimedia recording. flowstone. mouseclick, hotkeys and modularity in general. Link to comment Share on other sites More sharing options...
MikahS Posted January 23, 2015 Share Posted January 23, 2015 MouseClicks() Func MouseClicks() MouseClick("left",734,75,1) Sleep(2000) MouseClick("left",763,76,1) Sleep(2000) MouseClick("left",307,70,1) Sleep(2000) MouseClick("left",733,75,1) Sleep(2000) MouseClick("left",758,75,1) Sleep(2000) EndFunc By putting it into a function you can call this function anywhere in your script for multiple uses. Does that help? 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...
ayatest Posted January 23, 2015 Author Share Posted January 23, 2015 (edited) I'm not sure yet. :-) So the "MouseClicks" is a custom name (not AutoIt operator), yes? I ask, because mouse clicks will be one of few other items. (btw, why it;s used twice?) And then to call the function, I do something like this? Call("MouseClicks") and it will perform all these steps in this particular place where it is called, yes? Or should I define smething more in the script's header? Edited January 23, 2015 by ayatest functional testing. multimedia recording. flowstone. mouseclick, hotkeys and modularity in general. Link to comment Share on other sites More sharing options...
MikahS Posted January 23, 2015 Share Posted January 23, 2015 (edited) Sorry, I'm sure it was a vague description. Let me explain a little further. Mouseclicks is a custom name I made up for the function. When you create a function (function can be declared anywhere in the script) like so: Func test() ;comment EndFunc You can then call that function all the time like so: test() So you do not have to use the Call() function. When calling this function, it will stop wherever it is in that script, and go into the function line by line, until it has finished. Then, it will resume where it left off outside of the function. Does that help clear things up? If not, please let me know, I'd be happy to explain anything you don't understand further. Edited January 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...
Solution ayatest Posted January 23, 2015 Author Solution Share Posted January 23, 2015 Yes, thank you, works perfectly. functional testing. multimedia recording. flowstone. mouseclick, hotkeys and modularity in general. Link to comment Share on other sites More sharing options...
MikahS Posted January 23, 2015 Share Posted January 23, 2015 (edited) Glad you got an understanding. My pleasure. Also, having a look at the AutoIt wiki will definitely give you loads of info, along with many tutorials. EDIT: Also, on future topics (this really was just explanations) mark the answer that best solved your problem on the bottom right of the post. Edited January 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...
ayatest Posted January 23, 2015 Author Share Posted January 23, 2015 This is my first day with autoit. :-) Generally, from my experience, my best practice/learning, is - to have a specific problem to find a solution for it. Reading wiki and tutorials is helpful only to a certain degree, because there is a lot of terminology I don't understand (so sometimes I even don't have keywords so to speak) or don't have a context for it. It's easier for me to describe a problem (like a module, that should do something), see the code for it, and then integrate it into wider design. functional testing. multimedia recording. flowstone. mouseclick, hotkeys and modularity in general. Link to comment Share on other sites More sharing options...
water Posted January 23, 2015 Share Posted January 23, 2015 Which application do you try to automate? Mouseclick is dependant on screen resolution and window positions. Most of the time there are more reliable ways to automate an application. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
ayatest Posted January 23, 2015 Author Share Posted January 23, 2015 Multiple. I have some designs I made in Flowstone, and I have other kind of works (sometimes autoit is seeing things like buttons, sometimes not). Some of work is done for visual output (video recording), so mouse pointer must be visible and must go here and there. But as for dependencies, correct me if I understand it wrong. If there is a way to use relative coordinates (app window serves as offset), then I see no problem if app wanders on the screen. If not - what else can I specifically use to achieve the same functional (and visual?) mouse effect? functional testing. multimedia recording. flowstone. mouseclick, hotkeys and modularity in general. Link to comment Share on other sites More sharing options...
water Posted January 23, 2015 Share Posted January 23, 2015 If you need a visible mouse pointer then your approach is the best way in my opinion. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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