Page 1 of 2

AHK Howto - Wish I had known from the start

Posted: 04 Jun 2015, 22:18
by Chunjee
Recorded some videos yesterday and today about getting started with AHK; the stuff I wish I had known from the start.

Little worried I might be going too fast but I want to get building real tools as quickly as possible because that is where I started to appreciate AHK most. Hope someone will find them useful.

Play all (playlist)

==Lesson One==
https://youtu.be/TLfY3mCxWd8
Setup, vars, =, :=, running scripts, msgbox

==Lesson Two==
https://youtu.be/yUcZOvzxDEc
Subroutines, Functions, Return, Scope, If, Else

==Lesson Three==
https://youtu.be/oO2bGT7FkWQ
#include, lib, Arrays/Objects, Imagesearch, Pixelsearch, Mousemove

==Lesson Four==
https://youtu.be/Ot2fnaWbDTA
FileRead, StrSplit, FileAppend

==Lesson Five==
https://youtu.be/E_sL2ntVnPo
RegEx, ||, &&, Continue, Break

==Lesson Six==
https://youtu.be/1PtHCsjd-Mw
GUIs, Timers

==Lesson Seven==
https://youtu.be/Uvjg3idUEUk
Run, RunWait, While

Re: AHK Howto - Wish I had known from the start

Posted: 05 Jun 2015, 05:41
by Joe Glines
Good job breaking them down into nice sizable bits. I think this will help a lot of people new to programming and AutoHotKey. :)

Re: AHK Howto - Wish I had known from the start

Posted: 05 Jun 2015, 05:50
by Guest
Videos are always nice, but code is often hard to read. Perhaps some tips for future videos, during the recording process:

- use white background + black text (better contrast)
- use a bigger font 16 or 20+ so people can actually read the code in the video

Re: AHK Howto - Wish I had known from the start

Posted: 05 Jun 2015, 06:50
by Joe Glines
When I record them I shrink my resolution which, in turn, bumps everything up. It looks ridiculously large to me when I'm recording the video but the clarity of text when viewing them is worth it. :)

Re: AHK Howto - Wish I had known from the start

Posted: 05 Jun 2015, 10:10
by joedf
Cool! :)

Re: AHK Howto - Wish I had known from the start

Posted: 12 Jun 2015, 14:49
by Chunjee
Added Lesson Seven
Run, RunWait, While

Re: AHK Howto - Wish I had known from the start

Posted: 13 Jun 2015, 10:27
by Gio
Hello there :)

The tutorials are getting quite nice.

Congratulations and please keep up the videos. This will certainly help a lot of people. :thumbup:

Re: AHK Howto - Wish I had known from the start

Posted: 20 Aug 2015, 09:59
by Sander
Hi, I've started following these tutorials and I find them well presented and interesting. I hope you keep going with them!

By the way http://downloadmob.com/Learn_AHK doesn't seem to be working.

Re: AHK Howto - Wish I had known from the start

Posted: 19 Oct 2015, 00:50
by PADRAK
So where exactly can I download the AutoHotkey module program that you use in your How To Videos?

I could use that for debugging my attempts to learn Script Files.

See my first post I made 5 minutes ago...

Thanks!

Re: AHK Howto - Wish I had known from the start

Posted: 19 Oct 2015, 14:10
by TheDewd
PADRAK wrote:So where exactly can I download the AutoHotkey module program that you use in your How To Videos?
AHK Studio by maestrith
http://autohotkey.com/board/topic/85996-ahk-studio/

https://www.google.com/?q=site:autohotk ... AHK+Studio

Re: AHK Howto - Wish I had known from the start

Posted: 27 Mar 2016, 04:10
by HinkerLoden
Nice . Prevents some silly questions inside the forum. But there are some things you should change.

1.) add the content into the Description - so its possible to find per search or even the google search will do it
2.) Reduce the lenght of Videos around 20 min or less . I think nr 5 is 40min - this is to long - just split it up.

For the first things its pretty good. Voice is clear. But try to take it all into an Example. Maybe give a kind of Homework at end of the HowTo. If you wanna get some more followers you need to animate your viewers to interact.

Re: AHK Howto - Wish I had known from the start

Posted: 31 Mar 2016, 17:51
by Chunjee
Thanks for your ideas. I would like to pick this up again soon and get into some real projects.

