AutoHotkey Guide

CrazyBob's Cops And Robbers game information, help, faqs and guides. If you need help with something in game, this is the place!
User avatar
Nelle
Commissioner
Posts: 2684
Joined: Fri Jul 13, 2012 11:23 am

Re: AutoHotkey Guide

Post by Nelle » Fri May 08, 2015 6:45 pm

Instructions weren't clear enough. Got my dick stuck in the toaster.

JK, nice guide

User avatar
jawher7
Sergeant
Posts: 244
Joined: Sat Jul 09, 2011 3:15 pm
Gender: Male
Personal Saying: Enjoying the finest things in life
Location: Tunisia

Re: AutoHotkey Guide

Post by jawher7 » Wed May 27, 2015 6:14 am

Sea I simply use this cmd for a rdm lotto number with one button press each gameday (two acutally, alt+l for me) and it works as a charm

!l::
random, lotto, 1, 150
sendinput t/lotto %lotto%{enter}
return

hm well , I recently lost my fishlog that my friend made me years ago, ive never been into AHK sooo
cld u tell me how exactly can I stop the loop? i mean i used to press f3 to launch it and it used to automatically and infinitely fish each 10sec(the time needed between two fish attempts WHEN u have a Rod) and I press f10 when I wanted to completely stop the loop.
Copy paste here the cmd needed if u dnt mind and thanks!
Image

User avatar
laske
Commissioner
Posts: 2477
Joined: Wed Oct 30, 2013 7:32 pm
Gender: Male
Location: Serbia

Re: AutoHotkey Guide

Post by laske » Wed Jun 03, 2015 10:59 am

Great guide.
I was always wondering how to do random vehc but was too lazy to look it up.

Colgate
Captain
Posts: 892
Joined: Tue Aug 14, 2012 7:36 am
Gender: Male
Personal Saying: straight out africa, no shame, no guilt.

Re: AutoHotkey Guide

Post by Colgate » Thu Jul 16, 2015 8:16 am

how to use the numbers above azertyuiop

User avatar
SEA
CnR Admin
Posts: 1084
Joined: Sun Aug 01, 2010 12:49 am
Gender: Male
Location: Piccadilly Market
Contact:

Re: AutoHotkey Guide

Post by SEA » Thu Jul 16, 2015 8:26 am

ColgateCnR wrote:how to use the numbers above azertyuiop
Just type the number without any prefixes, like this:

Code: Select all

1:: SendInput t/lock{Enter}
or if you want to use a key combination, you can do something like this (SHIFT + 1):

Code: Select all

+1:: SendInput t/lock{Enter}
Blow my brain to fragments on an empty canvas - that's my last work of art for this fucked up planet

Colgate
Captain
Posts: 892
Joined: Tue Aug 14, 2012 7:36 am
Gender: Male
Personal Saying: straight out africa, no shame, no guilt.

Re: AutoHotkey Guide

Post by Colgate » Thu Jul 16, 2015 8:32 am

not working, can you make one and upload it please

Colgate
Captain
Posts: 892
Joined: Tue Aug 14, 2012 7:36 am
Gender: Male
Personal Saying: straight out africa, no shame, no guilt.

Re: AutoHotkey Guide

Post by Colgate » Thu Jul 16, 2015 9:04 am

jawher7 wrote:Sea I simply use this cmd for a rdm lotto number with one button press each gameday (two acutally, alt+l for me) and it works as a charm

!l::
random, lotto, 1, 150
sendinput t/lotto %lotto%{enter}
return

hm well , I recently lost my fishlog that my friend made me years ago, ive never been into AHK sooo
cld u tell me how exactly can I stop the loop? i mean i used to press f3 to launch it and it used to automatically and infinitely fish each 10sec(the time needed between two fish attempts WHEN u have a Rod) and I press f10 when I wanted to completely stop the loop.
Copy paste here the cmd needed if u dnt mind and thanks!
"my friend made me''? you never been here when anonybus was playing regulary 8)

anyways, here it is

(put a key to activate it)::

stopfish = false

random, fishsleep, 8000, 8500

loop

{

sendinput %finvtoggle%t/fish{enter}

sleep, %fishsleep%

if stopfish = true

break

}

return


(put a key to desactivate it)::

stopfish = true

return


!f12::

if finv =

finv = false

if finv = false

{

finvtoggle = t/finv{enter}

finv = true

}

else if finv = true

{

finvtoggle =
finv = false
}
return

User avatar
Evdeo
Lieutenant
Posts: 409
Joined: Mon Dec 19, 2011 12:46 pm
Gender: Male

Re: AutoHotkey Guide

Post by Evdeo » Thu Jul 16, 2015 9:37 am

