AutoHotkey Community

It is currently May 27th, 2012, 1:33 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: November 20th, 2009, 5:39 pm 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
David.P wrote:
ImageSearch conflicts with the menus of PDF XChange Viewer
F10 in Windows = "Goes to the menu mode"

Can you change it in DNS? (I use a SR prog which as default used ` key, which was a pain as scripting in ahk uses that, so i changed it to #!` (ctrl-alt-`)

Having "IfWinNotActive,..." before "ImageSearch" means if you stay in PDF-XChange for a time, your mic-correcting script won't be working
Instead, use ControlSend
Code:
MicImageSearch:
WinGetPos, trayX, trayY, trayWidth, trayHeight, ahk_class Shell_TrayWnd ; get tray area size & position
{
ImageSearch, MicIconX, MicIconY, trayX, trayY, trayX+trayWidth, trayY+trayHeight , *66 MicOff.png ; look for the red Mic Off icon in the task tray
If ErrorLevel = 0 ; if MicOff symbol is found but mic should be on, switch it on
{
IfEqual, Color, Green ; Var "Green" means that mic should be on
Send, {F9} ;switch the mic on
}
else
{
ImageSearch, MicIconX, MicIconY, trayX, trayY, trayX+trayWidth, trayY+trayHeight , *66 MicOn.png  ; look for the green Mic On icon
If ErrorLevel = 0 ; if MicOn symbol is found but mic should be off, switch it off
IfEqual, Color, Red ; Var "Red" means that mic should be off
ControlSend,, {F10}, <DNS>  ; switch the mic off
}
}
Return

So if in PDF-XChange (or any other program/window) wont Send F10 to it, but only to DNS

PS: Current (set up by DNS)...
Code:
~F10::
  ;(switch the mic off)
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 6:23 pm 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
Thanks for the hint regarding ControlSend! I'll try that.

Actually, the PDFXChange issue is not that much of a problem anymore (since now there's already two ways how to get around it) -- rather, the main problem now is the one that had been dicussed in the more recent posts, regarding the question how to reliably find out (or better: how to reliably control) that dogged red/green microphone state (off/on) of Dragon NaturallySpeaking:

Image
Image

It doesn't work with

- WinMenuSelectItem (app has nonstandard menus)
- PostMessage (app uses the same message for mic on and mic off)
- Hotkeys (dito same hotkey for mic on and off)
- ControlSend (dito no different controls for mic off/on available)

So basically I'm stuck with ImageSearch (yuck) or PixelGetColor (hmm) on that microphone icon... :?

I'd much rather find a way to control that microphone state directly without having to use the stopgap solution of constantly watching certain pixels on the screen..............


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 21st, 2009, 10:16 am 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
Sorry if this has already been discussed. I haven't followed the thread fully.

Quote:
ControlSend (dito no different controls for mic off/on available)

Maybe you can get the current status. And use postmessage or hotkeys to do the toggling.
Have you tried ControGet or ControlGetText to "read" from the control ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 21st, 2009, 11:29 am 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
Hi Leef and thanks for coming back to the thread. Actually I haven't tried ControlGet/ControlGetText yet since WindowSpy revealed nothing that would indicate the microphone state (well apart from maybe that statusbar text).

Thus, is it possible that ControlGet or ControlGetText will reveal anything more than what can be seen from the AHK Window Spy already...?

[edit:] ...can't use that statusbar text either since there is cases where it shows the exact same text whether the mic is on or whether it is off :(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2009, 11:52 am 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
OK. I found out that at least there is an ADDITIONAL hotkey in the Dragon app that switches the microphone off ONLY.

Thus, using this "OFF"-hotkey, now at least I can be sure that the mic actually is OFF afterwards.

The only problem still is that the other hotkey (the one that switches the mic ON) actually TOGGLES between the ON and OFF states of the microphone, so you can't be sure wheter you actually switched the microphone ON or OFF after having sent that hotkey....

And always switching it OFF first and only then ON again takes too much time....

So still looking for a way to "look inside that application"...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 24th, 2009, 1:35 pm 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
Another way would be to monitor all F9 keypresses
Of course can't use F9:: as that hotkey would override the DNS's hotkey routine for F9
But could use GetKeyState or KeyWait

However looking in process memory would probably be a more elgant way
---> See this


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 24th, 2009, 3:40 pm 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
Thank you for the two additional approaches.

For the moment, it seems as if I'd stick with ImageSearch because the process memory thing seems to go way over my head...

Thanks
David.P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2009, 10:06 am 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
OK I think I found the solution. It's actually very easy if I think about it.

The solution actually is NOT to use that Dragon microphone ON/OFF toggle function key at all in order to make sure that the microphone state is known at all times.

Luckily, the Dragon app has another hotkey called "press to talk". As long as this hotkey is held down, the mic is on, otherwise it is off.

So controlling the mic is really only a matter of making sure that this "press to talk" key is held down if the mic is supposed to be on. My script only has to check like every fraction of a second whether the mic is supposed to be on and if yes issue another "press to talk" key-down....

Switching the mic off and making sure it actually IS off is only a matter of sending a single "press to talk" keystroke...

Seems as if this solution has eradicated like a hundred lines of code that ineffectively had been trying to discover and if applicable correct the mic state... 8)

But thanks anyway to all participants for helping to break the "thought barrier".

Cheers David.P


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Blackholyman, bobbysoon, iDrug, Ohnitiel, Tipsy3000, Yahoo [Bot] and 17 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