shadowbladex Posted September 22, 2008 Posted September 22, 2008 (edited) !! Problem Solved !!Hi, i am still new to autoit. Im trying to make a Macro program that runs from a text (.ini) file.So far i have managed to make it work, just not 100% correctly.Here is what i have so far:Programexpandcollapse popup;Hotkey $HotKey = IniRead("config.ini", "Hotkey", "HotKey", "") ;Button $Button1 = IniRead("config.ini", "Button", "Button1", "") $Button2 = IniRead("config.ini", "Button", "Button2", "") $Button3 = IniRead("config.ini", "Button", "Button3", "") $Button4 = IniRead("config.ini", "Button", "Button4", "") $Button5 = IniRead("config.ini", "Button", "Button5", "") $Button6 = IniRead("config.ini", "Button", "Button6", "") $Button7 = IniRead("config.ini", "Button", "Button7", "") $Button8 = IniRead("config.ini", "Button", "Button8", "") $Button9 = IniRead("config.ini", "Button", "Button9", "") $Button10 = IniRead("config.ini", "Button", "Button10", "") $Button11 = IniRead("config.ini", "Button", "Button11", "") $Button12 = IniRead("config.ini", "Button", "Button12", "") $Button13 = IniRead("config.ini", "Button", "Button13", "") $Button14 = IniRead("config.ini", "Button", "Button14", "") ;Sleep $Sleep1 = IniRead("config.ini", "Sleep", "Sleep1", "") $Sleep2 = IniRead("config.ini", "Sleep", "Sleep2", "") $Sleep3 = IniRead("config.ini", "Sleep", "Sleep3", "") $Sleep4 = IniRead("config.ini", "Sleep", "Sleep4", "") $Sleep5 = IniRead("config.ini", "Sleep", "Sleep5", "") $Sleep6 = IniRead("config.ini", "Sleep", "Sleep6", "") $Sleep7 = IniRead("config.ini", "Sleep", "Sleep7", "") $Sleep8 = IniRead("config.ini", "Sleep", "Sleep8", "") $Sleep9 = IniRead("config.ini", "Sleep", "Sleep9", "") $Sleep10 = IniRead("config.ini", "Sleep", "Sleep10", "") $Sleep11 = IniRead("config.ini", "Sleep", "Sleep11", "") $Sleep12 = IniRead("config.ini", "Sleep", "Sleep12", "") $Sleep13 = IniRead("config.ini", "Sleep", "Sleep13", "") $Sleep14 = IniRead("config.ini", "Sleep", "Sleep14", "") Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{END}", "Terminate") HotKeySet($HotKey, "Attack") ;;;; Body of program would go here;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func Attack() WinWaitActive("WINDOW") Sleep("1000") Send($Button1) Sleep($Sleep1) Send($Button2) Sleep($Sleep2) Send($Button3) Sleep($Sleep3) Send($Button4) Sleep($Sleep4) Send($Button5) Sleep($Sleep5) Send($Button6) Sleep($Sleep6) Send($Button7) Sleep($Sleep7) Send($Button8) Sleep($Sleep8) Send($Button9) Sleep($Sleep9) Send($Button10) Sleep($Sleep10) Send($Button11) Sleep($Sleep11) Send($Button12) Sleep($Sleep12) Send($Button13) Sleep($Sleep13) Send($Button14) Sleep($Sleep14) EndFuncText File (.ini)[Hotkey] HotKey= [Button] Button1= Button2= Button3= Button4= Button5= Button6= Button7= Button8= Button9= Button10= Button11= Button12= Button13= Button14= [Sleep] Sleep1= Sleep2= Sleep3= Sleep4= Sleep5= Sleep6= Sleep7= Sleep8= Sleep9= Sleep10= Sleep11= Sleep12= Sleep13= Sleep14=The HotKey works. >_< My main problem is that they don't always respond with the button and the correct time.And I don't understand why I would also like to know if i run this and I'm only using 3 Buttons in the Ini file, will it run thrue all the 14? or just the ones i give a key to?Because i only want it to run the ones i give a key to.Any help is greatly appreciated! Edited September 22, 2008 by shadowbladex
martin Posted September 22, 2008 Posted September 22, 2008 Hi, i am still new to autoit. Im trying to make a Macro program that runs from a text (.ini) file. So far i have managed to make it work, just not 100% correctly. Here is what i have so far: Program expandcollapse popup;Hotkey $HotKey = IniRead("config.ini", "Hotkey", "HotKey", "") ;Button $Button1 = IniRead("config.ini", "Button", "Button1", "") $Button2 = IniRead("config.ini", "Button", "Button2", "") $Button3 = IniRead("config.ini", "Button", "Button3", "") $Button4 = IniRead("config.ini", "Button", "Button4", "") $Button5 = IniRead("config.ini", "Button", "Button5", "") $Button6 = IniRead("config.ini", "Button", "Button6", "") $Button7 = IniRead("config.ini", "Button", "Button7", "") $Button8 = IniRead("config.ini", "Button", "Button8", "") $Button9 = IniRead("config.ini", "Button", "Button9", "") $Button10 = IniRead("config.ini", "Button", "Button10", "") $Button11 = IniRead("config.ini", "Button", "Button11", "") $Button12 = IniRead("config.ini", "Button", "Button12", "") $Button13 = IniRead("config.ini", "Button", "Button13", "") $Button14 = IniRead("config.ini", "Button", "Button14", "") ;Sleep $Sleep1 = IniRead("config.ini", "Sleep", "Sleep1", "") $Sleep2 = IniRead("config.ini", "Sleep", "Sleep2", "") $Sleep3 = IniRead("config.ini", "Sleep", "Sleep3", "") $Sleep4 = IniRead("config.ini", "Sleep", "Sleep4", "") $Sleep5 = IniRead("config.ini", "Sleep", "Sleep5", "") $Sleep6 = IniRead("config.ini", "Sleep", "Sleep6", "") $Sleep7 = IniRead("config.ini", "Sleep", "Sleep7", "") $Sleep8 = IniRead("config.ini", "Sleep", "Sleep8", "") $Sleep9 = IniRead("config.ini", "Sleep", "Sleep9", "") $Sleep10 = IniRead("config.ini", "Sleep", "Sleep10", "") $Sleep11 = IniRead("config.ini", "Sleep", "Sleep11", "") $Sleep12 = IniRead("config.ini", "Sleep", "Sleep12", "") $Sleep13 = IniRead("config.ini", "Sleep", "Sleep13", "") $Sleep14 = IniRead("config.ini", "Sleep", "Sleep14", "") Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{END}", "Terminate") HotKeySet($HotKey, "Attack") ;;;; Body of program would go here;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func Attack() WinWaitActive("WINDOW") Sleep("1000") Send($Button1) Sleep($Sleep1) Send($Button2) Sleep($Sleep2) Send($Button3) Sleep($Sleep3) Send($Button4) Sleep($Sleep4) Send($Button5) Sleep($Sleep5) Send($Button6) Sleep($Sleep6) Send($Button7) Sleep($Sleep7) Send($Button8) Sleep($Sleep8) Send($Button9) Sleep($Sleep9) Send($Button10) Sleep($Sleep10) Send($Button11) Sleep($Sleep11) Send($Button12) Sleep($Sleep12) Send($Button13) Sleep($Sleep13) Send($Button14) Sleep($Sleep14) EndFunc Text File (.ini) [Hotkey] HotKey= [Button] Button1= Button2= Button3= Button4= Button5= Button6= Button7= Button8= Button9= Button10= Button11= Button12= Button13= Button14= [Sleep] Sleep1= Sleep2= Sleep3= Sleep4= Sleep5= Sleep6= Sleep7= Sleep8= Sleep9= Sleep10= Sleep11= Sleep12= Sleep13= Sleep14= The HotKey works. >_< My main problem is that they don't always respond with the button and the correct time. And I don't understand why I would also like to know if i run this and I'm only using 3 Buttons in the Ini file, will it run thrue all the 14? or just the ones i give a key to? Because i only want it to run the ones i give a key to. Any help is greatly appreciated! What is supposed to happen when you execute Send($Button1) or Send($sleep1)? It won't sleep for a certain time or click on a button for example. To sleep for a certain time you need Sleep(Number($Sleep5)) To click on a button you need ControlClick and the window title ControlClick($WindowTitle,"",$Button5);assuming $button5 has been set with the correct classname or ID. You can omit buttons and their correspning sleeps with an If statement expandcollapse popup If $button6 <> "" then Send($sleep6) Send($Button6) endif Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. shadowbladex Posted September 22, 2008 shadowbladex Members 11 Author Posted September 22, 2008 (edited) What is supposed to happen when you execute Send($Button1) or Send($sleep1)? It won't sleep for a certain time or click on a button for example. To sleep for a certain time you need Sleep(Number($Sleep5)) To click on a button you need ControlClick and the window title ControlClick($WindowTitle,"",$Button5);assuming $button5 has been set with the correct classname or ID. You can omit buttons and their correspning sleeps with an If statement If $button6 <> "" then Send($sleep6) Send($Button6) endif What i did was make it so i could just add {THEKEY} and the time in the ini file. Like: [button] Button1= Button2= then just add [button] Button1={f4} Button2={f1} And for time: [sleep] Sleep1= Sleep2= Then [sleep] Sleep1=1500 Sleep2=2000 I wanted to make it so i could control it from the ini file. Sorry i was not very clear about that in my first post. IF i understand right, your method will rely on a preset number? or am i misunderstanding it? Will your method allow me to edit the time and keys threw the ini file? Edited September 22, 2008 by shadowbladex
shadowbladex Posted September 22, 2008 Author Posted September 22, 2008 (edited) Ok.. As it appears my script actually works great. The problem was with the game i was trying it on. DOH! >.<" Anyway. I will leave my posts up for anyone who may be able to learn from any of it. Edited September 22, 2008 by shadowbladex
martin Posted September 22, 2008 Posted September 22, 2008 Ok.. As it appears my script actually works great. The problem was with the game i was trying it on. DOH! >.<"Anyway. I will leave my posts up for anyone who may be able to learn from any of it.Ok, I had my eyes crossed when I read your post and you can ignore my reply. (Well, you laready have >_< ) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Recommended Posts
shadowbladex
Anyway. I will leave my posts up for anyone who may be able to learn from any of it.
Edited by shadowbladexmartin