Jump to content

HotKeySet


Recommended Posts

Hello all

I recently wrote this:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
HotKeySet("{ENTER}", "press")
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Computer Speak", 615, 176)
GUISetBkColor(0xC0C0C0)
$Label1 = GUICtrlCreateLabel("Computer Speak", 8, 8, 591, 33, BitOR($SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN))
GUICtrlSetFont(-1, 18, 800, 4, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xA6CAF0)
$Label2 = GUICtrlCreateLabel("Type Anything into the Box Below and hear the Computer Say It", 8, 56, 596, 28, BitOR($SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN))
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xA6CAF0)
$Input1 = GUICtrlCreateInput("", 8, 96, 593, 24)
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Speak", 32, 128, 553, 41)
GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Button1
$text = GUICtrlRead($Input1)
$voice = ObjCreate("SAPI.SpVoice")
$voice.speak($text)
GUICtrlSetData($Input1, "")
ControlClick("", "", "[CLASS:Edit; INSTANCE:1]")

EndSwitch
WEnd

Func press()
ControlClick("", "", "[CLASS:Button; INSTANCE:1]")
EndFunc

and it works, but one issue I have with it is that if the window is running whilst im doing something else, i.e. writing in word, because of the HotKeySet, it will not let me press Enter, is there any way to set it so that the HotKeySet only runs when the window is highlighted??

thanks

Edited by Noviceatthis
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...