Help me I'm blind.

Get help with using AutoHotkey and its commands and hotkeys
thomasmessi
Posts: 42
Joined: 22 Dec 2019, 17:33

Re: Help me I'm blind.

26 Dec 2019, 12:33

When executing the code did not present error, only the one that I mentioned above.

So if you have a solution to this error, the rest may work correctly.
I just used the code that is for NVDa. For we all who use audio programs use the nvda screen reader.
ahk7
Posts: 302
Joined: 06 Nov 2013, 16:35

Re: Help me I'm blind.

26 Dec 2019, 13:02

Edit:
for those looking for working code have a look at the "NVDA and AutoHotkey" post on the forum here https://www.autohotkey.com/boards/viewtopic.php?f=6&t=71172 and on GitHub here https://github.com/hi5/nvda-autohotkey

Perhaps if we simply try with the full path to the nvdaControllerClient32.dll it works. I modified the functions a bit in the script below and you should now change nvdapath to the full path to the DLL file. Fingers crossed it works

Code: Select all

/*

nvda functions by DojoMike from example_autohotkey.ahk
found at https://github.com/DojoMike/nvda/blob/d32552beffcb61e20bdccc6c730c14ddd87baa6d/extras/controllerClient/x86/example_autohotkey.ahk

nvdapath sets a variable we use in the functions at the end of the file,
apparently we need to have the full path to the DLL.
*/
 
; change nvdapath variable below to the path to nvdaControllerClient32.dll
Global nvdapath:="C:\program files\NVDA\nvdaControllerClient32.dll" 

