Jump to content


Photo

Need assistance creating auto-attack script for a game


  • Please log in to reply
3 replies to this topic

#1 tmears

tmears
  • Members
  • 2 posts

Posted 25 April 2012 - 03:28 AM

Hello all,

I'm new to AutoHotkey and having a bit of trouble getting my script set up to do what I'd like. I'm trying to create a drop down list that contains each of the game's 3 classes (Dragon Knight, Spellweaver, Ranger) and depending on which is chosen the hotkeys sent would be different.

WinGet, ID, List, Drakensang Online: The online fantasy game in your browser

#IfWinActive, Drakensang Online: The online fantasy game in your browser

Gui, Add, Text, cGreen, Choose Your Class:
Gui, Add, DropDownList, vClass, Dragon Knight|Spellweaver|Ranger
Gui, Add, Button, Default, Go
Gui, Show
return

ButtonGo:
Gui, Submit, NoHide
MsgBox, You have selected %Class%

if Class = "Dragon Knight"
{
	$1::
	while GetKeyState("1", "P")
	    {
			SendPlay {1}
		}
		return
}

Currently no matter which class I select it still sends 1 to the game client.

I tried adding the other 2 classes:

else if Class = "Spellweaver"
{
	$1::
	while GetKeyState("1", "P")
	    {
			SendPlay {2}
		}
		return
}
else if Class = "Ranger"
{
	$1::
	while GetKeyState("1", "P")
	    {
			SendPlay {3}
		}
		return
}

However, this gives me a 'Duplicate Hotkey' error.

If anyone could point me in the right direction to correct this it would be greatly appreciated :)

#2 tmears

tmears
  • Members
  • 2 posts

Posted 25 April 2012 - 04:48 AM

Doh! I figured out what I was doing wrong...think I'm start to get the hang of this hehe.

WinGet, ID, List, Drakensang Online: The online fantasy game in your browser

#IfWinActive, Drakensang Online: The online fantasy game in your browser

Gui, Add, Text, cGreen, Choose Your Class:
Gui, Add, DropDownList, vClass, Dragon Knight|Spellweaver|Ranger
Gui, Add, Button, Default, Go
Gui, Show
return

ButtonGo:
Gui, Submit, NoHide
MsgBox, You have selected %Class%

$1::
while GetKeyState("1", "P")
{
if Class = Dragon Knight 
	{
	SendPlay {1}
	}
else if Class = Spellweaver
	{
	SendPlay {2}
	}
else if Class = Ranger
	{
	SendPlay {3}
	}
}
return


#3 Nailbiter

Nailbiter
  • Guests

Posted 29 April 2012 - 04:29 AM

Here's a possibility. This uses a simple input box to select a character class and the key to send based on what was selected. F1 selects the class F2 starts the key sends. This is just a test using a message box but the theory is solid and simple.
#SingleInstance Force
#MaxThreadsPerHotkey, 3

;------------------------------------------------
;  set up key to send
;------------------------------------------------
F1::
key := "None"
Loop
{	inputbox, selection, Choose Character Class, Choose Character Class`n(A) Ranger`n(B) Dragon Knight`n(C) Spellweaver
	If Errorlevel
	{	ExitApp
	}
	If (selection = "A")
	{	CharClass := "Ranger"
		key := 1
		Break
	}
	If (Selection = "B")
	{	CharClass := "Dragon Knight"
		key := 2
		Break
	}
	If (Selection = "C")
	{	CharClass := "Spellweaver"
		key := 3
		Break
	}
}
Return

;------------------------------------------------
; loop the key til stopped
;------------------------------------------------
F2::
Looping := (!Looping)
If (!Looping)
	Return
If (key = "None")
	Return
While (Looping)
{	MsgBox,,, Sending key %key% Press F2 to stop sending., 1
	;Send, %key%	
}
Return

;------------------------------------------------
; stop the script
;------------------------------------------------
Esc::
ExitApp

;================================================


#4 Pdad827

Pdad827
  • Guests

Posted 20 May 2012 - 10:35 PM

This is a curious script, have you got all the bugs worked out & what exactly does it do?