Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To Use SendMessage To Click On External Listview Item


hi all. could any one show me how i can use SendMessage to click on external listview item.Thanks




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Click External Listview Item?
Hi all could any one show me how i can click an external list view item . I have the following information about the listview :


hWnd=66310
Class=GradienTreeViewClass

Thanks

Simulate A Click On An Item In An External Listview
I'm trying to simulate a mouse click on an item in an external listview (syslistview32) from my VB application.

I found out how to get an item highlighted, but it seems I need the actual mouse click simulation to get the effect I need. Anyone know what I'd need to do this?

Any help is very much appreciated

Question: How To Get Item Text From A ListView By Using Sendmessage Api?
i need a function for getting items from a listview by only knowing its handle.
i tried much but i can only get its item count not the item texts.

respects...

Click Item In Listview Then Show That Item In Combo As Index = 0
Hi guys,

I have a listview (lvwUserPunchedOut) that is populated with records in a database (persons first name in one column and last name in the second column), what I am looking to do is if I select a persons name by clicking on it in the listview on frmMain, and then bring up frmSearchCriteria, i would like to show that selected name in the combobox as default (cboEmployee.ListIndex = 0) on frmSearchCriteria (the combobox is sorted = True and is also populated with first name and last name of the person)

How would this be done? Hope I make sense. Thanks in advance.

Add Item To External Listview.
Bascially i need to insert a new row of text into a listview on another program.

I found this code which seems to add the row:


Quote:




Public Function InsertItem(hwnd As Long, i As Long, ItemText As String, Optional State As Long)
Dim pitem As LVITEM
With pitem
.mask = LVIF_TEXT Or LVIF_STATE
.iItem = i
.pszText = ItemText
.State = 1
.stateMask = LVIS_STATEIMAGEMASK
End With
Call SendMessage(hwnd, LVM_INSERTITEM, 0, pitem)
Call SendMessage(hwnd, LVM_SETITEMSTATE, ByVal i, pitem)
End Function




It added the row, but my text was garbled and once i added a 2nd row the external program crashed.


Also i have looked at "Dr Memory's "CopyListview" Demo ", ( http://www.xtremevbtalk.com/t38276.html ) which is an amazing piece of code. It does the opposite of what i want. But the idea is the same. I tried editing it to do what i need but it crashes the remote program.

I've been workgin on this for weeks now, if anyone can help, please :)

my icq 8036469
msn m.drover@excite.com

Thanks for reading.


-MatthewJ

How To Highlight 1st Item On External Listview
Just wondering if anyone knows how to highlight the first item on an external listview

Thanks

Select 2nd Item Of External Listview?
Is there an easy way to select the second Item of an external listview.

This is the api of that listview

VB Code:
Dim mywindowclass As Long, wtlsplitterwindow As Long, atlb As LongDim syslistview As Longmywindowclass = FindWindow("my window class", vbNullString)wtlsplitterwindow = FindWindowEx(mywindowclass, 0&, "wtl_splitterwindow", vbNullString)wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)atlb = FindWindowEx(wtlsplitterwindow, 0&, "atl:005047b8", vbNullString)syslistview = FindWindowEx(atlb, 0&, "syslistview32", vbNullString)


Thanks

How To Highlight 1st Item On External Listview?
Hi all could any one tell me how i can highligh the first item on the external listview . I did not many searches but could not find the solution!! So i hope some one help me.Thanks

How To Highlight External Listview 1st Item?
hey does anyone know how to highlight the first item of another program listview

Thanks

Retrieving Listview Item Texts Frm External App
Hi guys,

I've been searching high and low for some code that allows me to get the item text from an external listview(another program) whose hwnd is known.

I've already read through most of the code regarding this on here with no result, can one of u gurus plz help ?

How To Change Color Of External Listview Item Using Api
Hi all. could any one show me how i can change a color of external listview item using an api.Thanks

Probelm Highligting First Item Of External Listview
Hi all i am triyiing to select first item of external listview using code beleow but each time i click on button it does not work. could any one look at this and let me know what i am doing wrong.Thanks


module code:

