-
DESPERATE - SendMessage - How can I click this toolbar item "Connect"
I need to submit a button within another program but I dont know how to identify it since it's not a standard button.
I am trying to use SendMessage to click "Connect" and "Disconnect"
When I am connected to the internet, the "Connect" button changes the captcha to "Disconnect"
http://img487.imageshack.us/img487/4519/helloue3.jpg
The reason I am doing this is because my PC card (mobile internet) gets kicked off, I am making a program to make it automatically reconnect.
This is extremely urgent by the way and I would very much appreciate any help. :wave:
-
Re: SendMessage - How can I find the cmdButton name of this program?
You can use a progrm like Spy++ or Winspector Spy or the program in my signature. it will show the class name of that button.
-
Re: SendMessage - How can I find the cmdButton name of this program?
Then IF you need an example how to do the sendmessage then please look at this example as well http://www.vbforums.com/showthread.php?t=485789
-
Re: SendMessage - How can I find the cmdButton name of this program?
Fazi, I am using your SendMessage blaster.
Please view:
http://img483.imageshack.us/img483/9149/helloxb4.jpg
When I click the Highlighted line within your program it highlights what seems to be the group box that the CONNECT button is IN.
None of the items in the list (in your program) highlight the connect button on the verizon program....
-------------------------------- using wininspector:
http://img292.imageshack.us/img292/9453/spectng7.jpg
In the above screenshot (wininspector) when I click the "Connect" button within the verizon program the WP-ACTIVATE message is sent to the list, so I think the name of the button is that, I'm going to try to click it with send message.
I also wish I could grab the text at the very bottom so that I know if it's already connected or not.
-
Re: SendMessage - How can I find the cmdButton name of this program?
It is the toolbar and the connect button is a toolbar item. So you need to click on a toolbar item. check this pls http://www.codeguru.com/forum/archiv.../t-307633.html
-
Re: SendMessage - How can I find the cmdButton name of this program?
I am not sure what to do in this case then. Here is my complete code to submit the button:
Module: Code:
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public BtnHwnd As Long
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sSave As String
'Get the windowtext length
sSave = Space$(GetWindowTextLength(hwnd) + 1)
'get the window text
GetWindowText hwnd, sSave, Len(sSave)
'remove the last Chr$(0)
sSave = Left$(sSave, Len(sSave) - 1)
If sSave = "WM_ACTIVATE" Then
BtnHwnd = hwnd
Exit Function
End If
'continue enumeration
EnumChildProc = 1
End Function
Form1 Private Declare Code:
and my Function to submit: Code:
Private Sub HitButton()
On Error Resume Next
Dim WinWnd As Long
Dim Ret As Long
Dim ErrNum As Integer
'Find window Handle
WinWnd = FindWindow(vbNullString, "VZAccess Manager")
If WinWnd <> 0 Then
'Show the form
'AppActivate "email poster"
'Find button handle by going through every child control in the form
EnumChildWindows WinWnd, AddressOf EnumChildProc, ByVal 0&
If BtnHwnd <> 0 Then
'Send the Message
Ret = SendMessage(BtnHwnd, BM_CLICK, 0, 0&)
Else
ErrNum = 2 'Button was not found
End If
Else
ErrNum = 1 'Window was not found
End If
'Errors
Select Case ErrNum
Case 1
Me.Caption = "Window handle could not be found"
Case 2
Me.Caption = "Button was not found on form"
End Select
End Sub
I'm not sure how to access the toolbar... hmm...:ehh:
-
Re: SendMessage - How can I find the cmdButton name of this program?
did you check the link i gave in #5?
-
Re: SendMessage - How can I find the cmdButton name of this program?
Quote:
Originally Posted by Fazi
did you check the link i gave in #5?
I did but I don't understand it.
-
Re: SendMessage - How can I find the cmdButton name of this program?
:D Thud,
here is another example i found while google. please check.
http://www.developersdex.com/vb/mess...er.eweka.nl%3E
-
Re: SendMessage - How can I find the cmdButton name of this program?
Fazi, I am the one who posted that question on Usenet.
TB_PRESSBUTTON doesn't work, it only presses the button, but doesn't run the code behind the button. BM_CLICK only seems to work for normal buttons.
The solution can be found in this thread. It works with PostMessage, WM_LBUTTONDOWN and WM_LBUTTONUP
http://www.vbforums.com/showthread.php?t=487052
-
Re: SendMessage - How can I find the cmdButton name of this program?
Lets see VBF experts here might have a solution :)
-
Re: SendMessage - How can I find the cmdButton name of this program?
Quote:
Originally Posted by Chris001
Fazi, I am the one who posted that question on Usenet.
TB_PRESSBUTTON doesn't work, it only presses the button, but doesn't run the code behind the button. BM_CLICK only seems to work for normal buttons.
The solution can be found in this thread. It works with PostMessage, WM_LBUTTONDOWN and WM_LBUTTONUP
http://www.vbforums.com/showthread.php?t=487052
It looks like this would work:
Code:
ClickMouseSilent 20, 20, hChild, True
But I dont know how to modify the code that I have (provided above)
Can anyone help me out?
Rep points anyone? :wave:
-
Re: SendMessage - How can I find the cmdButton name of this program?
I've found this code, I think i'm getting really close here. I still need help though.
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Type TBBUTTON
iBitmap As Long
idCommand As Long
fsState As Byte
fsStyle As Byte
bReserved1 As Byte
bReserved2 As Byte
dwData As Long
iString As Long
End Type
Private Const WM_USER = &H400
Private Const TB_GETBUTTON = (WM_USER + 23)
Private Const WM_COMMAND = &H111
Private Sub TestClickingToolbarButton()
Dim hToolbar As Long
hToolbar = FindWindow("IEFrame", "Google - Microsoft Internet Explorer")
hToolbar = FindWindowEx(hToolbar, 0, "WorkerW", vbNullString)
hToolbar = FindWindowEx(hToolbar, 0, "ReBarWindow32", vbNullString)
hToolbar = FindWindowEx(hToolbar, 0, "ToolbarWindow32", "")
ClickToolbarButtonByIndex hToolbar, 7 ' Button 7 is the Favorites button.
End Sub
Private Sub ClickToolbarButtonByIndex(ByVal hToolbar As Long, ByVal lButtonIndex As Long)
Dim MyButton As TBBUTTON
Dim xpBuffer As Long ' Address of cross-process buffer.
xpBuffer = drMemoryAlloc(hToolbar, 1024)
SendMessageLong hToolbar, TB_GETBUTTON, lButtonIndex, xpBuffer
drMemoryRead xpBuffer, VarPtr(MyButton), Len(MyButton)
PostMessage GetParent(hToolbar), WM_COMMAND, MyButton.idCommand, hToolbar
drMemoryFree xpBuffer
End Sub
Private Sub Command1_Click()
Dim hToolbar As Long
hToolbar = FindWindow("IEFrame", "MSN.com - Windows Internet Explorer")
hToolbar = FindWindowEx(hToolbar, 0, "WorkerW", vbNullString)
hToolbar = FindWindowEx(hToolbar, 0, "ReBarWindow32", vbNullString)
hToolbar = FindWindowEx(hToolbar, 0, "ToolbarWindow32", "")
ClickToolbarButtonByIndex hToolbar, 7 ' Button 7 is the Favorites button.
End Sub
I got the code from this thread: http://www.vbforums.com/showthread.php?t=362571
and its for internet explorer... which uses a toolbar as well.
I'm desperate... :eek:
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
still no solution, im really trying here. :eek:
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Please do not bump your threads... for the reasons see this thread (especially post #9)
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Quote:
Originally Posted by si_the_geek
Please do not bump your threads... for the reasons see
this thread (especially post #9)
If we do not bump our threads after two days of no response, how do you imagine we'll get a response?
Do you suggest we repost our question within a completely new thread? I doubt that.
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
As mentioned in the thread I linked to, a bump after a reasonable amount of time is is acceptable, and preferable to a duplicate.. but less than a day (or just a few hours, as in the post I deleted) is not a reasonable amount of time.
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Well great. It's been like three days. I'm still very stuck. :ehh:
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
i think there should be a menu item call 'Connect'. you can use it insted of the toolbar button. just use sendkeys to click that connect :D
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Quote:
Originally Posted by Fazi
i think there should be a menu item call 'Connect'. you can use it insted of the toolbar button. just use sendkeys to click that connect :D
I am using sendkeys and it's very unreliable....
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
yes, but before sending the keys, always put that window to focus.
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
is there a way to download a copy of that software without anwsering the questions they ask before download.
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Quote:
Originally Posted by Fazi
is there a way to download a copy of that software without anwsering the questions they ask before download.
yes, you can download it here:
http://www.vzam.net/download/download.aspx
you would need the PC card to connect obviously but you will be able to access the program. the connect/disconnect is the same button i believe.
I need to make two functions to connect and disconnect.
:wave:
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
it is asking a 10 digit wireless number :(
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Quote:
Originally Posted by Fazi
it is asking a 10 digit wireless number :(
here you go;
http://www.vzam.net/uploadedFiles/VZ...1759c-5750.exe
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
downloading and ill take a look at it and i come back lit lator if i have a good result. :)
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
i dont have any connection wireless connection device attached to the pc i am in. so the toolbar button has not activated. still you can use SendMessage() to file > Connect menu. check this example http://www.microsoft.com/communities...0bbb3096e4&p=1
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Quote:
Originally Posted by Fazi
alrighty, and with this code above the form can be controlled while it is not in focus right? If yes then this will have to do..
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Quote:
Originally Posted by Fazi
ofcause.
Okay, im using this code which works for Notepad, it doesn't want to work with my VZAccess manager program.....
Code:
Private Const WM_COMMAND = &H111
Private Const MIIM_TYPE = &H10
Private Const MIIM_ID = 2
Private Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetMenu Lib "user32" (ByVal Hwnd As Long) As Long
Private Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" _
(ByVal hMenu As Long, ByVal un As Long, ByVal b As Long, lpMenuItemInfo As MENUITEMINFO) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Sub MenuClick(Hwnd As Long, Menu As Long, Item As Long)
Dim hMenu As Long, hSubMenu As Long, L As Long
Dim M As MENUITEMINFO
If Hwnd Then
hMenu = GetMenu(Hwnd)
If hMenu Then
hSubMenu = GetSubMenu(hMenu, Menu)
If hSubMenu Then
M.fMask = MIIM_TYPE Or MIIM_ID
M.dwTypeData = Space$(128)
M.cbSize = Len(M)
M.cch = 128
L = GetMenuItemInfo(hSubMenu, Item, True, M)
L = SendMessage(Hwnd, WM_COMMAND, M.wID, ByVal 0)
End If
End If
End If
End Sub
' Example - Open Notepad's About Dialog.
Private Sub Command1_Click()
Dim Lng As Long
Lng = FindWindow(vbNullString, "VZAccess Manager")
MenuClick Lng, 0, 0 ' 0 based, menu seperators count as an item.
End Sub
Here is a screenshot:
http://img353.imageshack.us/img353/1085/vzoo2.jpg
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
thud, your GetMenu() function does not return a handle to the VZAM Menu System :( . Here http://msdn2.microsoft.com/en-us/library/ms647640.aspx it says "
Remarks
GetMenu does not work on floating menu bars. Floating menu bars are custom controls that mimic standard menus; they are not menus. To get the handle on a floating menu bar, use the Active Accessibility APIs. "
you need to find a way to get the handle of the menu in VZAM :) .
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Quote:
Originally Posted by Fazi
thud, your GetMenu() function does not return a handle to the VZAM Menu System :( . Here
http://msdn2.microsoft.com/en-us/library/ms647640.aspx it says "
Remarks
GetMenu does not work on floating menu bars. Floating menu bars are custom controls that mimic standard menus; they are not menus. To get the handle on a floating menu bar, use the Active Accessibility APIs. "
you need to find a way to get the handle of the menu in VZAM :) .
can I get that with winspector or Spy++?
Update: Please see the following screenshot;
http://img215.imageshack.us/img215/3930/untitledvu4.jpg
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
yah, you can get the handle of the toolbar using any of that program. if you provide the toolbar handle GetMenu Returns the handle to the menu. now Getsubmenu() did not return a handle. i am lit busy here. ill check and come back. mean time you can try to get the handle of the sub menu.
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Look I have an even easier idea. I think this can be done with sendmessage.
I want to just simulate clicking F4 (it connects and deconnects) Its a shortcut
I dont want the program to have to be in focus though. I dont want to use appactivate or sendkeys.
How can I "set focus" and hit F4 without the VZAccess Manager program being visible to the user using sendmessage?
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
You can try,
SendMessage (handle,WM_KEYDOWN,VK_F4,0)
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Quote:
Originally Posted by Fazi
You can try,
SendMessage (handle,WM_KEYDOWN,VK_F4,0)
I'm literally going insane here.
I need the full functions with the F4 Message.
It needs to Identify VZAccess Manager then press F4 - hopefully it's not going to set user focus to the program and can do it in the background.
Can you put this together for me?
Are you located in the US? I will pay you for this, I've been messing with this for over a week, I just need it working so that I can move on..... :eek:
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Thud,
please use PostMessage() insted of SendMessage()
ok.
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
does not not need a payment :D
I ll post the code in few minutes. i was experimenting with Notepad all thease time. let me try it with VZAM
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Hope you success at this time :D
Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const VK_F4 = &H73
Private Const WM_KEYDOWN = &H100
Private Sub Command1_Click()
Dim hWnd As Long, childw As Long
Dim i As Integer
hWnd = FindWindow(vbNullString, "VZAccess Manager")
PostMessage hWnd, WM_KEYDOWN, VK_F4, 0
End Sub
-
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
thanks:) I need that
Quote:
Originally Posted by Fazi
Hope you success at this time :D
Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const VK_F4 = &H73
Private Const WM_KEYDOWN = &H100
Private Sub Command1_Click()
Dim hWnd As Long, childw As Long
Dim i As Integer
hWnd = FindWindow(vbNullString, "VZAccess Manager")
PostMessage hWnd, WM_KEYDOWN, VK_F4, 0
End Sub