Skip to content

visual Basic Paltlalk ban

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #190834
    Snoopy1968
    Member

    im trying to create a ban procedure for admins with the code below
    but everytime it gets to the window where it says Ban User my program
    freeses anyone any ideas

    Dim x As Long, editx As Long, button As Long
    Dim console As Long

    If (Text38 = “”) Then
    PalAdmin
    Text38 = Trim(AdmnConsole)
    Else

    DoEvents
    Timer8.Enabled = False
    console = FindWindow(“#32770”, Text38)
    x = FindWindowEx(console, 0&, “ComboBox”, vbNullString)
    editx = FindWindowEx(x, 0&, “Edit”, vbNullString)
    Call SendMessageByString(editx, WM_SETTEXT, 0&, “abc”)
    button = FindWindowEx(console, 0&, “button”, “Ban Selected User”)
    Call SendMessageLong(button, WM_KEYDOWN, VK_SPACE, 0&)
    Call SendMessageLong(button, WM_KEYUP, VK_SPACE, 0&)
    DoEvents

    PalBan

    x = FindWindow(“#32770”, BanWindow)

    button = FindWindowEx(x, 0&, “button”, “Yes”)
    Call SendMessageLong(button, WM_KEYDOWN, VK_SPACE, 0&)
    Call SendMessageLong(button, WM_KEYUP, VK_SPACE, 0&)

    Text38 = “”

    End If

    #190848
    Departure
    Member

    Its hard to say without seeing the rest of code, but just out of a long shot i would add buttonX or something like that for the second window that appears?

    you have

    x = FindWindow(“#32770”, BanWindow)
    button = FindWindowEx(x, 0&, “button”, “Yes”)
    Call SendMessageLong(button, WM_KEYDOWN, VK_SPACE, 0&)
    Call SendMessageLong(button, WM_KEYUP, VK_SPACE, 0&)

    But this proberly no big issue and maybe wont make any diffrence, but you already set x and button on the previouse findwindow API, but like i said its hard to tell without seeing the functions that have been called. Also this only a guess because I have’nt actually tryed it, but I will look at finding the console window and placing ban now and ill post the code I get from making such a routine

    #190847
    Snoopy1968
    Member

    What seems to happen is that the function PalBan doesnt produce BanWindow, BanWindow is a varible of type strring setup at the top of the code i have tried to see what it does produce there seems to be a verry long wait before it sees it though in real time the ban window is proucded almost imdediatley for the life i cant figure out why
    Public Function EnumWindowsProc6(ByVal hndle As Long, ByVal parm As Long) As Boolean

    Dim sSave As String, Ret As Long
    Ret = GetWindowTextLength(hndle)
    sSave = Space(Ret)
    GetWindowText hndle, sSave, Ret + 1

    If InStr(sSave, “Ban User”) Then

    Lnghnd2 = Str$(hndle)
    BanClass = GetClass(Lnghnd2)
    BanWindow = GetWinTitle(Lnghnd2)
    End If
    EnumWindowsProc6 = True

    End Function
    Public Function PalBan(Optional strClassname1 As String) As Long
    Dim retval As Boolean
    retval = EnumWindows(AddressOf EnumWindowsProc6, 0)
    strClassname1 = GetClass(Lnghnd2)
    PalBan = Lnghnd2
    End Function

    as you can see i cant see anything wrong wrong with this function if you can i would be love the input

    #190846
    Departure
    Member

    hmmm I use a slightly diffrent method of getting handel of a window with knowen text…

    the following code is what i use for ALL my paltalk programs and has never failed me and works with out a problem….
    Place in a module

    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Public Declare Function GetParent& Lib "user32" (ByVal hWnd As Long)
    Public Declare Function IsWindowVisible& Lib "user32" (ByVal hWnd As Long)
    Public Declare Function EnumWindows& Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long)

    Public Const GW_HWNDNEXT = 2
    Public Const GW_Child = 5

    Dim sPattern As String
    Dim hFind As Long

    Public Function FindWindowWild(sWild As String, Optional bMatchCase As Boolean = True) As Long
    sPattern = sWild
    If Not bMatchCase Then sPattern = UCase(sPattern)
    EnumWindows AddressOf EnumWinProc, bMatchCase
    FindWindowWild = hFind
    End Function

    Function EnumWinProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
    Dim k As Long
    Dim sName As String

    If IsWindowVisible(hWnd) And GetParent(hWnd) = 0 Then
    sName = Space$(128)
    k = GetWindowText(hWnd, sName, 128)
    If k > 0 Then
    sName = Left$(sName, k)
    If lParam = 0 Then sName = UCase(sName)
    If sName Like sPattern Then
    hFind = hWnd
    EnumWinProc = 0
    Exit Function
    End If
    End If
    End If
    EnumWinProc = 1
    End Function

    Then i would use the code like this

    Yourbanwindow = FindWindowWild("*Text on ban window", False)

    the astrix (*) means a wild card and is VERY usful for chat rooms in paltalk like this…

    x = FindWindowWild("*Voice Room", False)

    This will find the handel of the voice room your currently in, as you can see it does not need to know the full string of the text on the window for example “Paltalk Help lobby – Voice Room” because the astrix acts as a wild card, Also its a lot less coding than other methods paltalk programmers use.

    If you want I can write you a demo code to show how I would get the ban window

    #190845
    Snoopy1968
    Member

    This is probley a simply quesiton
    but how do you tell visual basic you want the Yes with the special character under the “Y”
    ?

    #190844
    Departure
    Member

    @Snoopy1968 wrote:

    This is probley a simply quesiton
    but how do you tell visual basic you want the Yes with the special character under the “Y”
    ?

    Please explain what you mean bu “Y” I dont get what your asking

    #190843
    Snoopy1968
    Member

    This may sound stupid but i notice that there is an underlne character under the “Y” in paltalk so trying to look for “Yes” would i assume come up negative how do i tell visual basic i want “Y” Not just plan “Y” does visual basic understand html code in the findwindows command

    #190842
    Departure
    Member

    if you mean on buttons and stuff you use the “&” for example &Yes and &No, I hope this is what you meant ….

    #190841
    Snoopy1968
    Member

    that helps i tried your rutine inside my timer for some resent evertime it gets to the point for looking for the ban user window it just stops cant figer itout
    also tried your routine to see if it would find the administrative console* and this came back 0 im beginging to wonder if its me lol everyone else can do it lol

    #190840
    Departure
    Member

    Actually I have tryed it and have the same problem, I have a feeling this is due to emulatewinproc because it seems that vb apps is waiting for a yes or no to clicked before it continues and searches for the Ban User window, Admin seem to got around this by creating another app that clicks yes for him, This ofcause means that the main vb app does’nt have to wait.

    The work around:
    Well I have few ideas , but to get it working straigh away would be to call a second app to do the clicking on Yes button for you, But in mean while Im going to test a couple of ideas I have to get around this problem , and ill report back to you with a soloution.

    P.s I even tryed a pause function to make sure the code was’nt executing before the window appeared, thats how i worked out that it actually waits for user to click yes or no

    #190839
    Departure
    Member

    Solution solved, It was right in front of me and i did’nt see it untill i started stepping throught the code to find out why it hangs,

    Instead of using SendMessageLong API to send the Virtual keybord stroke, use Postmessage…

    After changing this it fixed the problem of clicking the yes in the Ban User? dialog, I then decided to reasearch this and find out an awser why this was and after reading forum message in other sites about SendMessage API i came across some important infomation which confirmed my suspictions….

    SendMessage is ~synchronous~. Consider the
    case where the recipient process is hung or in a "not-responding"
    state. The sending process then effectively becomes hung as well
    because it's waiting indefinitely for a response which may never come.
    The sending process needs a way to either ignore that condition or
    detect it. PostMessage is asynchronous (does not wait for a response)
    so you could use it if you wanted to simply ignore a non-responsive
    state. However you cannot use PostMessage if you're passing strings or
    any other type of pointer in one of the args. SendMessageTimeout is
    synchronous (like SendMessage) except you can supply a timeout value.
    It's useful when you need to wait for a response or know the message
    was processed, but provides a means to avoid a wait forever condition.
    It also allows you to use string or pointer args.
    It's also important to make sure the recipient can process the
    messages in a timely fashion. For example if it has intensive
    processing routines that take more than a second or so to complete, it
    should be calling DoEvents occasionally to process any pending
    messages on its queue.
    #190838
    Departure
    Member

    And here is my solution code that works 100% and no need to make a second app and its all done in the same function

    You would use the following function like this
    Bannick(“yournickname“)

    Or use a string or textbox like this
    Bannick(Yourstring)

    Public Function Bannick(nickname As String) ‘nickname as string will make it easyer to use this function
    Dim x As Long
    Dim xx As Long
    Dim xxx As Long
    Dim xxxx As Long
    Dim xxxxx As Long
    Dim xxxxxx As Long
    Dim xxxxxxx As Long
    Dim xxxxxxxx As Long

    x = FindWindowWild(“*Voice Room”, False) ‘find the current room your talking in
    PostMessage x, WM_COMMAND, 32998, 0 ‘Send the command to open Admin Console

    Pause (0.2) ‘ Pause for 200 millisecs to give time for the window to open before executing next peice of code

    xx = FindWindowByPartialTitle(“Administrative”) ‘Find the admin console by the first part of title captions
    xxx = FindWindowEx(xx, 0&, “Combobox”, vbNullString) ‘Find combo box
    xxxx = FindWindowEx(xxx, 0&, “edit”, vbNullString) ‘Find edit field
    Call SendMessageByString(xxxx, WM_SETTEXT, 0&, nickname$) ‘Send the text to edit field
    xxxxx = FindWindowEx(xx, 0&, “button”, “Ban Selected User”) ‘Find Button called Ban selected user

    Do
    DoEvents
    Call PostMessage(xxxxx, WM_LBUTTONDOWN, 0&, 0&)
    ‘Send a virutal Left mouse click down
    Call PostMessage(xxxxx, WM_LBUTTONUP, 0&, 0&)
    ‘Send a virutal Left mouse click Up [/colour]
    <span style="color: #0040BF]Loop Until xxxxx 0 [/color”> ‘Keep doing this untill completed (just incase)

    Pause (0.2) ‘Pause for 200 millisecs to give time for the Ban User window to open before executing next peice of code

    xxxxxxx = FindWindowByPartialTitle(“Administrative”) ‘Find admin console from the first part of title caption
    xxxxxxx = FindWindow(“#32770”, “Ban User?”) ‘Find child ban window
    xxxxxxxx = FindWindowEx(xxxxxxx, 0&, “button”, vbNullString) ‘Find The Yes button
    Call PostMessage(xxxxxxxx, WM_LBUTTONDOWN, 0&, 0&) ‘Send a virutal Left mouse click down
    Call PostMessage(xxxxxxxx, WM_LBUTTONUP, 0&, 0&) ‘Send a virutal Left mouse click Up
    End Function

    #190837
    Snoopy1968
    Member

    hey thanks for that that woked wonder
    quesiton is it possible to use listviewtiem on the ban list
    or bouncelist has anyone donethat?

    or is it only for users?

    #190836
    Departure
    Member

    Yeap sure can, paltalk uses a listbox for holding the banned users and bounced users, here is Demo source code to show you how eay it can be done, Plus you will find the Public functions I have included VERY useful for other projects also :O)

    This is for bannéd users but easy to change either 1 line of code or add 1 line of code to get bounced users list

     

    #190835
    Snoopy1968
    Member

    Thanks for that help heres a simple quesiton but not sure why its not working

    i have a colection of Users(10000) As New Colection
    and i have items in this colection

    but when i try and change and item thats there vb Bombs out

    anynyone know why?

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