VB Code:
Option Explicit Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As LongPrivate Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPrivate Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As LongPrivate Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As LongPrivate Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As LongPrivate Declare Function VirtualFreeEx Lib "kernel32" (ByVal hProcess As Long, lpAddress As Any, ByVal dwSize As Long, ByVal dwFreeType As Long) As LongPrivate Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As LongPrivate Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Type LV_ITEM    mask As Long    iItem As Long    iSubitem As Long    state As Long    stateMask As Long    pszText As String    cchTextMax As Long    iImage As Long    lParam As Long    iIndent As LongEnd Type Private Const LVM_FIRST = &H1000&Private Const LVM_SETITEMSTATE = (LVM_FIRST + 43)Private Const LVIF_STATE = &H8&Private Const LVIS_FOCUSED = &H1Private Const LVIS_SELECTED = &H2&Private Const PROCESS_VM_OPERATION = &H8Private Const PROCESS_VM_READ = &H10Private Const PROCESS_VM_WRITE = &H20Private Const PAGE_READWRITE = &H4&Private Const MEM_RESERVE = &H2000Private Const MEM_COMMIT = &H1000Private Const MEM_RELEASE = &H8000 Private hWndlvw As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPrivate Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long  Private Function EnumWindowsProc(ByVal hWnd As Long, ByVal lParam As String) As Long    Dim strCaption As String    Dim lLen As Long    [b]    hWnd = 3410942    hWndlvw = FindWindowEx(hWnd, 0&, "My Window Class", "")[/b]    ' If we've found a window with the SysListView32 class    ' check to see if parent window caption is the one we are looking for    If hWndlvw <> 0 Then        lLen = GetWindowTextLength(hWnd)        If lLen > 0 Then            strCaption = Space(lLen)            GetWindowText hWnd, strCaption, lLen + 1        End If    End If    EnumWindowsProc = (hWndlvw = 0 And strCaption <> lParam)End Function ' New example looks for a window with class SysListView32 that is hosted' by a window whose caption matches the contents of strInWindowWithCaptionPublic Function FindListView(strInWindowWithCaption As String) As Long    EnumWindows AddressOf EnumWindowsProc, StrPtr(strInWindowWithCaption)    FindListView = hWndlvwEnd Function  Public Function MessageCrossProcess(ByVal hWnd As Long)    Dim lProcID As Long    Dim hProc As Long    Dim lxprocLVITEM As Long    Dim LVITEM As LV_ITEM    Dim lItemPos As Long        GetWindowThreadProcessId hWnd, lProcID ' Get the process ID in which the ListView is running    If lProcID <> 0 Then        hProc = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, lProcID) ' make sure we have read write permissions in the process space        If hProc <> 0 Then            lxprocLVITEM = VirtualAllocEx(hProc, 0, LenB(LVITEM), MEM_RESERVE Or MEM_COMMIT, PAGE_READWRITE) ' Grab enough memory in the other procedure's space to hold our LV_ITEM                        ' Set up our local LV_ITEM to change the selected item            LVITEM.mask = LVIF_STATE            LVITEM.state = True            LVITEM.stateMask = LVIS_SELECTED Or LVIS_FOCUSED ' Just enforcing the selection better than in original version by moving the focus as well            ' Copy the local LV_ITEM into the space we reserved in the foreign process            WriteProcessMemory hProc, ByVal lxprocLVITEM, ByVal VarPtr(LVITEM), LenB(LVITEM), 0                        ' Now send the message, but pass the address of the copy of our LV_ITEM that now exists in the foreign process instead of our local version            lItemPos = 0& ' first item            SendMessage hWnd, LVM_SETITEMSTATE, lItemPos, ByVal lxprocLVITEM                        ' Clean up            VirtualFreeEx hProc, ByVal lxprocLVITEM, LenB(LVITEM), MEM_RELEASE            CloseHandle hProc        End If    End IfEnd Function


main form code:



VB Code:
Private Sub Command1_Click()MessageCrossProcess FindListView("[b]caption of external window[/b]") End Sub

Problem Selecting First Item Of External Listview
Hi all i got this code that supposed to select and highlight the first item of external list view but unfortuntly when i click the command button it does not do any thing. It seems it can not find the right window . i placed the class name of external listview and caption of the window that holds the listview but no luck. i be happy if an expert tell me how to fix this.Thanks



Code:

