khandan Posted August 18, 2011 Posted August 18, 2011 I havewritten this script that prduces and saves map and table , the first map name would be map_1 and first table name would be table_1 and based on function it runs again and again, how I can asked the script that in second round it save the second map and table by name of map_2 or table_2 or everything else?should I use Arrays or write another function?this is my script: #include <file.au3> #include <array.au3> Global $CSV_Array _FileReadToArray("C:\Users\naroueia\Desktop\climexdata.csv", $CSV_Array) ;The script will change greatly if you want to modify more than one parameter at the time ;you will need to click somewhere and modify that parameter, then click elsewhere ... so on For $i = 1 To $CSV_Array[0] _GetMyResults($CSV_Array[$i]) Next Func _GetMyResults($parameter) Run("C:\Program Files\CSIRO Entomology\Dymex\DxSim3.exe") ; runs the software MouseClick("left", 830, 400, 1); clicks on welcoming window Send("{ESC}") ; closes welcoming window WinWait('CLIMEX - Compare Locations (1 species)', ''); activates the main window WinActivate('CLIMEX - Compare Locations (1 species)', '') MouseClick('Left', 50, 241, 1); click on parameters window Sleep(2000) MouseClick('Left', 46, 169, 1); opens temperature Index Sleep(2000) MouseClick('Left', 48, 198, 2); click on temperature Index DV0 filed Sleep(2000) Send($parameter); changes parameter Sleep(2000) Send("{Enter}"); goes to the next filed to confirm entered number (1) Sleep(2000) Send("{ESC}"); gets out of fileds Sleep(2000) MouseClick('Left', 471, 111, 1); closes the parameters window Sleep(2000) Send("^r"); Runs the model Sleep(1000) Sleep(35000) ;waits 27seconds for model to run; awaits for model to run fully Send("^m") Sleep(3000) ; 3 seconds shows the map MouseClick('Left', 590, 241, 1) Sleep(2000) Send("{Alt}") Send("m") MouseClick('Left', 109, 329, 1); clicks on Export File Sleep(2000) Send("{BS}"); deletes the default name ControlClick("Save As", "", "[CLASS:Button; INSTANCE:1]", ""); clicks on the empty field to type the name of file Sleep(2000) ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", "map_1"); saves the map by the name of "mapi" Sleep(2000) ControlClick("Save As", "", "[CLASS:Button; INSTANCE:2]", "") Sleep(6000); waits 4 seconds to save the file Send("{enter}"); justifies the dialoge box showing the map succesfully saved Sleep("4000") Send("{ALT}") Sleep("1000") Send("w"); activates the Window menue Sleep("2000") Send("2"); activates the Run window Sleep("1000") Send("^t"); creates the table Sleep("2000") Send("S"); opening standard table sleep("2000") MouseClick("left",459, 482,2) sleep("1000") send ("s"); sends the "save table" command sleep("1000") Send("{BS}"); deletes the default name sleep("1000") ControlClick("Save As", "", "[CLASS:Edit; INSTANCE:1]", ""); clicks on the empty field to type the name of file Sleep(1000) ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", "table_1"); saves the table by the name of "table_1" Sleep(1000) ControlClick("Save As", "", "[CLASS:Button; INSTANCE:2]", "") sleep("2000") Send("{ALTDown}+{F4}"); closes the software Send("{ALTUP}"); releases the ALT button sleep("2000") Controlclick("Dymex Simulato","", "[CLASS:Button; INSTANCE:2]","") EndFunc ;==>_GetMyResults Cheers
hannes08 Posted August 18, 2011 Posted August 18, 2011 Hi khandan, just change your function to accept a second parameter: For $i = 1 To $CSV_Array[0] _GetMyResults($CSV_Array[$i], $i) Next Func _GetMyResults($parameter, $index) ;... ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", "map_" & $index); saves the map by the name of "mapi" ;... ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", "table_" & $index); saves the table by the name of "table_1" ;... EndFunc Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
khandan Posted August 18, 2011 Author Posted August 18, 2011 Hi khandan, just change your function to accept a second parameter: For $i = 1 To $CSV_Array[0] _GetMyResults($CSV_Array[$i], $i) Next Func _GetMyResults($parameter, $index) ;... ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", "map_" & $index); saves the map by the name of "mapi" ;... ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", "table_" & $index); saves the table by the name of "table_1" ;... EndFunc ---Thank you very much thaaaaaaaaaanks
khandan Posted August 18, 2011 Author Posted August 18, 2011 ---Thank you very much thaaaaaaaaaanks====oh something else just crossed my mind, what if the defined file name already exists in that folder?in this case how i can ask the script to save file with a name loke "map_1_1" instead of "map_1" that already exists?Cheers
smartee Posted August 18, 2011 Posted August 18, 2011 Use the FileExists function to check if the file exists, and if so, then $index&="_1".
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