Need help with Slider

12/18/2013 21:49 mlukac89#1
Hi i have next script

I got inputs where i inputs cast times for skills 2900, 2600, etc... it have 10 skills
but problem is when i start it they cast skill and wait 2,9 sec then go to next skill, so i need to controll speed of casting skills + slider. Something like if cast (slider) on 100% to fire very fast but not to skip key, i dont know how to calculate this.

here is script

12/18/2013 22:19 alpines#2
Before you continue developing you should learn the basics about arrays.
It would shorten your code by far.
12/18/2013 22:47 mlukac89#3
But i hate arrays so much especially in Autoit its so confusing ;(
12/18/2013 23:06 alpines#4
Handling with arrays makes everything so much easier. Just try to learn how they work after some time you can't solve problems without them.

An example: If you want to set the data of 100 labels you will do it so
Code:
GUICtrlSetData($Label1, "1")
GUICtrlSetData($Label2, "1")
;...
and then you have 100 lines of code but you could solve it like this
Code:
For $i = 0 To UBound($aLabels) - 1
	GUICtrlSetData($aLabels[$i], "1")
Next
3 lines against 100 lines, what do you think is better?
12/18/2013 23:35 mlukac89#5
Oh i see its a only few lines of code and i know is better but i cant find good examples or tutorials to practice with so im now on start ;)

Can you give me maybe a example with my script or some good tutorial ?
12/19/2013 01:14 lolkop#6
Quote:
Originally Posted by mlukac89 View Post
Oh i see its a only few lines of code and i know is better but i cant find good examples or tutorials to practice with so im now on start ;)

Can you give me maybe a example with my script or some good tutorial ?
here's an example of array usage with your script...
Code:
Global $DEBUG = True
Global $label[6], $macroArray[2][10][4] ; [line][index][keyInput,checkbox,timeInput,timer]
Global $run, $buttonText[2]=['Start','Stop'], $handle, $keys[10]=[3,4,5,6,7,8,9,0,'ß',"´´"], $labelFont[6]=[400,400,800,400,400,400]

GUICreate("Macro", 602, 290, Default, Default, 0x108E0000)
GUICtrlCreateGroup('', 8, 2, 585, 190)
GUICtrlCreateGroup('', 8, 193, 585, 41)
GUICtrlCreateGroup('', 104, 11, 481, 86)
GUICtrlCreateGroup('', 105, 97, 481, 86)
For $line=0 To 1
	$label[$line] = GUICtrlCreateLabel("Bar No", 120, 32+$line*86, 46, 18)
	GUICtrlCreateCombo("", 121, 54+$line*86, 41, 25)
	GUICtrlSetData(-1, "1|2|3|4")
	For $i=0 To 9
		$macroArray[$line][$i][0] = GUICtrlCreateInput($keys[$i], 208+$i*38, 31+$line*86, 17, 17)
		$macroArray[$line][$i][1] = GUICtrlCreateCheckbox('', 210+$i*38, 51+$line*86, 17, 17)
		$macroArray[$line][$i][2] = GUICtrlCreateInput(1000, 200+$i*38, 72+$line*86, 33, 17)
	Next
Next
$label[2] = GUICtrlCreateLabel("SKILLS", 16, 14, 53, 18)
$label[3] = GUICtrlCreateLabel("Hotkey", 24, 56, 48, 18)
$label[4] = GUICtrlCreateLabel("CTRL + X", 24, 72, 60, 18)
$label[5] = GUICtrlCreateLabel("Cast time", 20, 208, 64, 18)
For $i=0 To 5
	GUICtrlSetFont($label[$i], 9, $labelFont[$i], 0, "Verdana")
Next
$saveBtn = GUICtrlCreateButton("Save", 520, 240, 75, 25)
$startBtn = GUICtrlCreateButton("Start", 8, 240, 75, 25)
$hSlider = GUICtrlCreateSlider(96, 208, 494, 20)

