AutoHotkey Community

It is currently May 26th, 2012, 3:35 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: April 21st, 2008, 5:51 pm 
Offline

Joined: June 22nd, 2007, 4:42 am
Posts: 40
I was playing the ancient game Diablo again for kicks and was slightly irritated by the fact I could not use WASD like most games now a days. I took a shot at making the WASD keys work.

I got the keys to work individually with this code:

Code:
ScreenWidth := 795
ScreenHeight := 595

halfWidth := ScreenWidth/2
halfHeight := ScreenHeight/2

w::
MouseGetPos, saveXpos, saveYpos
MouseClick, left, %halfwidth%, 5, 1, 0, D
MouseGetPos, new_saveXpos, new_saveYpos
;msgbox, orig: %saveXpos%, %saveYpos% new: %new_saveXpos%, %new_saveYpos%
KeyWait w
;msgbox, w was released               
MouseClick, left,,, 1, 0, U
MouseMove, %saveXpos%, %saveYpos%
return

a::
MouseGetPos, saveXpos, saveYpos
MouseClick, left, 5, %halfHeight%, 1, 0, D
MouseGetPos, new_saveXpos, new_saveYpos
KeyWait a               
MouseClick, left,,, 1, 0, U
MouseMove, %saveXpos%, %saveYpos%
return

s::
MouseGetPos, saveXpos, saveYpos
MouseClick, left, %halfWidth%, %ScreenHeight%, 1, 0, D
MouseGetPos, new_saveXpos, new_saveYpos
KeyWait s               
MouseClick, left,,, 1, 0, U
MouseMove, %saveXpos%, %saveYpos%
return

d::
MouseGetPos, saveXpos, saveYpos
MouseClick, left, %ScreenWidth%, %halfHeight%, 1, 0, D
MouseGetPos, new_saveXpos, new_saveYpos
KeyWait d               
MouseClick, left,,, 1, 0, U
MouseMove, %saveXpos%, %saveYpos%
return


But I do not know how I would make it work to allow you to go diagonal.

I was think of doing something like:

Code:
w & d::
MouseGetPos, saveXpos, saveYpos
MouseClick, left, %ScreenWidth%, 5, 1, 0, D
MouseGetPos, new_saveXpos, new_saveYpos
KeyWait d   ;THIS IS THE PROBLEM            
MouseClick, left,,, 1, 0, U
MouseMove, %saveXpos%, %saveYpos%
return


the problem is if w is released then it keeps going north west because I dont know how to check if both keys are up.


EDIT: Thanks to VxE, I've got a good script that I will probably add more to. Heres my final version so far:

Code:
ScreenWidth := 800
ScreenHeight := 585

halfWidth := ScreenWidth/2
halfHeight := ScreenHeight/2

keys = wasd ; ULDR
SetDefaultMouseSpeed, 0

StringSplit, key, keys
Loop, Parse, Keys
   Hotkey, *$%A_LoopField%, TheTimer, on
Pause::Suspend

TheTimer:
SetTimer, TheMover, 5 ; this number is the speed adjustment, higher = slower
return

TheMover:
dx := GetKeyState( key4, "P" ) - GetKeyState( key2, "P" ) ;Right - Left
dy := GetKeyState( key3, "P" ) - GetKeyState( key1, "P" ) ;Down - Up
If !TheFlag
   MouseGetPos, memx, memy
If ( dx + dy*2 )
{
   TheSpam = Left Down
;////////////////////////// Uncomment the next line to stop the rapid-click
;   IfEqual, TheFlag, 1, StringReplace, TheSpam, TheSpam, Down, 0
   Click, % (halfwidth + 50 * dx) " "
      . (halfheight + 50 * dy) " " TheSpam

   TheFlag = 1
}
else
{
   Click, Left Up
   Click, %memx% %memy% Left 0
   TheFlag = 0
   SetTimer, TheMover, off
}
return


I changed it so that it does not click to the edge of the screen because it was not ideal that if you just tapped "w, a, s or d" it would go all the way to the edge of the screen, when you may have wanted to only take a few steps.

NOTE:Ran into a problem with finding the center because it was not (400,300) like you would think, because the character is higher than the center.

