AHK Howto - Wish I had known from the start

Helpful script writing tricks and HowTo's
User avatar
Chunjee
Posts: 1400
Joined: 18 Apr 2014, 19:05
Contact:

AHK Howto - Wish I had known from the start

04 Jun 2015, 22:18

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
Last edited by Chunjee on 12 Jun 2015, 14:49, edited 3 times in total.
User avatar
Joe Glines
Posts: 770
Joined: 30 Sep 2013, 20:49
Location: Dallas
Contact:

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

05 Jun 2015, 05:41

Good job breaking them down into nice sizable bits. I think this will help a lot of people new to programming and AutoHotKey. :)
Sign-up for the 🅰️HK Newsletter

ImageImageImageImage:clap:
AHK Tutorials:Web Scraping | | Webservice APIs | AHK and Excel | Chrome | RegEx | Functions
Training: AHK Webinars Courses on AutoHotkey :ugeek:
YouTube

:thumbup: Quick Access Popup, the powerful Windows folders, apps and documents launcher!
Guest

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

05 Jun 2015, 05:50

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
User avatar
Joe Glines
Posts: 770
Joined: 30 Sep 2013, 20:49
Location: Dallas
Contact:

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

05 Jun 2015, 06:50

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. :)
Sign-up for the 🅰️HK Newsletter

ImageImageImageImage:clap:
AHK Tutorials:Web Scraping | | Webservice APIs | AHK and Excel | Chrome | RegEx | Functions
Training: AHK Webinars Courses on AutoHotkey :ugeek:
YouTube

:thumbup: Quick Access Popup, the powerful Windows folders, apps and documents launcher!
User avatar
Gio
Posts: 1247
Joined: 30 Sep 2013, 10:54
Location: Brazil

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

13 Jun 2015, 10:27

Hello there :)

The tutorials are getting quite nice.

Congratulations and please keep up the videos. This will certainly help a lot of people. :thumbup:
Sander
Posts: 1
Joined: 20 Aug 2015, 09:54

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

20 Aug 2015, 09:59

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.
PADRAK
Posts: 2
Joined: 19 Oct 2015, 00:17

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

19 Oct 2015, 00:50

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!
User avatar
TheDewd
Posts: 1507
Joined: 19 Dec 2013, 11:16
Location: USA

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

19 Oct 2015, 14:10

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
User avatar
HinkerLoden
Posts: 93
Joined: 23 Mar 2016, 07:50
Contact:

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

27 Mar 2016, 04:10

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.
User avatar
Chunjee
Posts: 1400
Joined: 18 Apr 2014, 19:05
Contact:

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

31 Mar 2016, 17:51

Thanks for your ideas. I would like to pick this up again soon and get into some real projects.
User avatar
HinkerLoden
Posts: 93
Joined: 23 Mar 2016, 07:50
Contact:

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

02 Apr 2016, 12:42

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.
WhatIsWindows
Posts: 14
Joined: 02 Apr 2016, 05:00

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

04 Apr 2016, 15:33

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.
	}
}

kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

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

04 Apr 2016, 15:41

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.
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

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

04 Apr 2016, 15:48

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)
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
WhatIsWindows
Posts: 14
Joined: 02 Apr 2016, 05:00

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

04 Apr 2016, 16:29

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
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

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

04 Apr 2016, 16:43

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.
	}
 
}
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
WhatIsWindows
Posts: 14
Joined: 02 Apr 2016, 05:00

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

04 Apr 2016, 17:10

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 ?
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

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

04 Apr 2016, 17:15

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
rawr. fear me.
*poke*
Is it December 21, 2012 yet?

Return to “Tutorials (v1)”

Who is online

Users browsing this forum: No registered users and 38 guests