Nice guide, Thanks!
Age is something that doesn't matter, unless you are a cheese.

User avatar
TR3
Commissioner
Posts: 3046
Joined: Wed Jan 30, 2013 4:35 am
Gender: Male
Personal Saying: Crazy Insane or Insane Crazy?
Location: Croatia
Contact:

Re: AutoHotkey Guide

Post by TR3 » Thu Jul 16, 2015 7:22 pm

SEA wrote:
Papi wrote:For e.g if my 'z' key is for /sit 8.
If i'm typing a sentence and i use z in chatbox, will that z alphabet be replaced by /sit 8 command?
Yes, because AHK doesn't detect whether the chat box is open or not.
Yes it does, if you program it to do so:

Just copy paste this into your file and you're good to go

Code: Select all

#UseHook

t::
Suspend On
SendInput t
Hotkey, Enter, On
Hotkey, Escape, On
Hotkey, t, Off
return

NumpadEnter::
Enter::
Suspend Permit
Suspend Off
SendInput {Enter}
Hotkey, t, On
Hotkey, Enter, Off
Hotkey, Escape, Off
return

Escape::
Suspend Permit
Suspend Off
SendInput {Escape}
Hotkey, t, On
Hotkey, Enter, Off
Hotkey, Escape, Off
return
Image

Evangelist
Commissioner
Posts: 3008
Joined: Fri Jan 06, 2012 4:52 am

Re: AutoHotkey Guide

Post by Evangelist » Thu Oct 20, 2016 6:12 am

I know this is kind of a bump, but since I've been asked a few questions regarding ahk, I'll post answers here.
Papi wrote:For e.g if my 'z' key is for /sit 8.
If i'm typing a sentence and i use z in chatbox, will that z alphabet be replaced by /sit 8 command?
In order to avoid "linking" binds as said in your example, you have to use $-sign in front of every key you want to bind.

Example 1:

Code: Select all

1::Sendinput t/lk{enter}
return

3::Sendinput t/dance 1{enter}
return
This set of binds does the following: When you press number 1 (above Q letter on the keyboard), it'll execute /lk command for you. But, if you press number 3, it'll execute /dance t/lk. So, this is good to avoid, because it obviously reduces number of keys we can use.

Example 2: But if you do it this way (with $-sign):

Code: Select all

$1::Sendinput t/lk{enter}
return

$3::Sendinput t/dance 1{enter}
return
This way you'll avoid underlined part from above, which means pressing 1 means /lk, and pressing 3 means /dance 1 (without that 1 being "converted" into /lk).


Another note: Some people say they're having troubles with having chatbox open. There are 2 ways to work around this, and here I'll explain them. TR3's code works as well, but there are a few solutions which are a bit more simple.
1. Making togglable ON/OFF key for your keybinds (using 2 keys)

Code: Select all

$F10::
	Suspend
	Suspend Off
return

$F11::
	Suspend On
return
Pressing F10 key will turn your keybinder ON, meaning your keybinds will work everywhere (yes, even when you open the chat box).
Pressing F11 key will suspend (read "pause"/disable) your keybinder.
Why is this good? Let's say you want to chat normally and be idle in CH. You press F11, and you can do whatever you like with your keyboard, without worrying if it'll write some nonsense on the chat. Once you are about to stop chatting, or just want to exit CH, you can press F10 once, and your binds are ready. If you feel like opening the chatbox again, press F11 again prior to doing so.

2. Making togglable ON/OFF key for your keybinds (using 1 key)

Code: Select all

$F10::
	Suspend Toggle
return
As you can read from this simple code, it works like this: press F10 to toggle your script on/off.

2. Making "automatic" turn on/off key
This will rely on the fact chatbox can be opened by pressing either F6 or t, and closed by pressing either ESC or enter. Therefore we can write this:

Code: Select all

~t::
	Suspend On
	return	
~F6::
	Suspend On
	return
~enter::
	Suspend Off
	return
~Esc::
	Suspend Off
	return
~ sign represents ahk's function which will NOT block that key's native function. It's somewhat similar to $-sign.
For more information, visit ahk's page on suspend command.

I've been also asked how to read chatlog. First of all, I don't support fully-automated gameplay. Secondly, I have 2 versions of how to read chatlog, and set your bind according to it, but the code is not "that" simple. I mean, it's not complicated, but I don't think pasting it here would help much.


As in real life, in programming idea is the main thing you start from. I don't think ahk is some serious programming, but still... it can be quite interesting once you realise the syntax and some other stuff. Regarding ahk, there are some interesting functions/commands which can be used in great number of ways. So start up your imagination, and be creative, that's all you need to make a decent keybinder, all by yourself.
.

Post Reply