- This topic has 14 replies, 2 voices, and was last updated 17 years ago by Departure.
-
AuthorPosts
-
September 16, 2007 at 11:07 am #190834Snoopy1968Member
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 ideasDim x As Long, editx As Long, button As Long
Dim console As LongIf (Text38 = “”) Then
PalAdmin
Text38 = Trim(AdmnConsole)
ElseDoEvents
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&)
DoEventsPalBan
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
September 16, 2007 at 12:14 pm #190848DepartureMemberIts 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
September 16, 2007 at 12:52 pm #190847Snoopy1968MemberWhat 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 BooleanDim sSave As String, Ret As Long
Ret = GetWindowTextLength(hndle)
sSave = Space(Ret)
GetWindowText hndle, sSave, Ret + 1If InStr(sSave, “Ban User”) Then
Lnghnd2 = Str$(hndle)
BanClass = GetClass(Lnghnd2)
BanWindow = GetWinTitle(Lnghnd2)
End If
EnumWindowsProc6 = TrueEnd 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 Functionas you can see i cant see anything wrong wrong with this function if you can i would be love the input
September 16, 2007 at 3:30 pm #190846DepartureMemberhmmm 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 modulePublic 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
September 16, 2007 at 4:47 pm #190845Snoopy1968MemberThis is probley a simply quesiton
but how do you tell visual basic you want the Yes with the special character under the “Y”
?September 16, 2007 at 5:42 pm #190844DepartureMember@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
September 16, 2007 at 6:55 pm #190843Snoopy1968MemberThis 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
September 16, 2007 at 7:37 pm #190842DepartureMemberif you mean on buttons and stuff you use the “&” for example &Yes and &No, I hope this is what you meant ….
September 16, 2007 at 8:17 pm #190841Snoopy1968Memberthat 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 lolSeptember 17, 2007 at 5:44 am #190840DepartureMemberActually 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
September 17, 2007 at 2:08 pm #190839DepartureMemberSolution 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.September 17, 2007 at 3:23 pm #190838DepartureMemberAnd 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 Longx = FindWindowWild(“*Voice Room”, False) ‘find the current room your talking in
PostMessage x, WM_COMMAND, 32998, 0 ‘Send the command to open Admin ConsolePause (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 userDo
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 FunctionSeptember 17, 2007 at 6:28 pm #190837Snoopy1968Memberhey 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?
September 17, 2007 at 6:41 pm #190836DepartureMemberYeap 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
October 3, 2007 at 6:17 pm #190835Snoopy1968MemberThanks 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 colectionbut when i try and change and item thats there vb Bombs out
anynyone know why?
-
AuthorPosts
Related
- You must be logged in to reply to this topic.