Audio Enabled in IM windows

In this forums, you can get help for any programming language.

Audio Enabled in IM windows

Postby Rontic » Sat Jul 05, 2008 2:20 am


Okay. I am currently working on a program that uses the SAPI voice interface to send out text to speech over chatrooms, and IM windows for a friend who is mute.
I need to be able to have my program know when the audio in an IM window is enabled.
If the audio in an IM window is not enabled, then there is no mic button.
When my program tries to lock down a mic button that isn't there, it causes Paltalk to crash.
I need a way to prevent this from happening accidently.
Can anybody tell me how to deal with this problem?
Rontic
 
Posts: 6
Joined: Sat Feb 16, 2008 4:03 pm

Re: Audio Enabled in IM windows

Postby String » Sat Jul 05, 2008 4:58 am

Your answer is in your question.

.....need to be able to have my program know when the audio in an IM window is enabled.


....If the audio in an IM window is not enabled, then there is no mic button.

Code: Select all
If ThereIsNoButton Then
   IM_AudioNotEnabled
End If
-= Please ask your questions in the forum, not in pm.
String
imFiles Senior
imFiles Senior
 
Posts: 310
Joined: Mon Mar 10, 2008 7:06 am
Location: IDE

Re: Audio Enabled in IM windows

Postby Rontic » Sat Jul 05, 2008 11:38 am

For some reason, my program still sees a button there, even if it's not visible. lol
Rontic
 
Posts: 6
Joined: Sat Feb 16, 2008 4:03 pm

Re: Audio Enabled in IM windows

Postby Chike » Sat Jul 05, 2008 12:48 pm

Rontic wrote:For some reason, my program still sees a button there, even if it's not visible. lol

Where is this "there: or if it is the button is sees or something else, is a key to the mystery.
Maybe you can rely on the menues instead, you can see what's in them and what it is always.
Image
Chike
imFiles Master
imFiles Master
 
Posts: 583
Joined: Sun May 13, 2007 6:20 pm

Re: Audio Enabled in IM windows

Postby Rontic » Sat Jul 05, 2008 5:54 pm

I'm going to see if the GetMenuState command will be of any help.
Rontic
 
Posts: 6
Joined: Sat Feb 16, 2008 4:03 pm

Re: Audio Enabled in IM windows

Postby Chike » Sat Jul 05, 2008 6:45 pm

Rontic wrote:I'm going to see if the GetMenuState command will be of any help.

It sure does. You can see if audio is active by the check state of "Audio On" and send the IM window the commands you need that are the menu ID of the submenu items of "Talk Mode".
Much easier than finding buttons.
Image
Chike
imFiles Master
imFiles Master
 
Posts: 583
Joined: Sun May 13, 2007 6:20 pm

Re: Audio Enabled in IM windows

Postby Rontic » Sat Jul 05, 2008 11:26 pm

Okay. This is what I have so far. It's written in Delphi...

Function AudioEnabled:Boolean;
Var dlggroupchatwindowclass: Longint;
itemcount:longint;
menuitemid:longint;
submenu:longint;
TheMenu:hmenu;
isamenu:longint;
itemstate:longint;
Begin
result:=false;
dlggroupchatwindowclass := FindWindowA('dlggroupchat window class', pchar(Roomname));
themenu:=GetMenu(dlggroupchatwindowclass);
submenu:=GetSubMenu(themenu,3);
if IsMenu(submenu) then
begin
itemcount:=GetMenuItemCount(submenu);
if (itemcount = 15) or (itemcount = 16) then
begin
itemstate:=GetMenuState(submenu,1,MF_BYPOSITION);
if (itemstate and 8 )=8 then
begin
result:=true;
end
else
begin
result:=false;
//menu might not be loaded
end;
end else
begin
result:=false;
//menu not loaded
end;
end else begin
result:=false;
end;
End;



The trouble now is, I have to open up and close the menu in order to refresh the information after the audio is added.

I hope somebody can give me the code numkber for the menu command.
I know it's simillar to how to open up the admin console, but I don't know what number to substute for the actions menu.
Then I have to close it after it's been opened. lol
Unless there's a better way.
Rontic
 
Posts: 6
Joined: Sat Feb 16, 2008 4:03 pm

Re: Audio Enabled in IM windows

Postby Chike » Sun Jul 06, 2008 4:27 am

Rontic wrote:if (itemcount = 15) or (itemcount = 16) then

Personally I would have check if the item name is "Action" rather depend on the count.
BTW put code in "Code"


Rontic wrote:The trouble now is, I have to open up and close the menu in order to refresh the information after the audio is added.

Not realy. You can trick paltalk to think you have :wink:
Code: Select all
SendMessage(hwnd, WM_INITMENUPOPUP, hmenu, nItem);
SendMessage(hwnd, WM_UNINITMENUPOPUP, hmenu, 0);

If it's the Action menu that need to be open then hmenu is themenu and nitem 3.


Rontic wrote:I hope somebody can give me the code numkber for the menu command.

Those you can find on the fly with GetMenuItemID

Didn't I tell you it is much easier than messin with the button? :mrgreen:
Image
Chike
imFiles Master
imFiles Master
 
Posts: 583
Joined: Sun May 13, 2007 6:20 pm

Re: Audio Enabled in IM windows

Postby Departure » Sun Jul 06, 2008 5:05 am

Wow about time we had another delphi programmer :D
anyway the WM_Command to turn audio on is 33346 so it would look something like

PostMessage(PalPMHandle,WM_COMMAND,33346,0);

P.s all you need is the PM window handle, once you have that just use the above line and it will be turned on :lol:
User avatar
Departure
Global Moderator
Global Moderator
 
Posts: 996
Joined: Thu Mar 17, 2005 11:26 am
Location: Australia

Re: Audio Enabled in IM windows

Postby Rontic » Sun Jul 06, 2008 11:28 am

I really have to thank you guys for all this info.
Now I can finish up the audio checking routine. :-)
Rontic
 
Posts: 6
Joined: Sat Feb 16, 2008 4:03 pm


Return to Programming Help

Who is online

Users browsing this forum: No registered users and 0 guests