Code on a single line

Get help with using AutoHotkey and its commands and hotkeys
gerard
Posts: 34
Joined: 01 Apr 2020, 13:14

Code on a single line

25 May 2020, 06:30

I hope they are very good.
It is not my intention to start a discussion about whether or not to accumulate code on a single line. But many times I find myself repeating things that would be simpler to read like this.
I just wish I could put a voice tag for my screen reader, and a click.
I usually do it like this:

Code: Select all

#f::
	Click, Left, 222, 333, 2
	Speak("Beta")
	Return

#g::
	Click, Left, 444, 555, 2
	Speak("Gama")
	Return

Speak(text)
	{
	return DllCall("nvdaControllerClient" A_PtrSize*8 ".dll\nvdaController_speakText", 		"wstr", text)
	}
Something like :

Code: Select all

#f::Speak("Beta",222,333,Left,2)
#g::Speak("Gama",444,555,Left,2)

Speak(text)
	{
	return DllCall("nvdaControllerClient" A_PtrSize*8 ".dll\nvdaController_speakText", "wstr", 	text)
	}
Helgef
Posts: 4414
Joined: 17 Jul 2016, 01:02
Contact:

Re: Code on a single line

25 May 2020, 06:40

You could write a speakAndClick() function.

Cheers.
User avatar
Chunjee
Posts: 524
Joined: 18 Apr 2014, 19:05
GitHub: Chunjee

Re: Code on a single line

25 May 2020, 10:03

Could do something like:

Code: Select all

fn_SpeakAndClick(text, x:="", y:="")
{
	if (x != "" && y != "") {
		Click, Left, %x%, %y%
	}
	return DllCall("nvdaControllerClient" A_PtrSize*8 ".dll\nvdaController_speakText", "wstr", 	text)
}
Rohwedder
Posts: 3133
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Code on a single line

25 May 2020, 10:51

Or use jeeswgs commands as functions (AHK v2 functions for AHK v1):

Code: Select all

#f::Click(222,333,2),Speak("Beta")
#g::Click(444,555,2),Speak("Gama")

Speak(text)
	{
	return DllCall("nvdaControllerClient" A_PtrSize*8 ".dll\nvdaController_speakText", 		"wstr", text)
	}
Click(Params*)
{ ;https://autohotkey.com/boards/viewtopic.php?f=37&t=29689&p=210818#p210818
    local i, Param, Args
    for i, Param in Params
        Args .= " " . Param
    Click %Args%
}
gerard
Posts: 34
Joined: 01 Apr 2020, 13:14

Re: Code on a single line

25 May 2020, 13:24

Thank you!
With the first answer I had thought of something like this:

Code: Select all

#f::Speak("Beta",46,162,"Left,2")
#g::Speak("Gama",139,162,"Left,2")

Speak(text,xCoord,yCoord,Key)
	{
	Click,% xCoord "," yCoord "," Key ""
	return DllCall("nvdaControllerClient" A_PtrSize*8 ".dll\nvdaController_speakText", "wstr", 	text)
	}
But I loved this last option jeeswgs commands
Thanks again for the answers.

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, c7aesa7r, NOLLIE, TAC109 and 48 guests