Skip to content

GetUserStatus [VB.NET]

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #186702
    autopilot
    Member

    Add status together when multiple status’ are present.

    • none = 0
    • cam = 1
    • red dot = 5
    • holding mic = 10
    • hand is raised = 20
    • So cam and mic = 11
    Public Function GetSLVUserStatus(ByVal lstviewhwnd As IntPtr, ByVal UserIndex As Integer) As Integer
    Dim Result, iReturn As Integer
    Dim myItem As LV_ITEMA
    Dim pHandle As Integer
    Dim pMyItemMemory As Integer
    Dim ProcessID As IntPtr
    '***********************************************************
    'open a handle to the process
    '***********************************************************
    Call GetWindowThreadProcessId(lstviewhwnd, ProcessID)
    pHandle = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, ProcessID)
    '************************************************************************************
    'initialize the local LV_ITEM structure
    'The myItem.iSubItem member is set to the index of the column that is being retrieved
    '************************************************************************************
    myItem.mask = LVIF_IMAGE Or LVIF_STATE
    myItem.iItem = UserIndex
    myItem.iSubItem = 0
    myItem.stateMask = &HFFFF
    '**********************************************************
    'write the structure into the remote process's memory space
    '**********************************************************
    pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem), MEM_COMMIT, PAGE_READWRITE)
    Result = WriteProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0)
    '*************************************************************
    'send the get the item message and write back the memory space
    '*************************************************************
    Result = SendMessage(lstviewhwnd, LVM_GETITEM, UserIndex, pMyItemMemory)
    Result = ReadProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0)
    '**************************************************
    'Read Image Index to get user status
    'cam = 1
    'red dot = 5
    'holding mic = 10
    'hand is raised = 20
    '**************************************************
    iReturn = myItem.iImage
    '**************************************************
    'deallocate the memory and close the process handle
    '**************************************************
    Result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE)
    Result = CloseHandle(pHandle)
    '**************************************************
    'Return the Status value
    '**************************************************
    Return iReturn
    End Function

    Note: May need to run as administrator!

    #186716
    autopilot
    Member

    for those looking for an easy way to detect if user is red dotted, you can do something like this:

    Private Function IsRedDotted(ByVal wHnd As IntPtr, ByVal iUserIndex As Integer) As Boolean
    Dim bReturn As Boolean = False
    Try
    Dim iStatus As Integer = mdlSysListView.GetSLVUserStatus(wHnd, iUserIndex)
    Select Case iStatus
    Case 5
    'MsgBox("Red Dot only")
    bReturn = True
    Case 6
    '1 + 5
    'MsgBox("On Cam + Red Dot")
    bReturn = True
    Case 15
    '5 + 10
    'MsgBox("Red Dot + On Mic")
    bReturn = True
    Case 16
    '1 + 5 + 10
    'MsgBox("On Cam + Red Dot + On Mic")
    bReturn = True
    Case 25
    '5 + 20
    'MsgBox("Red Dot + Hand Raised")
    bReturn = True
    Case 26
    '1 + 5 + 20
    'MsgBox("On Cam + Red Dot + Hand Raised")
    bReturn = True
    '************************************
    '* I dont think the rest are possible
    '************************************
    Case 35
    '5 + 10 + 20
    'MsgBox("Red Dot + On Mic + Hand Raised")
    bReturn = True
    Case 36
    '1 + 5 + 10 + 20
    'MsgBox("On Cam + Red Dot + On Mic + Hand Raised")
    bReturn = True
    Case Else
    ' No RedDot present
    bReturn = False
    End Select
    Catch ex As Exception
    
    End Try
    Return bReturn
    End Function

     

    #186715
    Chike
    Member

    I’d do something lie this:

    typedef enum UserStatusType {
    none = 0,
    cam = 1,
    reddot = 2,
    holdingmic = 4,
    handraised = 8
    };
    
    UserStatusType GetUserStatus(/*user name or index*/)
    {
    int iStatus = // Get status from list
    UserStatus Type rStatus = none;
    if (iStatus >= 20) {
    rStatus |= handraised;
    iStatus -= 20;
    }
    if (iStatus >= 10) {
    rStatus |= holdingmic;
    iStatus -= 10;
    }
    if (iStatus >= 5) {
    rStatus |= reddot;
    iStatus -= 5;
    }
    if (iStatus == 1) {
    rStatus |= cam;
    }
    return rStatus;
    }

    User can then check which ever status it is intersted in

    UserStatusType userStatu = GetUserStatus();
    if (userStatus & reddot) [
    // undot
    }

    However I am not sure all combinations are valid, e,g 15 should never be possible, and 25 is in question

    #186714
    AhFox
    Member

    Looks good … thanks!

    #186713
    Johnny5
    Member

    Use enum and return it, just random coding i did not actually test the code.

     

    Enum UserStatus
    RedDot = 5
    OnCamRedDot = 6
    RedDotHandRaised = 25
    End Enum
    
    Function GetUserStatus(ByVal wHnd As IntPtr, ByVal iUserIndex As Integer) As UserStatus
    Dim mUserStatus As UserStatus
    Dim iStatus As Integer = mdlSysListView.GetSLVUserStatus(wHnd, iUserIndex)
    mUserStatus = CType(iStatus , UserStatus)
    
    return mUserStatus
    End Function

     

    #186712
    Chike
    Member

    @Johnny5 wrote:

    Use enum and return it, just random coding i did not actually test the code.

    Enum UserStatus
    RedDot = 5
    OnCamRedDot = 6
    RedDotHandRaised = 25
    End Enum

    Function GetUserStatus(ByVal wHnd As IntPtr, ByVal iUserIndex As Integer) As UserStatus
    Dim mUserStatus As UserStatus
    Dim iStatus As Integer = mdlSysListView.GetSLVUserStatus(wHnd, iUserIndex)
    mUserStatus = CType(iStatus , UserStatus)

    return mUserStatus
    End Function

    What is exactly the point in converting integer to another form of integer that has the same values?

    #186711
    AhFox
    Member

    @Chike wrote:

    What is exactly the point in converting integer to another form of integer that has the same values?

    I believe using the ENUM … you have the Intelli-sense from Visual Studio … instead of using the numerical value.

    #186710
    Chike
    Member

    @NVYE wrote:

    @Chike wrote:

    What is exactly the point in converting integer to another form of integer that has the same values?

    I believe using the ENUM … you have the Intelli-sense from Visual Studio … instead of using the numerical value.

    And that’s make any logical difference?

    #186709
    AhFox
    Member

    No … doesn’t make it different … but it’s better to understand.

    In order words, instead of getSelectedUserStatus() return 1,2,3, or 4 now you’re getting DOTTED, ON_MIC, etcs. I rather prefer to have ENUM than to see numerical value, because I have to look into the dictionary to find out what 1 = ?, and 2 = ? …

    It’s the matter of choice … but ENUM definitely better choice.

    #186708
    Chike
    Member

    You don’t look at the code when it’s running and it makes mo sense to ask what you are looking for than all the possible combinations e.g. if dot or camdot, or, if cam or camdot or camhand, when it is only the dot or cam or mic you are looking for.

    #186707
    Chike
    Member

    @autopilot wrote:

    Add status together when multiple status’ are present.

    none = 0
    cam = 1
    red dot = 5holding mic = 10
    hand is raised = 20

    So cam and mic = 11

    2 more in v11.2
    hq cam = 2
    viewing cam = 4
    Updateed code

    typedef enum UserStatusType {
    none = 0,
    cam = 1,
    reddot = 2,
    holdingmic = 4,
    handraised = 8
    hq = 16
    viewing = 32
    };
    
    UserStatusType GetUserStatus(/*user name or index*/)
    {
    int iStatus = // Get status from list
    UserStatus Type rStatus = none;
    if (iStatus >= 20) {
    rStatus |= handraised;
    iStatus -= 20;
    }
    if (iStatus >= 10) {
    rStatus |= holdingmic;
    iStatus -= 10;
    }
    if (iStatus >= 5) {
    rStatus |= reddot;
    iStatus -= 5;
    }
    if (iStatus == 4) {
    rStatus |= cam | viewing;
    } else if (iStatus == 2) {
    rStatus |= cam | hq;
    } else if (iStatus == 1) {
    rStatus |= cam;
    }
    return rStatus;
    }

     

    #186706
    ChiNa
    Administrator

    //Edited / Deleted Topic!


    @AutoPilot
    , Thats Geniuse, So this is basicly getting the Mics/Hands by Images. Thank you Auto-Pilot. We really needed that function! But i never Thought of it that way lol! So Clever and Geniouse!


    @Chike
    , I been using Visual Studio Lately 🙁 Feeling so lost sometimes. Thanks for the Presentation.
    Pretty cool to get 2 new Options!

    @NYVE, I agree bro.. I prefer Enum as well.


    @Johnny5
    , Your Method is pretty Awesome, I checked it and works… Thanks mate!

    //Edited , Problem Solved…
    I had problems getting some of the Functions! But fixed.! The code below is what I am using now.
    And if I could get an idea about how to get the Win Handle ID for each time I start Paltalk, it could be great.

    My Code (Using Highlight Nic Method):

    The Win Handle and Index:

    Public ReadOnly Property Status() As String
    Get
    Return 69282 'Win Handle
    End Get
    End Property
    
    Public ReadOnly Property StatusIndex() As String
    Get
    Return 1 'Win Index
    End Get
    End Property

     

    Highlights Nickname First – Created a Sub for Nickname in the room as “User” in TextBox1

      Private Sub CheckStatus(ByVal User As String)
    If HighlightNic(TextBox1.Text) Then
    IsReddDot(Status, StatusIndex)
    Else
    MsgBox("User not Found!")
    End If
    End Sub

    And ofcourse for the Call I use:

    CheckStatus(TextBox1.Text)

    This is Johnny5’s Method can be used too, very Simple and works:

    GetUserStatus(Status, StatusIndex)

    Thanks a lot for the awesome work guys.. AutoPilot, Chike and Johhny5

    #186705
    Chike
    Member

    @ChiNa-Man wrote:

    And if I could get an idea about how to get the Win Handle ID for each time I start Paltalk, it could be great.

    I thought we’re done with controls handles long ago.

    #186704
    AhFox
    Member

    cool … thanks for the update.

    #186703
    ChiNa
    Administrator

    Thanks @Chike, I have forgotten all about that! Have to take a look. Thank you

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.