Option Explicit

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 EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) 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 GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function VirtualFreeEx Lib "kernel32" (ByVal hProcess As Long, lpAddress As Any, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Type LV_ITEM
mask As Long
iItem As Long
iSubitem As Long
state As Long
stateMask As Long
pszText As String
cchTextMax As Long
iImage As Long
lParam As Long
iIndent As Long
End Type

Private Const LVM_FIRST = &H1000&
Private Const LVM_SETITEMSTATE = (LVM_FIRST + 43)
Private Const LVIF_STATE = &H8&
Private Const LVIS_FOCUSED = &H1
Private Const LVIS_SELECTED = &H2&
Private Const PROCESS_VM_OPERATION = &H8
Private Const PROCESS_VM_READ = &H10
Private Const PROCESS_VM_WRITE = &H20
Private Const PAGE_READWRITE = &H4&
Private Const MEM_RESERVE = &H2000
Private Const MEM_COMMIT = &H1000
Private Const MEM_RELEASE = &H8000

Private hWndlvw As Long

Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long


Private Function EnumWindowsProc(ByVal hWnd As Long, ByVal lParam As String) As Long
Dim strCaption As String
Dim lLen As Long

hWndlvw = FindWindowEx(hWnd, 0&, "SysListView32", "")
' If we've found a window with the SysListView32 class
' check to see if parent window caption is the one we are looking for
If hWndlvw <> 0 Then
lLen = GetWindowTextLength(hWnd)
If lLen > 0 Then
strCaption = Space(lLen)
GetWindowText hWnd, strCaption, lLen + 1
End If
End If
EnumWindowsProc = (hWndlvw = 0 And strCaption <> lParam)
End Function

' New example looks for a window with class SysListView32 that is hosted
' by a window whose caption matches the contents of strInWindowWithCaption
Public Function FindListView(strInWindowWithCaption As String) As Long
EnumWindows AddressOf EnumWindowsProc, StrPtr(strInWindowWithCaption)
FindListView = hWndlvw
End Function


Public Function MessageCrossProcess(ByVal hWnd As Long)
Dim lProcID As Long
Dim hProc As Long
Dim lxprocLVITEM As Long
Dim LVITEM As LV_ITEM
Dim lItemPos As Long

GetWindowThreadProcessId hWnd, lProcID ' Get the process ID in which the ListView is running
If lProcID <> 0 Then
hProc = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, lProcID) ' make sure we have read write permissions in the process space
If hProc <> 0 Then
lxprocLVITEM = VirtualAllocEx(hProc, 0, LenB(LVITEM), MEM_RESERVE Or MEM_COMMIT, PAGE_READWRITE) ' Grab enough memory in the other procedure's space to hold our LV_ITEM

' Set up our local LV_ITEM to change the selected item
LVITEM.mask = LVIF_STATE
LVITEM.state = True
LVITEM.stateMask = LVIS_SELECTED Or LVIS_FOCUSED ' Just enforcing the selection better than in original version by moving the focus as well
' Copy the local LV_ITEM into the space we reserved in the foreign process
WriteProcessMemory hProc, ByVal lxprocLVITEM, ByVal VarPtr(LVITEM), LenB(LVITEM), 0

' Now send the message, but pass the address of the copy of our LV_ITEM that now exists in the foreign process instead of our local version
lItemPos = 0& ' first item
SendMessage hWnd, LVM_SETITEMSTATE, lItemPos, ByVal lxprocLVITEM

' Clean up
VirtualFreeEx hProc, ByVal lxprocLVITEM, LenB(LVITEM), MEM_RELEASE
CloseHandle hProc
End If
End If
End Function




and the on click event



Code:

Private Sub Command1_Click()
MessageCrossProcess FindListView("Rooms List - Search Results")

End Sub

How To Select/highligh Item From External Listview?
Hi all. i got an external listview in an application. I want create a program that one click of button i select a perticuler item from external listview. i searched every where but i did not find a working example. could any one show me how to select/highlight external listview item.Thanks

Why This Code Doesn't Select External Listview 1st Item?
Well I cant figure why this code does not work all i want to do is select an external listview firts item, this what i have so far:

Module