While True
	Switch GUIGetMsg()
		Case -3
			Exit
		Case $startBtn
			$run = Not $run
			GUICtrlSetData($startBtn, $buttonText[$run])
			$handle = WinGetHandle("Archlord")
			If $handle = '' Then
				TrayTip('AL-Macro', 'You need to run Archlord first', 1)
			Else
				TrayTip('AL-Macro', 'Running...', 5000, 1)
			EndIf
	EndSwitch
	If $run Then
		For $i=0 To 9
			If GUICtrlRead($macroArray[0][$i][1])=1 And TimerDiff($macroArray[0][$i][3])>=GUICtrlRead($macroArray[0][$i][2]) Then
				MySend(GUICtrlRead($macroArray[0][$i][0]))
				$macroArray[0][$i][3]=TimerInit()
			EndIf
			If GUICtrlRead($macroArray[1][$i][1])=1 And TimerDiff($macroArray[1][$i][3])>=GUICtrlRead($macroArray[1][$i][2]) Then
				MySend('+'&GUICtrlRead($macroArray[1][$i][0]))
				$macroArray[1][$i][3]=TimerInit()
			EndIf
		Next
	EndIf
WEnd

Func MySend($content)
	If $DEBUG Then Return ConsoleWrite($content&@CRLF)
	Return ControlSend($handle, '', '', $content, 0)
EndFunc
you should allways keep in mind:
less code -> lower chance of making mistakes
12/19/2013 02:09 mlukac89#7
Thank for this i will now practice a bit with that ;D
12/19/2013 10:39 alpines#8
If you use arrays then you can put the control handles inside these indexes which shorten your code by far and makes them more readable.

An quick example
Code:
$aLabels[10] = [GUICtrlCreateLabel(), GUICtrlCreateLabel(), GUICtrlCreateLabel(), GUICtrlCreateLabel(), GUICtrlCreateLabel(), GUICtrlCreateLabel(), GUICtrlCreateLabel(), GUICtrlCreateLabel(), GUICtrlCreateLabel(), GUICtrlCreateLabel()]

For $i = 0 To UBound($aLabels) - 1
	GUICtrlSetData($aLabels[$i], ...)
Next
and the methode you used
Code:
$h1 = GUICtrlCreateLabel()
$h2 = GUICtrlCreateLabel()
$h3 = GUICtrlCreateLabel()
$h4 = GUICtrlCreateLabel()
$h5 = GUICtrlCreateLabel()
$h6 = GUICtrlCreateLabel()
$h7 = GUICtrlCreateLabel()
$h8 = GUICtrlCreateLabel()
$h9 = GUICtrlCreateLabel()
$h10 = GUICtrlCreateLabel()

GUICtrlSetData($h1, ...)
GUICtrlSetData($h2, ...)
GUICtrlSetData($h3, ...)
GUICtrlSetData($h4, ...)
GUICtrlSetData($h5, ...)
GUICtrlSetData($h6, ...)
GUICtrlSetData($h7, ...)
GUICtrlSetData($h8, ...)
GUICtrlSetData($h9, ...)
GUICtrlSetData($h10, ...)
Arrays just contain multiple variable which makes the handling with controls much easier.
12/19/2013 14:29 mlukac89#9
example this piece of code from lolkop

Code:
$label[2] = GUICtrlCreateLabel("SKILLS", 16, 14, 53, 18)
$label[3] = GUICtrlCreateLabel("Hotkey", 24, 56, 48, 18)
$label[4] = GUICtrlCreateLabel("CTRL + X", 24, 72, 60, 18)
$label[5] = GUICtrlCreateLabel("Cast time", 20, 208, 64, 18)
For $i=0 To 5
	GUICtrlSetFont($label[$i], 9, $labelFont[$i], 0, "Verdana")
