AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

New to Autohotkey... HELP
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
moses



Joined: 05 Oct 2006
Posts: 6

PostPosted: Thu Oct 05, 2006 3:44 pm    Post subject: New to Autohotkey... HELP Reply with quote

hey people..
i just found this program.. a friend told me to try it out..

and well.. i was wondering... till now i was using a program called ACtool..
and i made a macro in it for a game i play.. gunz
i was wondering if it you can write somehting like the macro i was using
just in AutoHotkey..

here is the macro

Code:
SetActiveWindow Gunz
while 1=1
  while 1=1
   
    if {globalkeys} contains 087 //press w
      clearglobalkeys
      Keydown {space} 10
      Delay 90
      Keys w
      Delay 5
      Keys w
      Delay 7
      Leftmousedown
      Delay 5
      Leftmouseup
      Delay 25
      Keys Shift
      Delay 15
      clearglobalkeys
      Delay 5
    end if
   
    if {globalkeys} contains 083 // press s
      clearglobalkeys
      Keydown {space} 10
      Delay 90
      Keys s
      Delay 5
      Keys s
      Delay 7
      Leftmousedown
      Delay 5
      Leftmouseup
      Delay 25
      Keys Shift
      Delay 15
      clearglobalkeys
      Delay 5
    end if
   
    if {globalkeys} contains 068 // press d
      clearglobalkeys
      Keydown {space} 10
      Delay 90
      Keys d
      Delay 5
      Keys d
      Delay 7
      Leftmousedown
      Delay 5
      Leftmouseup
      Delay 25
      Keys Shift
      Delay 15
      clearglobalkeys
      Delay 5
    end if
   
    if {globalkeys} contains 065 //press a
      clearglobalkeys
      Keydown {space} 10
      Delay 90
      Keys a
      Delay 5
      Keys a
      Delay 7
      Leftmousedown
      Delay 5
      Leftmouseup
      Delay 25
      Keys Shift
      Delay 15
      clearglobalkeys
      Delay 5
    end if
   
    if {globalkeys} contains 049 //press 1 to stop
      clearglobalkeys
      Break
    end if
  END
 
  while 1=1
   
    if {globalkeys} contains 088 //press x
      clearglobalkeys
      Keydown {space} 10
      Leftmousedown
      Delay 5
      Leftmouseup
      Delay 255
      Keys w
      Delay 10
      Keys w
      Delay 5
      clearglobalkeys
      Delay 5
    end if
   
    if {globalkeys} contains 050 // press 2 to restart
      clearglobalkeys
      Restart
    end if
  end
end


its easy to understand.. but if u dont get something just ask me.
thanks ahead. Smile
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Thu Oct 05, 2006 4:09 pm    Post subject: Re: New to Autohotkey... HELP Reply with quote

moses wrote:
i was wondering if it you can write somehting like the macro i was using


Sure! Maybe even better.. Only that you have to concentrate and adapt
to AutoHotkey syntax style:

Code:
;SetActiveWindow Gunz
WinActivate Gunz

;if {globalkeys} contains 087 //press w
w::

;if {globalkeys} contains 083 // press s
s::

;if {globalkeys} contains 068 // press d
d::

;if {globalkeys} contains 065 //press a
a::

;if {globalkeys} contains 049 //press 1 to stop
1::

;if {globalkeys} contains 088 //press x
x::

;if {globalkeys} contains 050 // press 2 to restart
2::

;Keydown {space} 10
Send, {Space 10}

;Delay 90
Sleep 90

;Keys w
Send {W}

;Leftmousedown
Send {LButton Down}

;Leftmouseup
Send {LButton Up}

;Keys Shift
Send {Shift}

;Restart
Reload


In my guess, the lines in blue are the equivalent commands for ACTool ( those commented in green)

Regards, Smile
_________________
Back to top
View user's profile Send private message
TeknoMusicMan



Joined: 14 Apr 2005
Posts: 188
Location: Wisconsin, USA

PostPosted: Thu Oct 05, 2006 4:09 pm    Post subject: Reply with quote

I really doubt anyone is going to rewrite your code for you in AHK. You sould open up the AHK help file and use the search to find what your looking for.

To get you started heres a couple of the commands you would need


Keys in ACTool would be Send in AHK
Delay in ACTool would be Sleep in AHK