EDIT: (4/22/08) Well, I liked the sound of ControlClick, because its nice to move the mouse while walking around with wasd, so heres the new script, complete with a hotkey (hold down alt+e) that picks up special items (browns, greens, yellows and blues) and some scripts I use to use skills:

Code:
SendMode Play

ScreenWidth := 800
ScreenHeight := 585

halfWidth := ScreenWidth/2
halfHeight := ScreenHeight/2

Skill := 0
xTL := 0
yTL := 0
xBR := 800
yBR := 553
Best1st := 1

keys = wasd ; ULDR
SetDefaultMouseSpeed, 0

StringSplit, key, keys
Loop, Parse, Keys
   Hotkey, $%A_LoopField%, TheTimer, on
Pause::Suspend

TheTimer:
SetTimer, TheMover, 5 ; change speed, higher = slower
return

TheMover:
dx := GetKeyState( key4, "P" ) - GetKeyState( key2, "P" ) ;Right - Left
dy := GetKeyState( key3, "P" ) - GetKeyState( key1, "P" ) ;Down - Up
If !TheFlag
   MouseGetPos, memx, memy
If (dx | dy)
{
   TheSpam = Left Down
;////////////////////////// Uncomment the next line to stop the rapid-click
;   IfEqual, TheFlag, 1, StringReplace, TheSpam, TheSpam, Down, 0

;   Click, % (halfwidth + 50 * dx) " "
;      . (halfheight + 50 * dy) " " TheSpam

    xval := halfwidth + 50 * dx
    yval := halfheight + 50 * dy
    ControlClick, x%xval% y%yval%, Diablo,,,, D

    TheFlag = 1
}
else
{
   MouseGetPos, memx, memy
   ;ControlClick, x%xval% y%yval%, Diablo
   Click, %xval% %yval% Left 1
   Click, %memx% %memy% Left 0
   TheFlag = 0
   SetTimer, TheMover, off
}
return

q::
tmp_Skill := Skill
Send, {f1}
Loop
{
    if not GetKeyState("q", "P" )
        break
    Sleep 250
    Click Right
}
Skill := tmp_Skill
Send {f%Skill%}
return

f::
tmp_Skill := Skill
Send, {f6}
Loop
{
    if not GetKeyState("f", "P" )
        break
    Sleep 250
    Click Right
}
Skill := tmp_Skill
Send {f%Skill%}
return

r::
tmp_Skill := Skill
Send, {f2}
Click Right
Sleep 450
Send, {f5}
Click Right
Skill := tmp_Skill
Send {f%Skill%}
return

e::
tmp_Skill := Skill
Send, {f4}
Click Right
Skill := tmp_Skill
Send {f%Skill%}
return

!e::

