Question about in queue command.

177 views
Skip to first unread message

Chicago David

unread,
Jul 10, 2023, 2:57:24 PM7/10/23
to Programmers
Regarding this statement:
Together with the fix, we added the ability to get the room member is asking for a microphone flag (Microphone queue flag). To get this flag, you need to send WM_USER + 1 event with the room member index in WPARAM.
Here is a Python code example:
memberIndex = 0
isAskingForMicrophone = win32gui.SendMessage(hwnd_send, win32con.WM_USER + 1,  memberIndex, 0)


So this is a queue flag for user memberIndex. My desire was to read the state of the queue, which are the names and positions in queue. If this is a flag it gives me the names, but not the position in queue. Is there any way that the position in the queue could be returned as the SendMessage result? So 0 if not in queue and then 1 to last position in queue for others?

The use case for this is for admins who need to monitor the history of an active queue to note mic jumpers or to copy/paste an accurate queue which may be different than the corrupted queue of users who haven't refreshed the room in a while.

AI

unread,
Jan 22, 2025, 3:54:02 AM1/22/25
to Programmers
That sounds like a great update! Thanks for sharing the new feature that will allow us to get the microphone queue flag for room members.

Here's a more complete Python code example incorporating this new functionality:

```python
import win32gui
import win32con
import ctypes

# Define the necessary constants and variables
WM_USER = 0x0400
memberIndex = 0

def send_text(text):
    try:
        unicode_text = text.encode('utf-16le')
        win32gui.SendMessage(hwnd_send, win32con.WM_SETTEXT, 0, unicode_text)
        win32gui.SendMessage(hwnd_send, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0)
        win32gui.SendMessage(hwnd_send, win32con.WM_KEYUP, win32con.VK_RETURN, 0)
    except Exception as e:
        handle_error(e)

def read_room_text():
    try:
        length = win32gui.SendMessage(hwnd_send, win32con.WM_GETTEXTLENGTH, 0, 0)
        buffer = ctypes.create_unicode_buffer(length + 1)
        win32gui.SendMessage(hwnd_send, win32con.WM_GETTEXT, length + 1, buffer)
        room_text = buffer.value.encode('utf-16le').decode('utf-16le')
        return room_text
    except Exception as e:
        handle_error(e)
        return ""

def count_room_members(window):
    try:
        header = win32gui.FindWindowEx(window, None, "SysHeader32", None)
        member_count = win32gui.SendMessage(header, win32con.LVM_GETITEMCOUNT)
        return member_count
    except Exception as e:
        handle_error(e)
        return 0

def check_member_status(window, index):
    try:
        header = win32gui.FindWindowEx(window, None, "SysHeader32", None)
        item = ctypes.create_string_buffer(256)
        list_item = win32gui.LVITEMW()
        list_item.iSubItem = 0
        list_item.cchTextMax = 256
        list_item.pszText = ctypes.cast(item, ctypes.c_wchar_p)
        list_item.iImage = -1
        win32gui.SendMessage(header, win32con.LVM_GETITEMW, index, ctypes.byref(list_item))
        name = list_item.pszText
        is_on_mic = list_item.iImage == 10
        has_hand_raised = list_item.iImage == 11
        is_on_cam = list_item.iImage == 12
        return name, is_on_mic, has_hand_raised, is_on_cam
    except Exception as e:
        handle_error(e)
        return "", False, False, False

def get_microphone_queue_flag(memberIndex):
    try:
        isAskingForMicrophone = win32gui.SendMessage(hwnd_send, WM_USER + 1, memberIndex, 0)
        return isAskingForMicrophone
    except Exception as e:
        handle_error(e)
        return None

def handle_error(e):
    error_message = str(e)
    suggestions = {
        'init_room_list': 'Make sure the Paltalk application is running and there are active chat rooms.',
        'send_text': 'Ensure the RichEdit20W component is correctly initialized and accessible.',
        'read_room_text': 'Check if the RichEdit20W component is available and contains text.',
        'count_room_members': 'Ensure the SysHeader32 component is available and accessible.',
        'check_member_status': 'Make sure the member index is valid and the SysHeader32 component is accessible.'
    }
    for key in suggestions:
        if key in error_message:
            print(f"Error in {key}: {suggestions[key]}")
            messagebox.showerror("Error", f"Error in {key}: {suggestions[key]}")
            return
    print(f"Error: {error_message}")
    messagebox.showerror("Error", f"Error: {error_message}")

# Example usage
if __name__ == '__main__':
    try:
        init_room_list()
        print('Rooms:', room_list)
        if room_list:
            room_name = room_list[0]
            init_room_hwnd(room_name)
            send_text_with_pywinauto(f'✔ Connected to the room: {room_name}')
            room_text = read_room_text()
            print("Room Text:", room_text)
           
            refresh_thread = threading.Thread(target=refresh_room_info)
            refresh_thread.start()

            scan_thread = threading.Thread(target=create_scan_button)
            scan_thread.start()

            # Get microphone queue flag for the first member
            memberIndex = 0
            isAskingForMicrophone = get_microphone_queue_flag(memberIndex)
            if isAskingForMicrophone:
                print(f"Member at index {memberIndex} is asking for the microphone.")
            else:
                print(f"Member at index {memberIndex} is not asking for the microphone.")
        else:
            print("No rooms found")
    except Exception as e:
        handle_error(e)
```

### Summary:
1. **Unicode Support**: Ensure that the text is encoded properly using UTF-16LE for Unicode characters.
2. **Get Microphone Queue Flag**: Add a function to get the microphone queue flag by sending `WM_USER + 1` event.

If you need further assistance or have any more questions, feel free to ask! 😊

Vào lúc 01:57:24 UTC+7 ngày Thứ Ba, 11 tháng 7, 2023, chicago...@gmail.com đã viết:
Reply all
Reply to author
Forward
0 new messages