It's well worth your time to read at least the "Tutorial (quickstart)" section of the helpfile.
_________________

"Make it idiot-proof, and someone will make a better idiot."
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
moses



Joined: 05 Oct 2006
Posts: 6

PostPosted: Thu Oct 05, 2006 5:52 pm    Post subject: Reply with quote

thanks alot.. thats all i wanted to know..
the commands..
but one question...
if i use the hotkey "w"
and the command floowing it uses the "w" letter as well..
will it interfer with the sequence of the macro?
and if it does.. anyway to make it in a way thats it will not?
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Thu Oct 05, 2006 6:03 pm    Post subject: Reply with quote

moses wrote:
...
if i use the hotkey "w"
and the command floowing it uses the "w" letter as well..
will it interfer with the sequence of the macro?


Yes! It will interfere!
Suggestion:

use $w:: instead..

Regards, Smile
_________________
Back to top
View user's profile Send private message
moses



Joined: 05 Oct 2006
Posts: 6

PostPosted: Thu Oct 05, 2006 6:36 pm    Post subject: Reply with quote

thanks alot.. i rewrited the macro.. but one thing..
it doesnt work!! Confused

it wont stay in the loop.. when i press 1 it should break and go to the next loop till i press 2 and it will restart..

but its acting like there isnt any loop!!

the code..

Code:

WinActivate Gunz
  Loop{
   
    $w::
      Send, {Space 10}
      Sleep 90
      Send {W}
      Sleep 5
      Send {W}
      Sleep 7
      Send {LButton Down}
      Sleep 5
      Send {LButton Up}
      Sleep 25
      Send {Shift}
      Sleep 15
    return
   
    $s::
      Send, {Space 10}
      Sleep 90
      Send {S}
      Sleep 5
      Send {S}
      Sleep 7
      Send {LButton Down}
      Sleep 5
      Send {LButton Up}
      Sleep 25
      Send {Shift}
      Sleep 15
    return
   
    $d::
      Send, {Space 10}
      Sleep 90
      Send {D}
      Sleep 5
      Send {D}
      Sleep 7
      Send {LButton Down}
      Sleep 5
      Send {LButton Up}
      Sleep 25
      Send {Shift}
      Sleep 15
    return
   
    $a::
      Send, {Space 10}
      Sleep 90
      Send {A}
      Sleep 5
      Send {A}
      Sleep 7
      Send {LButton Down}
      Sleep 5
      Send {LButton Up}
      Sleep 25
      Send {Shift}
      Sleep 15
    return
   
    1::
      break
    return

  }
 
  Loop{
   
    x::
      Send, {Space 10}
      Send {LButton Down}
      Sleep 5
      Send {LButton Up}
      Sleep 255
      Send {W}
      Sleep 10
      Send {W}
      Sleep 5
    return
   
    2::
      Reload
    return

  }

Question Question Question
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Thu Oct 05, 2006 7:17 pm    Post subject: Reply with quote

moses wrote:
thanks alot.. i rewrited the macro.. but one thing..
it doesnt work!! Confused


The script does not require a Loop, I guess:

Code:
WinActivate Gunz
   
    $w::
      Send, {Space 10}
      Sleep 90
      Send {W}
      Sleep 5
      Send {W}
      Sleep 7
      Send {LButton Down}
      Sleep 5
      Send {LButton Up}
      Sleep 25
      Send {Shift}
      Sleep 15
    return
   
    $s::
      Send, {Space 10}
      Sleep 90
      Send {S}
      Sleep 5
      Send {S}
      Sleep 7
      Send {LButton Down}
      Sleep 5
      Send {LButton Up}
      Sleep 25
      Send {Shift}
      Sleep 15
    return
   
    $d::
      Send, {Space 10}
      Sleep 90
      Send {D}
      Sleep 5
      Send {D}
      Sleep 7
      Send {LButton Down}
      Sleep 5
      Send {LButton Up}
      Sleep 25
      Send {Shift}
      Sleep 15
    return
   
    $a::
      Send, {Space 10}
      Sleep 90
      Send {A}
      Sleep 5
      Send {A}
      Sleep 7
      Send {LButton Down}
      Sleep 5
      Send {LButton Up}
      Sleep 25
      Send {Shift}
      Sleep 15
    return
     
    $x::
      Send, {Space 10}
      Send {LButton Down}
      Sleep 5
      Send {LButton Up}
      Sleep 255
      Send {W}
      Sleep 10
      Send {W}
      Sleep 5
    return
   
    $2::
      Reload
    return