FileAppend, %Best1st%`n , C:\best1st.txt

if (Best1st < 3)
{
 xTL := 63
 yTL := 72
 Color := "0x588898" ;Gold Items
 Gosub, SearchnClick ;Pickup Golds
 xTL := 0
 yTL := 0
}
else if (Best1st > 2 and Best1st < 5)
{
 Color := "0x00C800" ;Green Items
 Gosub, SearchnClick ;Pickup Greens
}
else if (Best1st > 4 and Best1st < 7)
{

 Color := "0x205858" ;Yellow Items
 Gosub, SearchnClick ;Pickup Yellows
}
else if (Best1st > 6 and Best1st < 9)
{
 Color := "0xC85058" ;Blue Items
 Gosub, SearchnClick ;Pickup Blues
}
else
{
Best1st := 0
}

return

SearchnClick:

Send {Alt Down}
PixelSearch, Px, Py, %xTL%, %yTL%, %xBR%, %yBR%, %Color%, 1, Fast

 if ErrorLevel
 {
   Best1st := Best1st + 1
 }
 else
 {
   Px := Px+2
   Py := Py+5
   Click, %Px% %Py% Left 1
 }

return

!x::
Send {esc}{up}{enter}
return

~f1::
Skill := 1
return
~f2::
Skill := 2
return
~f3::
Skill := 3
return
~f4::
Skill := 4
return
~f5::
Skill := 5
return
~f6::
Skill := 6
return
~f7::
Skill := 7
return
~f8::
Skill := 8
return
~f9::
Skill := 9
return
~f10::
Skill := 10
return
~f11::
Skill := 11
return
~f12::
Skill := 12
return

LWin::
send {Alt}
return

_________________
Truth is truth, whether you believe it or not.


Last edited by CraSH23000 on April 23rd, 2008, 4:45 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 21st, 2008, 7:30 pm 
Offline

Joined: November 21st, 2007, 10:27 pm
Posts: 239
Location: 0x01101110
CraSH23000 wrote:
the problem is if w is released then it keeps going north west because I dont know how to check if both keys are up.


To check that use GetKeyState in the help file.


Last edited by Deller on April 22nd, 2008, 4:53 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 21st, 2008, 11:26 pm 
Offline

Joined: June 22nd, 2007, 4:42 am
Posts: 40
Yeah, I was thinking of using GetKeyState(), wasnt that familiar with it, but I think I get it now.

Code:
ScreenWidth := 795
ScreenHeight := 595

halfWidth := 400
halfHeight := 300

^+z::

loop
{

wIsD := GetKeyState("w")
aIsD := GetKeyState("a")
sIsD := GetKeyState("s")
dIsD := GetKeyState("d")

;MouseGetPos, saveXpos, saveYpos

if   (wIsD=1 and aIsD=0 and sIsD=0 and dIsD=0)   
{;W is Down
MouseClick, left, %halfwidth%, 5, 1, 0, D
}
else if (wIsD=0 and aIsD=1 and sIsD=0 and dIsD=0)
{;A is Down
MouseClick, left, 5, %halfHeight%, 1, 0, D
}
else if (wIsD=0 and aIsD=0 and sIsD=1 and dIsD=0)
{;S is Down
MouseClick, left, %halfWidth%, %ScreenHeight%, 1, 0, D
}
else if (wIsD=0 and aIsD=0 and sIsD=0 and dIsD=1)
{;D is Down
MouseClick, left, %ScreenWidth%, %halfHeight%, 1, 0, D
}
else if (wIsD=1 and aIsD=1 and sIsD=0 and dIsD=0)
{;W & A are Down
MouseClick, left, 5, 5, 1, 0, D
}
else if (wIsD=1 and aIsD=0 and sIsD=0 and dIsD=1)
{;W & D are Downs
MouseClick, left, %ScreenWidth%, 5, 1, 0, D
}
else if (wIsD=0 and aIsD=1 and sIsD=1 and dIsD=0)
{;S & A are Down
MouseClick, left, 5, %ScreenHeight%, 1, 0, D
}
else if (wIsD=0 and aIsD=0 and sIsD=1 and dIsD=1)
{;S & D are Down
MouseClick, left, %ScreenWidth%, %ScreenHeight%, 1, 0, D
}
else
{
MouseClick, left,,, 1, 0, U
}

}

;MouseMove, %saveXpos%, %saveYpos%

return


There is a problem though, after I use it, I cant drag anything. :?

_________________
Truth is truth, whether you believe it or not.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 22nd, 2008, 12:43 am 
Offline

Joined: April 9th, 2008, 8:46 am
Posts: 35
Location: Espoo, Finland
Ouch, is that an infinite loop i see there? How about using something like this instead:
Code:
SendMode, Input

ScreenWidth := 795
ScreenHeight := 595

halfWidth := 400
halfHeight := 300

clickX := halfWidth
clickY := halfHeight
wasdMoveActive := 0

w::
   clickY := 5
   Gosub, wasd_click
return
s::
   clickY := %ScreenHeight%
   Gosub, wasd_click
return
a::
   clickX := 5
   Gosub, wasd_click
return
d::
   clickX := %ScreenWidth%
   Gosub, wasd_click
return
w up::
   if (clickY < halfHeight)
      clickY := halfHeight
   Gosub, wasd_click
return
s up::
   if (clickY > halfHeight)
      clickY := halfHeight
   Gosub, wasd_click
return
a up::
   if (clickX < halfWidth)
      clickX := halfWidth
   Gosub, wasd_click
return
d up::
   if (clickX < halfWidth)
      clickX := halfWidth
   Gosub, wasd_click
return
   
wasd_click:
   if (clickX != halfWidth || clickY != halfHeight)
   {
      Click down %clickX% %clickY%
      if (!wasdMoveActive)
      {
         wasdMoveActive := 1
         MouseGetPos, mouseOldX, mouseOldY
      }
   }
   else
   {
      Click up
      if (wasdMoveActive)
      {
         wasdMoveActive := 0
         MouseMove, mouseOldX, mouseOldY
      }
   }
return


That aside, couldn't you move with the arrow keys in Diablo? If so, just remap them to wasd.

EDIT: Added MouseGetPos and MouseMove


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 22nd, 2008, 1:11 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
This should allow 8-direction movement (and can spam click optionally)

Code:
ScreenWidth := 795
ScreenHeight := 595

halfWidth := ScreenWidth/2
halfHeight := ScreenHeight/2

keys = wasd ; ULDR
SetDefaultMouseSpeed, 0

StringSplit, key, keys
Loop, Parse, Keys
   Hotkey, *$%A_LoopField%, TheTimer, on
Pause::Suspend

TheTimer:
SetTimer, TheMover, 5 ; this number is the speed adjustment, higher = slower
return

TheMover:
dx := GetKeyState( key4, "P" ) - GetKeyState( key2, "P" )
dy := GetKeyState( key3, "P" ) - GetKeyState( key1, "P" )
If !TheFlag
   MouseGetPos, memx, memy
If ( dx + dy*2 )
{
   TheSpam = Left Down
;////////////////////////// Uncomment the next line to stop the rapid-click
;   IfEqual, TheFlag, 1, StringReplace, TheSpam, TheSpam, Down, 0
   Click, % (halfwidth + Floor( halfwidth * 0.97 ) * dx) " "
      . (halfheight + Floor( halfheight * 0.97 ) * dy) " " TheSpam
   TheFlag = 1
}
else
{
   Click, Left Up
   Click, %memx% %memy% Left 0
   TheFlag = 0
   SetTimer, TheMover, off
}
return

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 22nd, 2008, 1:59 am 
Offline

Joined: June 22nd, 2007, 4:42 am
Posts: 40
orbik wrote:
Ouch, is that an infinite loop i see there?


I thought that would not be the best thing, :lol: then again its the only way I could figure out how to do diagonal combinations like:

"w & a" at the same to go north west
"w & d" at the same to go north east
"s & a" at the same to go south west
"s & d" at the same to go south east


orbik wrote:
That aside, couldn't you move with the arrow keys in Diablo? If so, just remap them to wasd.


The reason I'm making this script is because the game does not support moving with keyboard.

[VxE] wrote:
This should allow 8-direction movement (and can spam click optionally)


Thanks alot VxE works great, your script fixes issue I had with not being able to drag things.

EDIT: Sweet, I took your code and have my final version for this aspect of the program

Code:
ScreenWidth := 800
ScreenHeight := 585

halfWidth := ScreenWidth/2
halfHeight := ScreenHeight/2

keys = wasd ; ULDR
SetDefaultMouseSpeed, 0

StringSplit, key, keys
Loop, Parse, Keys
   Hotkey, *$%A_LoopField%, TheTimer, on
Pause::Suspend

TheTimer:
SetTimer, TheMover, 5 ; this number is the speed adjustment, higher = slower
return

TheMover:
dx := GetKeyState( key4, "P" ) - GetKeyState( key2, "P" ) ;Right - Left
dy := GetKeyState( key3, "P" ) - GetKeyState( key1, "P" ) ;Down - Up
If !TheFlag
   MouseGetPos, memx, memy
If ( dx + dy*2 )
{
   TheSpam = Left Down
;////////////////////////// Uncomment the next line to stop the rapid-click
;   IfEqual, TheFlag, 1, StringReplace, TheSpam, TheSpam, Down, 0
   Click, % (halfwidth + 50 * dx) " "
      . (halfheight + 50 * dy) " " TheSpam

   TheFlag = 1
}
else
{
   Click, Left Up
   Click, %memx% %memy% Left 0
   TheFlag = 0
   SetTimer, TheMover, off
}
return


I changed it so that it does not click to the edge of the screen because it was not ideal that if you just tapped "w, a, s or d" it would go all the way to the edge of the screen, when you may have wanted to only take a few steps.

NOTE:Ran into a problem with finding the center because it was not (400,300) like you would think, because the character is higher than the center.

_________________
Truth is truth, whether you believe it or not.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 22nd, 2008, 3:46 am 
Offline

Joined: April 9th, 2008, 8:46 am
Posts: 35
Location: Espoo, Finland
@VxE
While your code works, it's terribly inefficient by being based on a loop running at short intervals, and by repeating redundant arithmetic operations. The only advantage to my version is maintainability, by allowing easy redefinition of the movement keys. This should be addressed by using a better language (that supports higher level abstraction) instead of compromising performance. You also managed to make one part both hard to read and slow. Change If ( dx + dy*2 ) to If (dx | dy)
</rant>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 22nd, 2008, 6:27 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
orbik wrote:
@VxE
While your code works, it's terribly inefficient by being based on a loop running at short intervals, and by repeating redundant arithmetic operations. The only advantage to my version is maintainability, by allowing easy redefinition of the movement keys. This should be addressed by using a better language (that supports higher level abstraction) instead of compromising performance. You also managed to make one part both hard to read and slow. Change If ( dx + dy*2 ) to If (dx | dy)
</rant>

So sue me...

Really, what's your point? Are you disappointed to see code that hasn't been in development for at least 3 months? Or is it that you prefer your own spaghetti-code style to my semi-arcane style?

As for efficiency.... whoop-de-doo.... who's gonna notice?

And about easy redefinition of the keys, I think I've got you beat in that department since
I wrote:
keys = wasd ; ULDR
is unquestionably easier to deal with than 8 separate hotkeys.

Meh, anyone who's interested will just use whatever code they like better anyways. I suppose, If I really wanted to rewrite this code for myself, I'd use ControlClick instead of hijacking the mouse.

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2008, 5:19 pm 
Offline

Joined: February 14th, 2008, 10:07 pm
Posts: 72
Location: Santa Clara, CA
Hi CraSH,

I actually wrote a DiabloII leveling script not too long ago. It is pretty slick if I do say so myself. It will play endlessly, if you die it will recognize that fact and reload the last saved game.

I've been toying with the idea of posting it to the forum. I'll speed up my timeline if you are interested.

aobrien


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2008, 7:25 am 
Offline

Joined: June 22nd, 2007, 4:42 am
Posts: 40
Yes, I am very interested. I am curious how you are targeting enemies, and if your script works for multiple abilities and classes.

_________________
Truth is truth, whether you believe it or not.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 13th, 2008, 8:15 am 
Offline

Joined: February 14th, 2008, 10:07 pm
Posts: 72
Location: Santa Clara, CA
Hi Crash,
Sorry it took so long to reply... I don't check my personal email as much as I should.

I tried several different methods of targeting enemies, but came to the conclusion that it was just better to flail around and let them come to me (Use the shift key while clicking left-mouse), it is actually pretty effective.

I have used the script to level my Druid (Dimensional Blade - undestructible - kind of important) and Amazon archer.

I posted the script here:
Diablo 2 Expansion Auto-Leveling Script

aobrien


Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 23rd, 2010, 6:16 pm 
Hey I think you should make a video of how to change the diablo keys to work as you say cause im a little confused = P

MouseGetPos, saveXpos, saveYpos
MouseClick, left, %halfwidth%, 5, 1, 0, D
MouseGetPos, new_saveXpos, new_saveYpos
;msgbox, orig: %saveXpos%, %saveYpos% new: %new_saveXpos%, %new_saveYpos%
KeyWait w
;msgbox, w was released
MouseClick, left,,, 1, 0, U
MouseMove, %saveXpos%, %saveYpos%
return

a::
MouseGetPos, saveXpos, saveYpos
MouseClick, left, 5, %halfHeight%, 1, 0, D
MouseGetPos, new_saveXpos, new_saveYpos
KeyWait a
MouseClick, left,,, 1, 0, U
MouseMove, %saveXpos%, %saveYpos%
return

s::
MouseGetPos, saveXpos, saveYpos
MouseClick, left, %halfWidth%, %ScreenHeight%, 1, 0, D
MouseGetPos, new_saveXpos, new_saveYpos
KeyWait s
MouseClick, left,,, 1, 0, U
MouseMove, %saveXpos%, %saveYpos%
return

d::
MouseGetPos, saveXpos, saveYpos
MouseClick, left, %ScreenWidth%, %halfHeight%, 1, 0, D
MouseGetPos, new_saveXpos, new_saveYpos
KeyWait d
MouseClick, left,,, 1, 0, U
MouseMove, %saveXpos%, %saveYpos%
return
[/code]

But I do not know how I would make it work to allow you to go diagonal.

I was think of doing something like:

Code:
w & d::
MouseGetPos, saveXpos, saveYpos
MouseClick, left, %ScreenWidth%, 5, 1, 0, D
MouseGetPos, new_saveXpos, new_saveYpos
KeyWait d   ;THIS IS THE PROBLEM            
MouseClick, left,,, 1, 0, U
MouseMove, %saveXpos%, %saveYpos%
return


the problem is if w is released then it keeps going north west because I dont know how to check if both keys are up.


EDIT: Thanks to VxE, I've got a good script that I will probably add more to. Heres my final version so far:

Code:
ScreenWidth := 800
ScreenHeight := 585

halfWidth := ScreenWidth/2
halfHeight := ScreenHeight/2

keys = wasd ; ULDR
SetDefaultMouseSpeed, 0

StringSplit, key, keys
Loop, Parse, Keys
   Hotkey, *$%A_LoopField%, TheTimer, on
Pause::Suspend

TheTimer:
SetTimer, TheMover, 5 ; this number is the speed adjustment, higher = slower
return

TheMover:
dx := GetKeyState( key4, "P" ) - GetKeyState( key2, "P" ) ;Right - Left
dy := GetKeyState( key3, "P" ) - GetKeyState( key1, "P" ) ;Down - Up
If !TheFlag
   MouseGetPos, memx, memy
If ( dx + dy*2 )
{
   TheSpam = Left Down
;////////////////////////// Uncomment the next line to stop the rapid-click
;   IfEqual, TheFlag, 1, StringReplace, TheSpam, TheSpam, Down, 0
   Click, % (halfwidth + 50 * dx) " "
      . (halfheight + 50 * dy) " " TheSpam

   TheFlag = 1
}
else
{
   Click, Left Up
   Click, %memx% %memy% Left 0
   TheFlag = 0
   SetTimer, TheMover, off
}
return


I changed it so that it does not click to the edge of the screen because it was not ideal that if you just tapped "w, a, s or d" it would go all the way to the edge of the screen, when you may have wanted to only take a few steps.

NOTE:Ran into a problem with finding the center because it was not (400,300) like you would think, because the character is higher than the center.

EDIT: (4/22/08) Well, I liked the sound of ControlClick, because its nice to move the mouse while walking around with wasd, so heres the new script, complete with a hotkey (hold down alt+e) that picks up special items (browns, greens, yellows and blues) and some scripts I use to use skills:

Code:
SendMode Play

ScreenWidth := 800
ScreenHeight := 585

halfWidth := ScreenWidth/2
halfHeight := ScreenHeight/2

Skill := 0
xTL := 0
yTL := 0
xBR := 800
yBR := 553
Best1st := 1

keys = wasd ; ULDR
SetDefaultMouseSpeed, 0

StringSplit, key, keys
Loop, Parse, Keys
   Hotkey, $%A_LoopField%, TheTimer, on
Pause::Suspend

TheTimer:
SetTimer, TheMover, 5 ; change speed, higher = slower
return

TheMover:
dx := GetKeyState( key4, "P" ) - GetKeyState( key2, "P" ) ;Right - Left
dy := GetKeyState( key3, "P" ) - GetKeyState( key1, "P" ) ;Down - Up
If !TheFlag
   MouseGetPos, memx, memy
If (dx | dy)
{
   TheSpam = Left Down
;////////////////////////// Uncomment the next line to stop the rapid-click
;   IfEqual, TheFlag, 1, StringReplace, TheSpam, TheSpam, Down, 0

;   Click, % (halfwidth + 50 * dx) " "
;      . (halfheight + 50 * dy) " " TheSpam

    xval := halfwidth + 50 * dx
    yval := halfheight + 50 * dy
    ControlClick, x%xval% y%yval%, Diablo,,,, D

    TheFlag = 1
}
else
{
   MouseGetPos, memx, memy
   ;ControlClick, x%xval% y%yval%, Diablo
   Click, %xval% %yval% Left 1
   Click, %memx% %memy% Left 0
   TheFlag = 0
   SetTimer, TheMover, off
}
return

q::
tmp_Skill := Skill
Send, {f1}
Loop
{
    if not GetKeyState("q", "P" )
        break
    Sleep 250
    Click Right
}
Skill := tmp_Skill
Send {f%Skill%}
return

f::
tmp_Skill := Skill
Send, {f6}
Loop
{
    if not GetKeyState("f", "P" )
        break
    Sleep 250
    Click Right
}
Skill := tmp_Skill
Send {f%Skill%}
return

r::
tmp_Skill := Skill
Send, {f2}
Click Right
Sleep 450
Send, {f5}
Click Right
Skill := tmp_Skill
Send {f%Skill%}
return

e::
tmp_Skill := Skill
Send, {f4}
Click Right
Skill := tmp_Skill
Send {f%Skill%}
return

!e::

FileAppend, %Best1st%`n , C:\best1st.txt