VB Code:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPublic Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPublic Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As LongPublic Declare Function SendMessageLong& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPublic Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As LongPublic Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As LongPublic Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPublic Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As LongPublic Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As BooleanPrivate Declare Function SendMessageA Lib "user32" (ByVal hwnd As Long, ByVal _wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongGlobal lngRhWnd As Long ' global to store handleGlobal strWindowTitle As String ' global to store titleGlobal strClassname As StringPublic Const WM_SETTEXT = &HCPublic Const WM_LBUTTONDOWN = &H201Public Const WM_LBUTTONUP = &H202Public Const VK_SPACE = &H20Public Const WM_KEYDOWN = &H100Public Const WM_KEYUP = &H101Public Const WM_CLOSE = &H10


General

VB Code:
Private Declare Function SendMessageAny Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long


Call command

VB Code:
Dim mywindowclass As Long, wtlsplitterwindow As Long, atlb As LongDim syslistview As Longmywindowclass = FindWindow("my window class", vbNullString)wtlsplitterwindow = FindWindowEx(mywindowclass, 0&, "wtl_splitterwindow", vbNullString)wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)atlb = FindWindowEx(wtlsplitterwindow, 0&, "atl:005047b8", vbNullString)syslistview = FindWindowEx(atlb, 0&, "syslistview32", vbNullString)SendMessage syslistview32, WM_KEYDOWN, VK_DOWN, 0&SendMessage syslistview32, WM_KEYUP, VK_DOWN, 0&


All the apis seem to be correct is just not highlighting it

Is There A Quicker Way To Select An Item In An External Listview? (see Code Inside)
VB Code:
With myLVitem      .mask = LVIF_STATE      .state = &HF      .stateMask = LVIS_SELECTED Or LVIS_FOCUSED      End With              dmWriteProcessData lvItemPointer, VarPtr(myLVitem), Len(myLVitem)        apiResult = SendMessage(lvWindow, LVM_SETITEMSTATE, 1, lvItemPointer)

is what im currently using to select the item.. but the thing is i have to use SendMessage multiple times to select multiple items.. is there a way to select multiple items using only one sendmessage call?

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"



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.

ListView Item Right Click
Hello guys!
Does anyone knows how can I simulate a right click event on a listview item?

Thanks.

Listview With Item Right-click
Hello,

I couldn't find a code on internet for listview with the list of the items and the right click. Please can you find to get me the code??



thanks

Listview With Item Right Click
Hello,

I couldn't find a code for listview with the list of the item and the right click. Please can you find to get me the code??



thanks

Select Listview Item By Right Click
I have a listview and I would like the user to be able to select and item by right clicking it and also haveing a popupmenu. I have it so if they first left click on it then right click it would work, but I want to have it so they are able to just right click and have the menu apear. Here is the code that I have so far.

If Button = 2 Then
Dim aPt As POINTAPI
Dim anInd As Long
GetCursorPos aPt
With viewEntry
.SelectedItem.Index = LBItemFromPt(.hwnd, aPt.X, aPt.Y, False)
End With
PopupMenu DepClick
End If

This isn't working right because I tried to port it from a listbox. Any help would be great, thanks.

Listview - Right Click On Main Item.
How would I right-click on a listview's main item and make it show a menu via popupmenu?

So let's say I am showing a directory list using a listview and I right click on a file and it shows file options (rename, del, copy). How would I do that? It is kind of like explorer's view. I will include an image.

Right-Click Select Item In ListView
Hi. How can I program a ListView so that when the user right-clicks on it, the corresponding item is selected just as if the user had left-clicked? I thought of the SendMessage API but then how do I convert the X and Y values from the ListView's MouseDown event into an lParam value? i.e. how do i do the opposite of extracting High and Low-Order words?
Thanks in advance.

How To Add A Right Click Menu To ListView Item??
How to add a right click menu to ListView item??

ListView: Click On Item By Code
hi all
with the ListView in report mode
how can I make an 'item click' by program code? [I want the
background to go blue]
I have tried calling listview_itemclick and _click but
they do not make the list item go blue backround ....

Listview Item Click Grrrrrr!!!!!!!!!!!
Okay I have a list control on a form. I fill the list view with files and subdirectorys in a folder. Fairly straight forward

when a user clicks on a subfoder it clears the listview and then shows files and subfolders of that folder (sound familiar ) however it now has somehow activated the mousedown event on the first item in the list and as soon as you move the mouse it drags it all over the show. Then if you click to deselect it.. it fires of my click event again on the item.

How can I stop this from happening

PS I tried putting item.selected = false at the end of the code in the item click event but becuase for a subfolder it clears and refills the listview I just recieve an error

HELP PLEASE

Capturing A Double-click On A ListView Item
How would I go about detecting double clicks on ListView items? I've looked at the DblClick, ItemClick and Mousedown events, but it seems the only way I can effectively do it is detect a single click and then use a timer with a short interval and wait to see if another click event occurs within the interval (very long-winded, in other words). Come on, Windows uses it all the time, there HAS to be an easier way...