Re: AHK Howto - Wish I had known from the start

Posted: 02 Apr 2016, 12:42
by HinkerLoden
If you want we can do it together. I am now on in the progress to write a beginner HowTo. The critical point is where to begin and how to structure it . Getting good practical exercises. I thought about to have to each Category of the HowTo one Script where you exlplain the stuff. And another Project what get completed per each session as a kind of Homework and motivation for the people who want really learn it.

Re: AHK Howto - Wish I had known from the start

Posted: 04 Apr 2016, 15:33
by WhatIsWindows
Hey man, I started watching your tutorial and after the second vid I tried the function myself with different parameters and function names to remember the usage better but it keeps giving me the "Black" message and after that also gives the Else message and after that gives me a blank messagebox with nothing in it. I scanned the code again and again and I don't think I'm missing anything when I compare it to your code shown in video. Can you spot what's wrong? I'm stumped.

Code: Select all

#SingleInstance force
#NoEnv


Range = 75


MsgBox, % Fn_Convertlvl(Range)

ExitApp


Fn_Convertlvl(para_Range)
{
	If (para_Range = 75) {
		MsgBox, Black
		;Gives me this MsgBox as expected when range is 75
	}

	If (para_Range = 60) {
		Return 10
	}
	Else {
		MsgBox, 404
		;Gives me this MsgBox after first one even though it shouldn't
		; After 404 MsgBox it gives me a completely Blank MsgBox which is weird and I don't know what's wrong.
	}
}


Re: AHK Howto - Wish I had known from the start

Posted: 04 Apr 2016, 15:41
by kon
Try using if else if then else, instead of if if then else.

The blank message box you are seeing is because the function doesn't return anything so MsgBox, % Fn_Convertlvl(Range) shows blank. Try adding return, "example text" at the end of the function or in one of the if/else if/ else blocks.

Re: AHK Howto - Wish I had known from the start

Posted: 04 Apr 2016, 15:48
by tidbit
replace all the msgbox's inside the function with RETURN.
first it's checking if it's 75, if yes, show black. THEN since you didn't return (stop) the function, it goes to the next IF. since 75 isn't 60, it does the ELSE, shows 404.
but since you didn't return here either, it's not going to return any value to the msgbox outside the function, thus why you get a blank msgbox.

return command does a few things:
1) stops hotkeys/labels/other from going beyond that point (like a stop sign)
2) ends a function
3) gets a value out of a function (and ending the function)

Re: AHK Howto - Wish I had known from the start

Posted: 04 Apr 2016, 16:29
by WhatIsWindows
Okay, thanks for the info. I did as I understood and suggested and this is what I came up with.
It still gives me the blank box after the "Black" message box but only if the Range is 75. If I change it to 60 or any other number it gives the messagebox of 10 and 404 respectively without the blank box following it.
Spoiler

Re: AHK Howto - Wish I had known from the start

Posted: 04 Apr 2016, 16:43
by tidbit
you only need one return for each of those things, as for why you get a blank, it's now stopping because of the return in he " If (para_Range = 75) " section. and you never give it a value to return.

Code: Select all

#SingleInstance force
#NoEnv
 
 
Range = 75
 
 
MsgBox, % Fn_Convertlvl(Range)
 
ExitApp
 
 
Fn_Convertlvl(para_Range)
{
	If (para_Range = 75) {
		Return "Black" ; Text needs To be In quotes.
	;Gives a blank MsgBox after showing Black.
	;If I change MsgBox into Return, it just shows the blank MsgBox.
	}
 
	Else If (para_Range = 60) {
		Return 10
	;Works as intended with Range value being 60.
	}
	Else {
		Return, 404
	;Works as intended when Range value is anything but 60 or 75.
	}
 
}

Re: AHK Howto - Wish I had known from the start

Posted: 04 Apr 2016, 17:10
by WhatIsWindows
Alright, it works now. Thanks so much for explaining :D
One question though, how does it recognize Range value when the IF statement looks for para_Range value ?

Re: AHK Howto - Wish I had known from the start

Posted: 04 Apr 2016, 17:15
by tidbit
para_Range is the parameters name/variable.
you assign that var to the value of Range.
Range has the value of 75.
para_Range has the value of 75.
Image