if (Best1st < 3)
{
 xTL := 63
 yTL := 72
 Color := "0x588898" ;Gold Items
 Gosub, SearchnClick ;Pickup Golds
 xTL := 0
 yTL := 0
}
else if (Best1st > 2 and Best1st < 5)
{
 Color := "0x00C800" ;Green Items
 Gosub, SearchnClick ;Pickup Greens
}
else if (Best1st > 4 and Best1st < 7)
{

 Color := "0x205858" ;Yellow Items
 Gosub, SearchnClick ;Pickup Yellows
}
else if (Best1st > 6 and Best1st < 9)
{
 Color := "0xC85058" ;Blue Items
 Gosub, SearchnClick ;Pickup Blues
}
else
{
Best1st := 0
}

return

SearchnClick:

Send {Alt Down}
PixelSearch, Px, Py, %xTL%, %yTL%, %xBR%, %yBR%, %Color%, 1, Fast

 if ErrorLevel
 {
   Best1st := Best1st + 1
 }
 else
 {
   Px := Px+2
   Py := Py+5
   Click, %Px% %Py% Left 1
 }

return

!x::
Send {esc}{up}{enter}
return

~f1::
Skill := 1
return
~f2::
Skill := 2
return
~f3::
Skill := 3
return
~f4::
Skill := 4
return
~f5::
Skill := 5
return
~f6::
Skill := 6
return
~f7::
Skill := 7
return
~f8::
Skill := 8
return
~f9::
Skill := 9
return
~f10::
Skill := 10
return
~f11::
Skill := 11
return
~f12::
Skill := 12
return

