Text selection and then icon selection

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
TRS80
Posts: 13
Joined: 23 Jun 2018, 21:18

Text selection and then icon selection

23 Jun 2018, 21:54

I have permanently lost my voice. To converse somewhat over the phone, I am using a "text to speech" program called Panopreter within Microsoft Word 2013. I want to press a hotkey (F12) after typing a phrase or sentence to speed up the conversation lag on my end. At the present time, when I finish typing a phrase or sentence in Microsoft Word, I have to pause, grab the mouse, drag backwards to highlight the line of text that I want spoken, then after completing the text selection, I have to move the mouse to the upper left area of the window under a tool ribbon where a small "play" button is located. (Panopreter functions as an Add-In in Word.) After I click on the play button, Panopreter converts the selected text to speech. To avoid handling the mouse altogether, I would like to press F12 at the end of a carriage return and Panopreter immediately start speaking for me. I don't know much about Autohotkey, but I appreciate what it does. I use it for some simple procedures. If someone could provide a starter script on how to go about this, I would be very grateful. Thanks!
Qysh
Posts: 143
Joined: 24 Apr 2018, 09:16

Re: Text selection and then icon selection

28 Jun 2018, 13:13

Without a config file (dont remove the empty lines!)

Code: Select all

;#####################################################






















;#####################################################
CoordMode, Mouse, Window
SetBatchLines, 1
F12::
	MouseGetPos, mx, my
	Click, %x%, %y%
	MouseMove, %mx%, %my%
return

^!F12::
	MouseGetPos, mx, my
	;Clipboard = x := %mx%`ny := %my%
	Run, NOTEPAD.EXE %A_ScriptFullPath%
	Sleep, 1000
	WinMaximize, %A_ScriptName%
	;140 128
	Click, 140, 128
	Send, x := %mx%`ny := %my%
	Sleep, 200
	Send, ^{s}
	Sleep, 200
	WinClose, %A_ScriptName%
	MsgBox, Coordinates saved! `nrestart the script!
return
With a config file:

Code: Select all

;#####################################################
IfExist, pos.ini
{
	IniRead, posX, pos.ini, Position, X
	IniRead, posY, pos.ini, Position, Y
}
IfNotExist, pos.ini
{
	MsgBox, Hover over the Play Button and press CTRL+Alt+F12 and restart the Script
	IniWrite, 0, pos.ini, Position, X
	IniWrite, 0, pos.ini, Position, Y
}
;#####################################################
CoordMode, Mouse, Window
SetBatchLines, 1
F12::
	MouseGetPos, mx, my
	Click, %posX%, %posY%
	MouseMove, %mx%, %my%
return

^!F12::
	MouseGetPos, mx, my
	IniWrite, %mx%, pos.ini, Position, X
	IniWrite, %my%, pos.ini, Position, Y
	ExitApp
return
TRS80
Posts: 13
Joined: 23 Jun 2018, 21:18

Re: Text selection and then icon selection

01 Jul 2018, 13:52

Hello: Qysh:

Thank you so much for your suggestions. I don't think I communicated my endeavor very well. See if this makes better sense.

Assume the Microsoft Word 2013 is showing on the active screen.

I am listening on the phone and when it is my turn to speak, I want to type in a line of text and press the F12 key.

The F12 key should

1. Append the word "Over" to the end of the line,

2. Send something similar to a control+Shift+Up Arrow key combo to Word to select and highlight the one or two lines of text that I just typed.

3. Click the mouse at position 16,89 (the play button) which causes Panoperter to convert the highlighted text to speech.

When the person on the other end of the phone conversation hears the last word, "over" they know I am finished.

This is my code, but it doesn't work. I need to select at least two lines of text and the second line doesn't execute at all.

F12:: Send ^+{Up}
Click 16,89
Return

Any suggestions on what I need to do are appreciated. AutoHotKey is an amazing program, I am a complete noob!
TRS80
Posts: 13
Joined: 23 Jun 2018, 21:18

Re: Text selection and then icon selection

02 Jul 2018, 17:17

Anyone: Why doesn't the second line of this code execute?

F12:: Send ^+{Up}
Click 16,89
Return

I need to select a line of text in Word 2013 (which the send instruction does) and then have a mouse click at coords 16,89 (to press a play icon button) but nothing happens. I'm puzzled.

Thanks!
gregster
Posts: 8988
Joined: 30 Sep 2013, 06:48

Re: Text selection and then icon selection

02 Jul 2018, 22:13

TRS80 wrote:Anyone: Why doesn't the second line of this code execute?

F12:: Send ^+{Up}
Click 16,89
Return

I need to select a line of text in Word 2013 (which the send instruction does) and then have a mouse click at coords 16,89 (to press a play icon button) but nothing happens. I'm puzzled.

Thanks!
If you have just one line to execute, it is allowed on the same line as the hotkey name (return is then implied). But if you want to execute more than one line, they all have to be beneath the hotkey name:

Code: Select all

F12:: 
Send ^+{Up}
Click 16,89
Return
Compare https://autohotkey.com/docs/Hotkeys.htm#Intro
hunter99
Posts: 129
Joined: 20 Jan 2014, 17:57

Re: Text selection and then icon selection

02 Jul 2018, 23:28

TRS80, try this:

Code: Select all

;================================================================================================
F12:: 
CoordMode, Mouse, Screen	            ;Sets coordinate mode
SendInput {Raw} over		            ;types in the word "over" (for this word, really don't need {Raw} but makes for cleaner reading.)
Send ^+{Up}				            ;your code -- highlights the text
Click, 16, 89  			                    ; (to press a play icon button) make sure this is the screen coordinates.
Return
;===============================================================================================
hunter99
TRS80
Posts: 13
Joined: 23 Jun 2018, 21:18

Re: Text selection and then icon selection

03 Jul 2018, 09:41

Hello gregster and hunter99:

Thank you both!!! Both solutions are working well! There's so much to know before doing simple things! :)

Best regards,
TRS80

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 252 guests