Double Click Listview To Edit Item
Is it possible to trigger the labeledit event, or somehow get the listitem to be editable, by double-clicking it?

Listview: Arrow Keys Do Item Click
with the listview control (report mode)
when I move (from the selected item) up or down the list using the arrow keys it immediately causes an item_click event.
how do I stop this happening. I only want item_click to occur
when mouse is clicked on item

How Add Listview Item To Clip Board On Click Of A Button
hi all. i got a listview that loads sentences from a text file . I want to create a button so that it once clicked it copies the current select listview item to clip board.When next time the button is clicked it goes copies the next listview item and so on. could any one show me how this can be done?Thanks

Note: i want the listview item hightlight move to next item item as i click the button each time.

Listview Double Click - How Can You Grab The Text Of The Item Clicked?
when you double click an item in a listview, how can you get the actual text that was double clicked?

Sendmessage Again: Automating External App.
Here's my problem:

I wrote a VB app to control an external application based on parameterised input from a textfile. I wrote the app using VB's Sendkey.

This ended up being very unstable, so I rewrote it using API SendInput.

The procedure is as follows:
It's a multi-use app, so I kill existing process, then use CreateProcess to start it up, with inherited handles.
I use a findwindow loop to get the new app's parent window hwnd.
The reading in keystrokes ( and applying SHIFT. CTRL and ALT where necessary) I automated based on criteria in my script file.

The process worked, except for 1 small glitch. I was sending keys so fast the external app wasn't keeping up. It needs to open up popups, dialog boxes etc before I send keys. I then added in selective calls to WaitForSingleObject with a parameterised time, so that my VB app would wait e.g. 500ms before sending next keys.

Now I have another problem. 1 of my many runs through the application again sends keys too fast (in fact I'm killing the app) and again I send keys before the popup window has opened.. I don't want to keep increasing this hardcoded time, as it's taking too long now. Now here's my question.

I thought I could simply replace my SendInput with SendMessage and the same Keyup/keydown combinations, but I was wrong.

WM_CHAR messages work nicely, but I cannot get the application to respond to any WM_KEY* messages. In fact testing on notepad I cannot even get the app to respond to WM_CLOSE.

How can I use SendMessage API to control textinput a bit better. Mainly what I need is this code to work - Send ALT-F S to e.g. Notepad:

Code:
'Notepad
parenthwnd = FindWindowEx(ByVal 0&, ByVal 0&, "Notepad", vbNullString)
'Notepad's edit box
hwnd = FindWindowEx(hWindow, ByVal 0&, "Edit", vbNullString)

retvalue = SendMessage(hWnd, WM_SYSKEYDOWN, VK_MENU, 1&)
retvalue = SendMessage(hWnd, WM_KEYDOWN, VK_F, 1&)
retvalue = SendMessage(hWnd, WM_KEYUP, VK_F, 1&)
retvalue = SendMessage(hWnd, WM_KEYDOWN, VK_S, 1&)
retvalue = SendMessage(hWnd, WM_KEYUP, VK_S, 1&)
retvalue = SendMessage(hWnd, WM_SYSKEYUP, VK_MENU, 1&)
retvalue = SendMessage(parenthwnd, WM_SYSCOMMAND, SC_CLOSE, 0&)
I have tried using both hwnd values to no avail. SPY on the app suggests the SYSKEYDOWN message is being picked up by the edit box.
There's no messages coming back (yet) so I don't want to subclass.
All I need is to send These keystrokes to the app and maybe then use PeekMessage to see if the window has responded.

Using SendMessage API To Control External App
I have an external, 3rd party application that I need to be able to control. I've tried using SendKeys but due to the obvious limitations of this function the behavior is erratic. I know you can do this using the SendMessage API but I'm not sure how to do it.

Basically, I need to click a button on the toolbar (accessed via CTL+M) and then click a button on the resulting form (accessed via ALT+D). Any help would be greatly appreciated.

Modifying An External RTB? (SendMessage)
Hi

Once I've grabbed the handle of this richtextbox I would like to alter, does anyone know if it is possible to say send a REPLACE constant via the sendmessage api ?

like say replace a :) with an image, say

?

I've altered the max length that a programme has assigned it, but it'd be well helpful if some1 could help me with this, cheers!

Avoiding Horrible 'memory Cannot Be Read' Errors (sendmessage And External Listboxes)
Ive got a little app that ive made

in order to "multithread", my program launches itself (well, it launches the same program that only computes only, with no GUI).