LWin::
send {Alt}
return
[/quote]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 15th, 2011, 4:48 pm 
Offline

Joined: July 6th, 2011, 3:13 am
Posts: 7
Location: SouthEast Asia
SorryBut (or [VxE],

If your still around, I can't get SorryBut's FINAL version to work. How do you run it anyway, with AutoHotKey?

I tried that program, but when I run the script (w/ game), NOTHING happens. What am I doing wrong??

Does this work with any version of Diablo 2 and it's expansion?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 15th, 2011, 5:27 pm 
Offline

Joined: September 15th, 2009, 1:14 am
Posts: 562
I'll test it when I get some time today. I have to do some computer and tech support things today.

Edit: quick question, what version of AHK are you using? Basic or AHK_l? That way I can test it with that version if no one else replies with the solution before I am able to. (im on my phone at the dmv).

_________________
Disclaimer: I'm not an expert by any means; I just try to help out where I can.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 15th, 2011, 11:38 pm 
Offline

Joined: July 6th, 2011, 3:13 am
Posts: 7
Location: SouthEast Asia
codybear wrote:
I'll test it when I get some time today. I have to do some computer and tech support things today.

Edit: quick question, what version of AHK are you using? Basic or AHK_l? That way I can test it with that version if no one else replies with the solution before I am able to. (im on my phone at the dmv).

I'm using latest (I assume) AHK version, which 1.1

My operating system is Windows 7. I tried the tried the scripts with AHK, even created an .exe file. It seems to have no effect whatsoever. Does it require a patch version, or the expansion patch? The patch version I'm using is the old 1.08 expansion patch. I also have the one of the most recent patches, the 1.12 patch, just in case.

It's been said that Windows 7 is not AHK friendly.

I'm really quite new to this stuff, tried to do some tinkering, which often leads to no results.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot] and 22 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group