Regards, Smile
_________________
Back to top
View user's profile Send private message
moses



Joined: 05 Oct 2006
Posts: 6

PostPosted: Thu Oct 05, 2006 7:24 pm    Post subject: Reply with quote

but the loop is like for pausing it in a press of a butten..
any other way to do that?

EDIT: never mind dude.. i found it! tanks alot! just use suspend!!


Last edited by moses on Thu Oct 05, 2006 7:29 pm; edited 1 time in total
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Thu Oct 05, 2006 7:27 pm    Post subject: Reply with quote

moses wrote:
but the loop is like for pausing it in a press of a butten..


Why do you want to pause? Shocked
When run - the script does nothing but to wait for a Hotkey to be pressed!
You press W then the following action is done:

Code:
      Send, {Space 10}
      Sleep 90
      Send {W}
      Sleep 5
      Send {W}
      Sleep 7
      Send {LButton Down}
      Sleep 5
      Send {LButton Up}
      Sleep 25
      Send {Shift}
      Sleep 15


It is the same way for the other keys!

Regards, Smile
_________________
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Thu Oct 05, 2006 7:29 pm    Post subject: Reply with quote

A friendly suggestion:

You want to learn AutoHotkey, then better unlearn ACtool

Regards, Smile
_________________
Back to top
View user's profile Send private message
moses



Joined: 05 Oct 2006
Posts: 6

PostPosted: Thu Oct 05, 2006 7:30 pm    Post subject: Reply with quote

dude thanks for all ur help but i found what i was looking for..
suspend.. to stop the hotkeys...

i got one last question... anyway for me to make the script into a dll file?
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Thu Oct 05, 2006 7:33 pm    Post subject: Reply with quote

moses wrote:
i got one last question... anyway for me to make the script into a dll file?


Not in AutoHotKey...
Maybe you can try your luck with Visual basic!

Regards, Smile
_________________
Back to top
View user's profile Send private message
TeknoMusicMan



Joined: 14 Apr 2005
Posts: 188
Location: Wisconsin, USA

PostPosted: Thu Oct 05, 2006 7:35 pm    Post subject: Reply with quote

try my code.

I added #installkeybhook due to it being a game. and removed some {} you had in the send commands.

Code:
#InstallKeybdHook
WinActivate Gunz

$w::
Send, {Space 10}
Sleep 90
Send w
Sleep 5
Send w
Sleep 7
Send {LButton Down}
Sleep 5
Send {LButton Up}
Sleep 25
Send {Shift}
Sleep 15
return

$s::
Send, {Space 10}
Sleep 90
Send s
Sleep 5
Send s
Sleep 7
Send {LButton Down}
Sleep 5
Send {LButton Up}
Sleep 25
Send {Shift}
Sleep 15
return

$d::
Send, {Space 10}
Sleep 90
Send d
Sleep 5
Send d
Sleep 7
Send {LButton Down}
Sleep 5
Send {LButton Up}
Sleep 25
Send {Shift}
Sleep 15
return

$a::
Send, {Space 10}
Sleep 90
Send a
Sleep 5
Send a
Sleep 7
Send {LButton Down}
Sleep 5
Send {LButton Up}
Sleep 25
Send {Shift}
Sleep 15
return

$x::
Send, {Space 10}
Send {LButton Down}
Sleep 5
Send {LButton Up}
Sleep 255
Send w
Sleep 10
Send w
Sleep 5
return

$2::
Reload
return

_________________

"Make it idiot-proof, and someone will make a better idiot."
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
moses



Joined: 05 Oct 2006
Posts: 6

PostPosted: Thu Oct 05, 2006 7:35 pm    Post subject: Reply with quote

thnaks alot dude..
u were a great help Wink
Back to top
View user's profile Send private message
TeknoMusicMan



Joined: 14 Apr 2005
Posts: 188
Location: Wisconsin, USA

PostPosted: Thu Oct 05, 2006 7:37 pm    Post subject: Reply with quote

whops, bunch of people replied while i was tweaking your code Razz
_________________

"Make it idiot-proof, and someone will make a better idiot."
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group