the program and its 'threads' (6 of em) have to work with items in a listbox in the main program. the 6 threads retrieve the first item in the listbox in the main program (one with the GUI), then delete it with API. each thread does this, and loops until there are no more items in the listbox.

Heres the code I use - lstURLs holds the hwnd of the listbox in the main app


Code:
Do
textlen = SendMessage(lstURLs, LB_GETTEXTLEN, ByVal 0, ByVal CLng(0)) 'Get length of 1st item
itemtext = Space(textlen) & vbNullChar
textlen = SendMessage(lstURLs, LB_GETTEXT, ByVal 0, ByVal itemtext) 'Get text of 1st item
itemtext = Left(itemtext, textlen)
retval = SendMessage(lstURLs, LB_DELETESTRING, ByVal CLng(0), ByVal CLng(0)) 'Delete the 1st entry

ExecuteCodeOnTheRetrievedValue itemtext
Loop Until SendMessage(lstURLs, LB_GETCOUNT, ByVal CLng(0), ByVal CLng(0)) < 1 'Loop until theres no more items
naturally, with 6 threads including the main app accessing the same listbox, retrieving the first item and deleting it, problems can occur, especially if this occurs fairly quickly (~4 requests a second to the listbox)

The app works fine for a little while, but then it seems out of the blue i get a "invalid procedure call or argument" error, or even worse, a "the memory could not be 'read'" error

any idea what i can do to avoid the crashes?

i really dont want to recode everything to work without the accessing-listbox idea or even the thread idea, there surely must be some error checking i can use..

i cant really debug the app cause the 'threads' must all be in exes to be launched from the main app.

Thanks

Avoiding Horrible 'memory Cannot Be Read' Errors (sendmessage And External Listboxes)
Ive got a little app that ive made

in order to "multithread", my program launches itself (well, it launches the same program that only computes only, with no GUI).

the program and its 'threads' (6 of em) have to work with items in a listbox in the main program. the 6 threads retrieve the first item in the listbox in the main program (one with the GUI), then delete it with API. each thread does this, and loops until there are no more items in the listbox.

Heres the code I use - lstURLs holds the hwnd of the listbox in the main app

VB Code:
Do        textlen = SendMessage(lstURLs, LB_GETTEXTLEN, ByVal 0, ByVal CLng(0)) 'Get length of 1st item        itemtext = Space(textlen) & vbNullChar        textlen = SendMessage(lstURLs, LB_GETTEXT, ByVal 0, ByVal itemtext) 'Get text of 1st item        itemtext = Left(itemtext, textlen)        retval = SendMessage(lstURLs, LB_DELETESTRING, ByVal CLng(0), ByVal CLng(0)) 'Delete the 1st entry                ExecuteCodeOnTheRetrievedValue itemtext    Loop Until SendMessage(lstURLs, LB_GETCOUNT, ByVal CLng(0), ByVal CLng(0)) < 1 'Loop until theres no more items  


naturally, with 6 threads including the main app accessing the same listbox, retrieving the first item and deleting it, problems can occur, especially if this occurs fairly quickly (~4 requests a second to the listbox)

The app works fine for a little while, but then it seems out of the blue i get a "invalid procedure call or argument" error, or even worse, a "the memory could not be 'read'" error

any idea what i can do to avoid the crashes?

i really dont want to recode everything to work without the accessing-listbox idea or even the thread idea, there surely must be some error checking i can use..

i cant really debug the app cause the 'threads' must all be in exes to be launched from the main app.

Thanks

Using SendMessage To Find An Item In A Tree
Is it possible to use 'SendMessage' to do the following tasks in an application that is not under my control...

[1] Look for a treeview control in a given window.
[2] Look for an item in the treeview control identified in task 1.
[3] Select the item in the treeview as identified in task 2.

So, for example, I want my VB app to first locate the Outlook express window. Next, see if there is a treeview control present on the window. Then if its found, select the item 'Outlook ExpressLocal FoldersInbox' in the tree.

Any takers...?

Thanks

Making Right-Click In A ListBox Select An Item Exactly Like The Left Click.
Heres a start:


Code:
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
'Place code to select the item
End Sub

I need help where the comment is. Thanks

Sendmessage Click.
I know there are some samples on net that do this but they are like 100 lines... And I got this program i made that findwindow a window and sends keys to it and presses enter. Now I also want it to be clicked to a button. The window has a button "Copy" and a button "Clear" and I want to make a program that will.

