AutoHotkey Community

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

All times are UTC [ DST ]




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

Joined: November 18th, 2006, 7:56 pm
Posts: 305
[edited the thread's title to better reflect the current discussion topic]

Hi forum,

a standard script of mine (always running in the background) does an ImageSearch every certain fraction of a second.

The ImageSearch however unfortunately conflicts with one application (PDF-XChange Viewer) in that it closes the application's menus every time....... :(

This means I can't use any menus of PDF-XChange Viewer when at the same time my standard script is running (which is supposed to run all the time).

Any thoughts on what could cause this strange conflict, and what possibly could be done about it?

Thanks heaps already
David.P


Last edited by David.P on November 20th, 2009, 6:25 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 5th, 2009, 5:39 pm 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
oh well..... :oops:

Just added the line
Code:
IfWinNotActive,  - PDF-XChange Viewer

before that ImageSearch command.......

Still... it would be interesting to know what causes this conflict.

Cheers David.P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 5th, 2009, 5:56 pm 
Offline

Joined: October 26th, 2009, 6:29 am
Posts: 362
What is the image search for? Maybe theres another way better than image search.


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

Joined: November 18th, 2006, 7:56 pm
Posts: 305
Yeah, I wish there WERE another (reasonable) way than ImageSearch to do this.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 5th, 2009, 8:48 pm 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
David.P wrote:
Still... it would be interesting to know what causes this conflict.

The thread you reference was in August.
Post your code. Maybe we can find the conflict.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 5th, 2009, 10:31 pm 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
Well... here's the code:

Code:
;###########################
; Search where the Tray Icon of NaturallySpeaking is placed,
; watch the microphone on/off state and react if it is in the wrong state
;###########################

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
Send, {F10}  ; switch the mic off
}
}
Return


No idea here for another way to detect that microphone state other than doing the ImageSearch (which ImageSearch then conflicts with the menus of PDF XChange Viewer).

David.P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 5th, 2009, 11:53 pm 
Offline

Joined: October 26th, 2009, 6:29 am
Posts: 362
Off the top of my head... With no REAL thought... OnMessage ControlGet. 9 times out of 10 there is a MUCH better method than imagesearch that will be faster use less CPU and be fun to learn. Good luck


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 19th, 2009, 3:30 pm 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
Hi Ace and sorry that it took me such a long time to reply.

Thank you for sharing your ideas.

Below is what I could spy from the respective app's window, when the "mic on" or "mic off" keystrokes, respectively, are sent to that window:

Image

Do you think these messages could be used to find out whether that microphone symbol is green or red....?

Image
Image

Thanks heaps already,
Cheers David.P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 4:50 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
is the info shown by autoit window spy the same between the two states?

out of curiosity, why do you need to detect the state?
perhaps when you want it to be on, you can send the message to turn it on. If it's already on, it might not have a problem with that.

PixelGetColor? Hopefully won't interfere with the menus in the other program.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 5:01 pm 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
engunneer wrote:
is the info shown by autoit window spy the same between the two states?

I can't seem to find anything of the above messages with the AHK window spy... I thought the AHK window spy only shows window text and class names?

The reason for the need to find the mic state is that

a) the keystroke for "mic on" and "mic off" is the bloody same keystroke in that application, so I'm never quite sure about the state of that mic, and

b) the mic state on some occasions changes by itself, so the script should be notified and react accordingly....

Cheers David.P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 5:03 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
David.P wrote:
I can't seem to find anything of the above messages with the AHK window spy... I thought the AHK window spy only shows window text and class names?


It does, but perhaps the statusbar text gives a clue?

Does PixelGetColor interfere with your other program?

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 5:13 pm 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
engunneer wrote:
perhaps the statusbar text gives a clue?

Yes, that could be another way. But I'd rather catch those mic on/off messages directly (or something) in order not having to look for the statusbar text every few hundred milliseconds.

engunneer wrote:
Does PixelGetColor interfere with your other program?

This would be another possibility, but has the same drawback as above (having to watch that pixel color all the time).

Basically I'm looking for a way to check OR to control that microphone state DIRECTLY......

If only that application had DIFFERENT hotkeys for "mic on" and "mic off"....


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 5:16 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
does it have menu items instead of a hotkey that are different?

WinMenuSelectItem might do it.

Checking the statusbar constantly should not have issues for speed/performance

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 5:27 pm 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
Aaaaaaaaaaaaahhh could this be it???????

Image

Image

This should work without confusing the on and off states, shouldn't it.......???? :shock: :shock: :shock:

Or does WinMenuSelectItem actually OPEN the menu (visibly)?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 8:49 pm 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
Arghh that Dragon application has nonstandard menus which don't react on "WinMenuSelectItem".....!

And "PostMessage" is not applicable either, since it is the SAME stupid wm_command message for "mic on" and "mic off"....!

So is there any way that I can use this "wParam: 0x96012174, HDC: 0x96012174" stuff for "mic on" and "mic off" that Winspector gives me (see above table) -- maybe with OnMessage()...?


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 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], iDrug, Ohnitiel and 24 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