AutoHotkey Community

It is currently May 27th, 2012, 10:37 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 39 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: December 20th, 2007, 1:50 am 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
New Version not tested !
Win Alt Z turns of voice recongintion (To Block out other noises)
Win Alt X ( Oppisite of Win Alt Z)

Dont Use The Mouse Use Your Voice!


this script lets you use your voice to left click or right click
without having to use the buttons which can cause strain on muscles causing you to have pain .



Once you hear started you may begin talking

Saying Left will produce a left click
saying right will produce a rightclick


2007-12-22 - Update .25
Everything the same except now you must use
CoHelper.ahk (Becasue of errors)
************************************
2007-12-07 - Update .20
Uses COM.ahk instead of CoHelper.ahk (Suggested By COM TTS & Sean)
Win Alt Z turns of voice recongintion (To Block out other noises)
Win Alt X ( Oppisite of Win Alt Z)
************************************
2007-12-07 - Update .15
Confirmed And Working
Faster Clicking as posted back by COM TTS
************************************
2007-12-07
Update .10 better word detection
although it is still not tested it should work


Need: CoHelper.ahk
Code:
http://www.autohotkey.net/~Sean/Scripts/CoHelper.zip


Code:
SetBatchLines -1
#NoEnv
#Include CoHelper.ahk
#Persistent
RegRead, Exist, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Speech, SDKPath
If Errorlevel = 1
    gosub NotFoundD
Else
    gosub Begin
return
Begin:
OnExit, CleanUp

CoInitialize()
pspeaker := ActiveXObject("SAPI.SpVoice")
plistener:= ActiveXObject("SAPI.SpSharedRecognizer")
pcontext := Invoke(plistener, "CreateRecoContext")
pgrammar := Invoke(pcontext, "CreateGrammar")
Invoke(pgrammar, "DictationSetState", 0)
prules := Invoke(pgrammar, "Rules")
prulec := Invoke(prules, "Add", "wordsRule", 0x1|0x20)
Invoke(prulec, "Clear")
pstate := Invoke(prulec, "InitialState")

; Add here the words to be recognized! Looks like it understands the null pointer.
Invoke(pstate, "AddWordTransition", "+" . 0, "Left")
Invoke(pstate, "AddWordTransition", "+" . 0, "Right")
;;
Invoke(prules, "Commit")
Invoke(pgrammar, "CmdSetRuleState", "wordsRule", 1)
Invoke(prules, "Commit")
ConnectObject(pcontext, "On")

If (pspeaker && plistener && pcontext && pgrammar && prules && prulec && pstate)
   Invoke(pspeaker, "Speak", "Started")
Else   Invoke(pspeaker, "Speak", "Starting Failed")
Return

CleanUp:
Release(pstate)
Release(prulec)
Release(prules)
Release(pgrammar)
Release(pcontext)
Release(plistener)
Release(pspeaker)
CoUninitialize()
ExitApp


OnRecognition(prms, this)
{
   Global   pspeaker
   presult := DispGetParam(prms, 3, 9)
   pphrase := Invoke(presult, "PhraseInfo")
   text =  % "" . Invoke(pphrase, "GetText")
  if disabled = 1
      return
  Else If disabled = 0
  If text = Left
       gosub Lefty
  Else If text = Right
       gosub Righty
  Release(pphrase)
}

NotFoundD:
url = http://download.microsoft.com/download/speechSDK/SDK/5.1/WXP/EN-US/SpeechSDK51.exe
fileName = SpeechSDK51.exe
saveDir = %A_mydocuments%
Progress, X0 Y63 h75 w430,, Download Main Component. Be Patient , Download , bold
         SetTimer, uProgress, 150
         totalFileSize := HttpQueryInfo(url, 5)
         UrlDownloadToFile, %url%, %fileName%
         SetTimer, uProgress, off
         Progress, Off
         FileMove,%fileName%,%saveDir%
         filegetSize,sizefil,%A_mydocuments%\%fileName%
         if(sizefil = 1638)
         goto,nofile
         msgbox,Download finished
         exitapp

nofile:          ; When the file is not found, it creates a file of 1638 bytes
{
filedelete,%A_mydocuments%\%fileName%
msgbox,File not found on the site.
}
Exitapp

uProgress:
   FileGetSize, fs, %fileName% ,K
   a := Floor(fs/totalFileSize * 100*1024)
   b := Floor(fs/totalFileSize * 10000*1024)/100
   SetFormat, float, 0.2
   b += 0