1.Click Copy.
2.Click Clear.
3.Click Copy.
4.Click clear.
and so on and so on.

And is there only coordinated way since ive seen programs that don't care where the application is and still hit the button :S

-Joppe

PS: So how can I click a button "Copy" on an application.

Click With Sendmessage
I have a program that clicks on a point. but everytime it has to move the mouse to that point before it can click (using setmousepos-api).
but I want it to (simulate a) click on that point without moving the mouse.
can anyone help me?
I thought this was possible with the sendmessage-api.
please help!!!

Right-click Menu And Sending Left Click To Item
Can anyone tell me how I can use insert a right-click menu into my program so that when the user has selected a file (in a file list) and right-clicks, a menu appears at the location of the mouse pointer. I aleady know how to use the PopupMenu function to show a menu as I suppose that will need to be used, I just don't know how to capture a right-click mouse event and also use the position of the mouse pointer to show the menu.

Thanks in advance!

SendMessage - LB_ITEMFROMPOINT Always Returns The First Item On The List!!!
I use the following procedure with a ListBox called "lstFolders" to show a ToolTipText with the name of the item that the mouse's pointer is pointing, but it always returns the first item's name. Can you tell me why?
BTW I use "Option Base 1", don't know if it has anything to do with it.

Code:
Option Explicit
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 Const LB_ITEMFROMPOINT = &H1A9

Private Sub lstFolders_MouseMove(Button As Integer,

Shift As Integer, X As Single, Y As Single)
Dim lngPos As Long
Dim XX As Long
Dim YY As Long
Dim i As Integer

XX = CLng(X / Screen.TwipsPerPixelX)
YY = CLng(Y / Screen.TwipsPerPixelY)
lngPos = SendMessage(lstFolders.hwnd, LB_ITEMFROMPOINT, 0, ByVal ((YY * 65536) + XX))

If lngPos < lstFolders.ListCount And lngPos > -1 Then
lstFolders.ToolTipText = lstFolders.List(lngPos)
End If

End Sub

Click A Button Using The Sendmessage Api
Yea, how do i send the event click or mousedown or whatever to a button using sendmessage?

Click A Button Using SendMessage
I and using the function [SendMessage(BtnHwnd, BM_CLICK, 0&, 0&)] to try to click a 'Yes' button in another application.
When the other window comes up and I can see the 'Yes' button. I activate my program and I can se it trying to ckick the button. I has a timer that will try to click it a number of times and then my program closes. But it does not successfully click the button.

The odd thing is that if I immediately run my program again, it does successfully click the 'Yes' button on the other application.

What is happening the first time I run my program that allows it to click the button on the 2nd try?

Thanks

SendMessage First Click Doesn't Work
Hi there!

I'm trying to send a BM_CLICK using SendMessage to a dialog box to an external program. When I send the click, it sometimes clicks on the button, and sometimes it doesn't. But when I send two clicks, then it works everytime. Why is this?

Private Sub ClickButton()

Dim hwndDialog As Long
Dim hwndButton As Long
Dim retval As Long

hwndDialog = FindWindow(CLng(0), "Notepad")
If hwndDialog = 0 Then Exit Sub

hwndButton = FindWindowEx(hwndDialog, 0, CLng(0), "&Yes")

retval = SetActiveWindow(hwndDialog)
retval = SendMessage(hwndButton, BM_CLICK, ByVal CLng(0), ByVal CLng(0))
retval = SendMessage(hwndButton, BM_CLICK, ByVal CLng(0), ByVal CLng(0))

End Sub

Select Combobox Item In External App
I get the hwnd of the combobox in question then execute this code:

Code:
If lngHwnd <> 0 Then
lngRetVal = SendMessage(lngHwnd , CB_FINDSTRINGEXACT, 0,objCust.Salutation)
If lngRetVal <> CB_ERR Then
lngRetVal = SendMessage(lngHwnd , CB_SETTOPINDEX, 0, lngRetVal)
Else
'I can't do anything about this I'm afraid.
End If
End If


The findstringexact message is returning index 4 which is correct for my combo, however the CB_SETTOPINDEX message does nothing???? What am I missing?

Cheers.

How To Select External Menue Item?
Hi all . Could any one show me how i can select menue item from external meues in diffrent application. I have shown what i want in pic.Thanks

Copyright © 2005-08 www.BigResource.com, All rights reserved