test1:=nvdaController_testIfRunning()
if !test1
{
	; NVDA is not running, so provide some basic debug info.
	message := "NVDA is not running.  "
	if (Errorlevel)
	{
		message .= "The DLL call returned """ . test1 . """ and ErrorLevel was set to """ . ErrorLevel . """."
		message .= "Please refer to www.autohotkey.com for more information."
	}
	MsgBox % message
}
else
{
	; NVDA is running, so spreak and braille this information so the user knows.
	nvdaController_speakText("NVDA is running and script has started.")
	nvdaController_brailleMessage("NVDA is running and script has started.")
}

; This hotkey basically makes the S key work like Control (it makes NVDA stop talking)
Alt & s::nvdaController_cancelSpeech()

Alt & k::
MouseClick left, 250, 250
nvdaController_speakText("You pressed Alt & K")
Return

Alt & j::
MouseClick left, 200, 250
nvdaController_speakText("You pressed Alt & J")
Return


/*
 A part of NonVisual Desktop Access (NVDA)
 Copyright (C) 2007-2017 NV Access Limited, DojoMike
 This file is covered by the GNU Lesser General Public License, version 2.1.
 See the file license.txt for more details.

 DojoMike: Because AutoHotkey's DllCall function can be a bit tricky for newcomers, I've taken the liberty of creating the following wrapper functions.
 But of course, you could just as easily call the DLL directly, as I have done inside the functions.  But it might be easier to save the wrapper
 functions to a separate file and then including them (AutoHotkey has a #include directive similar to C++).
*/

nvdaController_testIfRunning()
{
	return DllCall(nvdapath . "\nvdaController_testIfRunning")
}

nvdaController_speakText(text)
{
	return DllCall(nvdapath . "\nvdaController_speakText", Str, text)
}

nvdaController_brailleMessage(text)
{
	return DllCall(nvdapath . "\nvdaController_brailleMessage", Str, text)
}

nvdaController_cancelSpeech()
{
	return DllCall(nvdapath . "\nvdaController_cancelSpeech")
}
Last edited by ahk7 on 01 Jan 2020, 04:40, edited 1 time in total.
thomasmessi
Posts: 42
Joined: 22 Dec 2019, 17:33

Re: Help me I'm blind.

26 Dec 2019, 14:00

Hi my noble friend.

I tried to copy the "nvdaControllerClient32.dll" dll to the folder path on my computer:

C: \ Program Files (x86) \ NVDA

but continues with the same message only from Msgbox command warning that "NVDA is not running. The DLL call returned" "and ErrorLevel was set to" -3 ". Please refer to www.autohotkey.com for more information."

I sincerely hope you don't get mad at me with so many questions and solution requests, my friend.

hugs.
ahk7
Posts: 302
Joined: 06 Nov 2013, 16:35

Re: Help me I'm blind.

26 Dec 2019, 14:07

Edit:
for those looking for working code have a look at the "NVDA and AutoHotkey" post on the forum here https://www.autohotkey.com/boards/viewtopic.php?f=6&t=71172 and on GitHub here https://github.com/hi5/nvda-autohotkey

So just to be sure I understand correctly. This test script works?

Code: Select all

nvdaIsRunning:=
DllCall("nvdaControllerClient32\nvdaController_testIfRunning", "int")
if(nvdaIsRunning = 0)
{
	result := DllCall("nvdaControllerClient32\nvdaController_speakText", "str", "NVDA Script is Working from AutoHotkey")
	if(errorLevel)
	{
		MsgBox, An error occured speaking through NVDA.
	}
ExitApp
Last edited by ahk7 on 01 Jan 2020, 04:40, edited 1 time in total.
thomasmessi
Posts: 42
Joined: 22 Dec 2019, 17:33

Re: Help me I'm blind.

26 Dec 2019, 15:06

Hello Friend

This is your last script test:

nvdaIsRunning: =
DllCall ("nvdaControllerClient32 \ nvdaController_testIfRunning", "int")
if (nvdaIsRunning = 0)
{
result: = DllCall ("nvdaControllerClient32 \ nvdaController_speakText", "str", "NVDA Script is Working from AutoHotkey")
if (errorLevel)
{
MsgBox, An error occured speaking through NVDA.
}
ExitApp

returned the following error:
ahk7
Posts: 302
Joined: 06 Nov 2013, 16:35

Re: Help me I'm blind.

26 Dec 2019, 16:22

I should have looked at it earlier but I thought NVDA was a paid program but it is free and I could install it in a portable manner so I did that. I managed to find the nvdaControllerClient DLLs both 32 and 64 bit versions and the script below works for me when using AutoHotkey 32 bit and AutoHotkey 64 bit so it shouldn't matter which version you are using.
I haven't installed any NVDA addons or extras so just the default voice and settings.
I hope it works on your computer as well.

Code: Select all

#NoEnv
#SingleInstance, force
SetBatchLines, -1

Alt & s::nvdaCancel()

Alt & k::
MouseClick left, 250, 250
nvdaSpeak("You pressed Alt & K")
Return

Alt & j::
MouseClick left, 200, 250
nvdaSpeak("You pressed Alt & J")
Return

nvdaSpeak(text)
	{
	 return DllCall("nvdaControllerClient" A_PtrSize*8 ".dll\nvdaController_speakText", "wstr", text)
	}

nvdaCancel()
	{
	 return DllCall("nvdaControllerClient" A_PtrSize*8 ".dll\nvdaController_cancelSpeech")
	}

nvdaBrailleMessage(text)
	{
	 return DllCall("nvdaControllerClient" A_PtrSize*8 ".dll\nvdaController_brailleMessage", "wstr", text)
	}

nvdaRunning() ; returns 0 if running
	{
	 return DllCall("nvdaControllerClient" A_PtrSize*8 ".dll\nvdaController_testIfRunning")
	}
For others:
thomasmessi
Posts: 42
Joined: 22 Dec 2019, 17:33

Re: Help me I'm blind.

26 Dec 2019, 17:06

Wonderful!!!

Now it worked!

You are awesome!

Now where will we put that message: "your script has been started". Is it similar to the script with microsft sap?

ISpVoice.Speak ("Your accessibility script has been started.")


I am very happy friend! Very happy indeed and you have no idea and can not imagine how great your gesture is!

If you allow me, I would like to be your friend of whatsapp, facebook or email.
ahk7
Posts: 302
Joined: 06 Nov 2013, 16:35

Re: Help me I'm blind.

26 Dec 2019, 17:23

Glad to hear it works - Indeed very similar to the Microsoft Voice, just add this line directly beneath the SetBatchlines, -1 line and it should speak the text when you start the script.

Code: Select all

nvdaSpeak("Your accessibility script has been started.")
Merry Christmas and Happy DJ-ing!
thomasmessi
Posts: 42
Joined: 22 Dec 2019, 17:33

Re: Help me I'm blind.

26 Dec 2019, 17:41

Perfect! It worked too!

Now I can put the other command lines above this line right ??

nvdaSpeak (text)
{
return DllCall ("nvdaControllerClient" A_PtrSize * 8 ".dll \ nvdaController_speakText", "wstr", text)
}

nvdaCancel ()
{
return DllCall ("nvdaControllerClient" A_PtrSize * 8 ".dll \ nvdaController_cancelSpeech")
}

nvdaBrailleMessage (text)
{
return DllCall ("nvdaControllerClient" A_PtrSize * 8 ".dll \ nvdaController_brailleMessage", "wstr", text)
}

nvdaRunning (); returns 0 if running
{
return DllCall ("nvdaControllerClient" A_PtrSize * 8 ".dll \ nvdaController_testIfRunning")
}


this part of the code will always be at the end right?
thomasmessi
Posts: 42
Joined: 22 Dec 2019, 17:33

Re: Help me I'm blind.

26 Dec 2019, 20:16

Hello Friend. I managed to enter the other commands and everything is working very well.
You did a great job.

I want to ask you now a question as to whether it is possible:

when doing the line "MouseClick right, 350, 350

; moves the mouse to the 350, 350 coordinate and opens a context menu.

  with 16 options. channel 1 through 16

Is there a possibility to make this context menu appear for my screen reader, and with the arrow keys scroll through the options and select any of them by pressing enter ???

like this:

alt control & shift c ::
MouseClick right, 350, 350
nvdaSpeak ("choose channel")

; by clicking on this option I would like to open a text menu and with the right arrow I will open another menu with options in the list from 1 to 16 and by clicking enter mark the channel
Return

thanks for listening.
hugs
ahk7
Posts: 302
Joined: 06 Nov 2013, 16:35

Re: Help me I'm blind.

27 Dec 2019, 12:54

You can add more hotkeys to the script, it doesn't matter that much where as long as it below the "Your accessibility script has been started." line.

I'm assuming that :

1. nvda doesn't see the context menu in your music program and therefore can't see the select channel menu

2. sending the appskey will show the context menu - if it doesn't you can try to replace {appskey} in the script below with {Rbutton}

I added two hotkeys in the script below:

1. alt ctrl shift c, this shows a menu with 16 channels which nvda can read. I added the & to each menu channel name so you can just press 5 to jump between channel 5 and 15, if you don't like that simply remove the & characters from each Menu line.

2. alt ctrl shift d, this shows an input box so you can enter a number. This is just to illustrate an alternative method or perhaps something you can use later.

There are more elegant or efficient ways to build a menu in AutoHotkey but this is very simple. So you can easily to build more menus if you need them.
Just make sure you give each menu a name - here it is MyChannelMenu - and a menu handler label - here it is MyChannelMenuHandler.

More information about Menus in AutoHotkey here https://www.autohotkey.com/docs/commands/Menu.htm

I hope it works.

Code: Select all

#NoEnv
#SingleInstance, force
SetBatchLines, -1

nvdaSpeak("Your accessibility script has been started.")

!^+c:: ; alt-control-shift-c
MouseClick right, 350, 350
nvdaSpeak ("choose channel")
Gosub, ChannelMenu
Return

!^+d:: ; alt-control-shift-d
MouseClick right, 350, 350
InputBox, Channel, Choose channel, Choose channel (enter number)
If ErrorLevel
	{
	 nvdaSpeak("You canceled")	
	 Return
	}
If Channel is not number
	{
	 nvdaSpeak("Incorrect number")	
	 Return
	}	
Send {Appskey}
Sleep 100 ; give the context menu some time to appear
Send {down %Channel%}	
Return


Alt & s::nvdaCancel()

Alt & k::
MouseClick left, 250, 250
nvdaSpeak("You pressed Alt & K")
Return

Alt & j::
MouseClick left, 200, 250
nvdaSpeak("You pressed Alt & J")
Return

nvdaSpeak(text)
	{
	 return DllCall("nvdaControllerClient" A_PtrSize*8 ".dll\nvdaController_speakText", "wstr", text)
	}

nvdaCancel()
	{
	 return DllCall("nvdaControllerClient" A_PtrSize*8 ".dll\nvdaController_cancelSpeech")
	}

nvdaBrailleMessage(text)
	{
	 return DllCall("nvdaControllerClient" A_PtrSize*8 ".dll\nvdaController_brailleMessage", "wstr", text)
	}

nvdaRunning() ; returns 0 if running
	{
	 return DllCall("nvdaControllerClient" A_PtrSize*8 ".dll\nvdaController_testIfRunning")
	}

; the & characters below make that number a shortcut, so you can type 5 and jump between channel 5 and 15
; if you don't like that remove the & characters
ChannelMenu:
Menu, MyChannelMenu, Add
Menu, MyChannelMenu, DeleteAll
Menu, MyChannelMenu, Add, Channel &1,  MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel &2,  MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel &3,  MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel &4,  MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel &5,  MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel &6,  MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel &7,  MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel &8,  MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel &9,  MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel 1&0, MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel 1&1, MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel 1&2, MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel 1&3, MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel 1&4, MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel 1&5, MyChannelMenuHandler
Menu, MyChannelMenu, Add, Channel 1&6, MyChannelMenuHandler
Menu, MyChannelMenu, Show	
Return
	
MyChannelMenuHandler:
Send {Appskey}
Sleep 100 ; give the context menu some time to appear
Send {down %A_ThisMenuItemPos%}	
Return
thomasmessi
Posts: 42
Joined: 22 Dec 2019, 17:33

Re: Help me I'm blind.

27 Dec 2019, 17:29

Wow, awesome!

Now I need to link, when choosing channel 3 for example going down with the arrow keys, hit enter and confirm channel 3.

But excellent this form of menu when making the command and appearing the options.

In this case the task is more complicated because with this script we are recreating the interface with the script is not it?

I wanted to show you how it is getting through a video. I would record my screen with obs studio and you would see how it works and could give other ideas.

And my blind friends found the breakthroughs super amazing and I quoted you for the gigantic help. Although I don't know your name.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bartimus, teadrinker, XShayanX and 54 guests