TFileSize := totalFileSize / 1024
Tfs=%TFileSize%
Progress,%a%,%b%`%        downloaded: %fs% Kb.    of     %Tfs% Kb.
return

HttpQueryInfo(URL, QueryInfoFlag=21, Proxy="", ProxyBypass="") {
hModule := DllCall("LoadLibrary", "str", "wininet.dll")
If (Proxy != "")
AccessType=3
Else
AccessType=1
io_hInternet := DllCall("wininet\InternetOpenA"
, "str", "" ;lpszAgent
, "uint", AccessType
, "str", Proxy
, "str", ProxyBypass
, "uint", 0) ;dwFlags
If (ErrorLevel != 0 or io_hInternet = 0) {
DllCall("FreeLibrary", "uint", hModule)
return, -1
}
iou_hInternet := DllCall("wininet\InternetOpenUrlA"
, "uint", io_hInternet
, "str", url
, "str", "" ;lpszHeaders
, "uint", 0 ;dwHeadersLength
, "uint", 0x80000000 ;dwFlags: INTERNET_FLAG_RELOAD = 0x80000000 // retrieve the original item
, "uint", 0) ;dwContext
If (ErrorLevel != 0 or iou_hInternet = 0) {
DllCall("FreeLibrary", "uint", hModule)
return, -1
}
VarSetCapacity(buffer, 1024, 0)
VarSetCapacity(buffer_len, 4, 0)
Loop, 5
{
  hqi := DllCall("wininet\HttpQueryInfoA"
  , "uint", iou_hInternet
  , "uint", QueryInfoFlag ;dwInfoLevel
  , "uint", &buffer
  , "uint", &buffer_len
  , "uint", 0) ;lpdwIndex
  If (hqi = 1) {
    hqi=success
    break
  }
}
IfNotEqual, hqi, success, SetEnv, res, timeout
If (hqi = "success") {
p := &buffer
Loop
{
  l := DllCall("lstrlen", "UInt", p)
  VarSetCapacity(tmp_var, l+1, 0)
  DllCall("lstrcpy", "Str", tmp_var, "UInt", p)
  p += l + 1
  res := res  . "`n" . tmp_var
  If (*p = 0)
  Break
}
StringTrimLeft, res, res, 1
}
DllCall("wininet\InternetCloseHandle",  "uint", iou_hInternet)
DllCall("wininet\InternetCloseHandle",  "uint", io_hInternet)
DllCall("FreeLibrary", "uint", hModule)
return, res
}

run, %Savedir%\%fileName%

msgbox, Extract the contents of this zip file to a folder then run Microsoft Speech SDK 5.1.msi

return


Lefty:
SendInput {LButton}
return

Righty:
SendInput {RButton}
return



#!z::
disabled = 1
return

#!x::
disabled = 0
return


Last edited by Fry on December 22nd, 2007, 3:57 pm, edited 5 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 20th, 2007, 3:05 am 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
anybody test yet


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 20th, 2007, 10:19 am 
Offline

Joined: January 20th, 2007, 1:29 pm
Posts: 96
Location: Melbourne
you can use a set of headphones in a pinch for a mic, walkman or mp3 player ones work a treat.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 20th, 2007, 2:34 pm 
explain more please


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 20th, 2007, 5:33 pm 
Offline

Joined: May 25th, 2007, 6:13 pm
Posts: 373
Trubbleguy wrote:
you can use a set of headphones in a pinch for a mic, walkman or mp3 player ones work a treat.

He means, that in a lot of cases, mics and headphones are so similarly made that you can use either/or. Using headphones as mics are not ideal but it can be done, to a lesser degree.

Dra'Gon

_________________
Image
For a good laugh {hopefully} >> megamatts.50megs.com

My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 20th, 2007, 10:44 pm 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
anybody use this yet


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 20th, 2007, 11:52 pm 
I have tested it and it works great.
Left click and right click, both are working, but a bit slow.
Thanks for the script


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2007, 12:05 am 
How about oth er words like "Play", "Stop"

Code:
OnRecognition(prms, this)
{
   Global   pspeaker
   presult := DispGetParam(prms, 3, 9)
   pphrase := Invoke(presult, "PhraseInfo")
   text =  % "" . Invoke(pphrase, "GetText")
   If text = Left
       gosub Lefty
  Else If text = Right
       gosub Righty
  Else if text = one
      gosub, 1
  else if text = two
      gosub, 2
  else if text = stop
      gosub, stop
  else if text = play
      gosub, play
     
  Release(pphrase)
}


Doesn't work :lol:
When I say, "play"
It invokes RIGHT CLICK

And other noise(keyboard typing sound triggers left click, sometimes right click)
Any suggestion?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2007, 12:11 am 
Offline

Joined: January 20th, 2007, 1:29 pm
Posts: 96
Location: Melbourne
straight out of Star Trek,
use a trigger word like,
COMPUTER

and yes a microphone and headphones coils are similiar in form and can be used as a mic, the headphone sounds a little dull but is usable.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2007, 12:32 am 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
awsome thanks for confirming this

also i will work to make it faster


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2007, 12:43 am 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
COM TTS to make words able to be recognized add them here



Code:
; Add here the words to be recognized! Looks like it understands the null pointer.
Invoke(pstate, "AddWordTransition", "+" . 0, "Left")
Invoke(pstate, "AddWordTransition", "+" . 0, "Right")
Invoke(pstate, "AddWordTransition", "+" . 0, "Play")

;;


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2007, 1:10 am 
Offline

Joined: October 28th, 2006, 2:14 am
Posts: 297
Location: US
Looks pretty cool, I can see a few uses for this , I wish logitech would send me my new headset soon though, its been like a month and I've not gotten them (I broke them somehow and sent it back :D)

_________________
Changed siggy at request of ahklerner :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2007, 1:28 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Better rewrite it to use COM.ahk instead of CoHelper.ahk.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2007, 1:51 am 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
why ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2007, 1:53 am 
Wow! Autohotkey appears to be starting to really take off in some interesting directions.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 39 posts ]  Go to page 1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 9 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group