Skizzy Posted June 4, 2012 Share Posted June 4, 2012 (edited) Is there a more... optimized way to write this script? It's very unreliable and will often action() over #2 when it should have action()'d on #1. I feel like it's something to do with the sleep(xxx), but I've tried so many different ways and seems I can't get it down. The memory address is accurate and is static.expandcollapse popup#include <NomadMemory.au3> #include <GUIConstants.au3> #include <Misc.au3> #include <Array.au3> $ID=_MemoryOpen(ProcessExists("application.exe")) $Address=0x19790F64 $value=_MemoryRead($Address,$ID ,"char[5]") Global $Paused HotKeySet("{HOME}", "TogglePause") HotKeySet("{END}", "Terminate") $Count = 10000 ; While 1 MouseMove ( 643, 760, 0 ) ; MouseClick("left") Sleep(50) Send( "{BACKSPACE 5}" ) Sleep(50) Send ($Count) Sleep(50) MouseMove ( 531, 841, 0 ) ; Mouseclick("left") $Count = $Count + 1 Sleep(50) MouseMove ( 958, 461, 0 ) ; MouseClick("left") Sleep(200) MouseMove ( 724, 322, 0 ) ; #1 If $value > 700 Then action() EndIf Sleep(100) MouseMove ( 724, 370, 0 ) ; #2 Sleep(400) If $value > 700 Then action() EndIf WEnd Func action() Sleep(50) MouseClick("left") Sleep(200) MouseMove ( 1442, 879, 0 ) MouseClick("left") Sleep(200) MouseMove ( 849, 722, 0 ) Mouseclick("left") EndFuncAny help would be very appreciated! I have spent hours on writing this thing from scratch, and being so close to being complete and it not cooperating like it should is quite frustrating. Edited June 4, 2012 by Skizzy Link to comment Share on other sites More sharing options...
water Posted June 4, 2012 Share Posted June 4, 2012 What kind of application do you try to automate? Wouldn't it be easier and more reliable to use Send or Control commands? 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...
Inverted Posted June 4, 2012 Share Posted June 4, 2012 There are things missing. What is that $value variable ? Otherwise this is just mouse moving, cliking and clicking, we can't help you. Link to comment Share on other sites More sharing options...
Skizzy Posted June 4, 2012 Author Share Posted June 4, 2012 (edited) What kind of application do you try to automate? Wouldn't it be easier and more reliable to use Send or Control commands? It's just something to make my life a bit easier. I do use a few Send commands in there, and I guess I could use Control. Might clear up a few lines, but it's not top priority at this moment. Just trying to make the If $value Then action() commands a bit more reliable. There are things missing. What is that $value variable ? Otherwise this is just mouse moving, cliking and clicking, we can't help you. $value is: $value=_MemoryRead($Address,$ID ,"char[5]") You probably just missed it because of how sloppy my coding is, sorry! Edited June 4, 2012 by Skizzy Link to comment Share on other sites More sharing options...
Skizzy Posted June 4, 2012 Author Share Posted June 4, 2012 (edited) I'm wondering if it has something to do with the value being a decimal for the memory address. For example, the address has a value of 767.2. A char[6] make sense here, correct? I can see the value changing while the macro does its thing and the address stays constant, but sometimes action() does not happen despite the address showing 767.2. Edit: If the script fails to perform action() when $value is > 700, and I terminate the script and run it again, it acknowledges it instantly, and does action() like it should. Ugh, I don't understand. Edited June 4, 2012 by Skizzy Link to comment Share on other sites More sharing options...
water Posted June 4, 2012 Share Posted June 4, 2012 Once again: Memory reading isn't needed 99.9% of the time. Almost every application can be automated using Send and Control commands. To make your script run reliable independant of screen size etc. I would strongly recommend to search for another approach and drop memory reading and mouse moving. Tell us what application you try to automate, what data you need to read and what buttons etc. you need to click on. 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...
Skizzy Posted June 4, 2012 Author Share Posted June 4, 2012 (edited) Ah, it's so satisfying when you troubleshoot an issue yourself. Finally got it done after several hours working on this thing today!Basically I just simplified my While statement, put the Memory information in there, and added a Refresh() function which just contains everything I used to have in the While section.While 1 $ID=_MemoryOpen(ProcessExists("application.exe")) $Address=0x19790F64 $dps=_MemoryRead($Address, $ID, "char[6]") If $value > 700 Then Action() Else Refresh() EndIf WEnd Edited June 4, 2012 by Skizzy Link to comment Share on other sites More sharing options...
Bert Posted June 4, 2012 Share Posted June 4, 2012 Once again: Memory reading isn't needed 99.9% of the time. Almost every application can be automated using Send and Control commands. To make your script run reliable independant of screen size etc. I would strongly recommend to search for another approach and drop memory reading and mouse moving.Tell us what application you try to automate, what data you need to read and what buttons etc. you need to click on.The OP is ignoring your question for if he is honest you know what will happen. ............"Click" The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
water Posted June 4, 2012 Share Posted June 4, 2012 I know ... that's why I ask 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...
czardas Posted June 4, 2012 Share Posted June 4, 2012 (edited) When I see all those clicks and mouse moves my PC just growls 'Don't you dare allow that code anywhere near my processor!'. Edited June 4, 2012 by czardas operator64 ArrayWorkshop 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