Next
some things dont need to be in array like this labels because u dont need to use it anywhere :)
12/19/2013 15:47 alpines#10
That's right, but it was just an example how you can do it.
Of course you can store more than useless labels.
12/19/2013 19:23 lolkop#11
Quote:
Originally Posted by mlukac89 View Post
example this piece of code from lolkop

Code:
$label[2] = GUICtrlCreateLabel("SKILLS", 16, 14, 53, 18)
$label[3] = GUICtrlCreateLabel("Hotkey", 24, 56, 48, 18)
$label[4] = GUICtrlCreateLabel("CTRL + X", 24, 72, 60, 18)
$label[5] = GUICtrlCreateLabel("Cast time", 20, 208, 64, 18)
For $i=0 To 5
	GUICtrlSetFont($label[$i], 9, $labelFont[$i], 0, "Verdana")
Next
some things dont need to be in array like this labels because u dont need to use it anywhere :)
if u're using one and the same function on more than one variable (in this case SetFont), it's allways usefull to use arrays...

you can change all fonts in 3lines of code... no matter how many labels exist... even for those 4 lines (in total 6), you'd need 4(6) lines to set the fonts, which makes the array usefull for you

Edit:
once you're tryin to handle unknown numbers of variables, you will have to use arrays anyways.
12/20/2013 18:17 mlukac89#12
Oh i see but i have problem with script you made i put out timer init and timer diff because its not work good i also tried like this, because in game on skill it say example 6 seconds but more cooldown you have like 80% then its cooldown like 1-2

And for cast time too on skill say 2,1 second and i put 2100 but its skip alot, it send keys like 100 ms and it depends of cast time you have 99%

So i need to control cast with slider cast time of skill 2,1 sec + slider = slider on max fire faster, slider on lower fire slower


Code:
If $run Then
		For $i=0 To 9
			If GUICtrlRead($macroArray[0][$i][1])=1 And GUICtrlRead($macroArray[0][$i][2]) Then
				MySend(GUICtrlRead($macroArray[0][$i][0]))
			EndIf
			If GUICtrlRead($macroArray[1][$i][1])=1 And GUICtrlRead($macroArray[1][$i][2]) Then
				MySend('+'&GUICtrlRead($macroArray[1][$i][0]))
			EndIf
		Next
	EndIf

And on the end it need to be something like this :

cast time on skill 2,1 second - + with slider
+ cooldown time from skill 6 sec - + my cooldown 1-80%

skill picture
[Only registered and activated users can see links. Click Here To Register...]

stats picture
[Only registered and activated users can see links. Click Here To Register...]

So fire if checked skill bar 1 = 3,4,5,6,7,8,9,0,ß,´´
Fire if checked skill bar 2 = 3,4,5,6,7,8,9,0,ß,´´

wait for cooldown of skill and fire again
12/20/2013 19:15 KDeluxe#13
You're using a stupid "system". Just use the highest available time and keep in mind that you have to add a small buffer. The game needs time to recognize the input. You should use something about "23000" ms.
12/20/2013 20:19 mlukac89#14
Why this system is stupid ? I just need to adjust cast time 99% with skill cast time 6 or 5 or 9 seconds ...

But i think you dont understand what i need. If you have for example 50% cast time you need 10 seconds or more to fire 10 skill, but if you have 99% cast or more you need 3-4 second to fire 10 skills, and second problem is skipping skills, it fire like 4,5,7,9,ß but not
3,4,5,6,7,8,9,0,ß,´´
12/20/2013 23:28 KDeluxe#15
You want to create a bot for Archlord. It's one of thousand MMORPGs and I'm pretty sure that the basics are the same. That means that you can learn new skills with various effects at higher levels. All skills are having different parameters (Cast Time, Cooldown Time, Duration, Range). There is no way that you can put all skills together. Your slider is simply useless.
Maybe you can equip some gear which will affect all of your skills. You will need far more than a simple slider in that case. Just calculate the time needed by yourself and set up your settings.