|
-
Jun 20th, 2000, 07:23 AM
#1
Thread Starter
Addicted Member
Hi
I need to be able to detect when a word is selected with mouse on other applications and grab the selected text.
Even if I could detect the mouse events on other applications (that is mouse buttons pressed etc.) I might be able to work something out.
Tahnks
-
Jun 20th, 2000, 07:43 AM
#2
transcendental analytic
Just a thought:
Subclass for WM_NCLBUTTONUP, store the clipboard content and send a ctrl+C, and then get clipboard content and then reset it again.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 20th, 2000, 08:30 PM
#3
Thread Starter
Addicted Member
I don't know what WM_NCLBUTTONUP is to start with.
could you please be a bit simpler?
-
Jun 20th, 2000, 11:58 PM
#4
transcendental analytic
Here you go, I haven't tested it but should work...
Code:
Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal ndx As Long, ByVal newValue As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const WM_NCLBUTTONUP = &HA2
Dim saveHWnd As Long
Dim oldProcAddr As Long
Sub startsubclassing(ByVal hwnd As Long)
saveHWnd = hwnd
oldProcAddr = SetWindowLong(hwnd, -4, AddressOf WndProc)
End Sub
Sub stopsubclassing()
SetWindowLong saveHWnd, -4, oldProcAddr
End Sub
Function WndProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long: Dim temp$
WndProc = CallWindowProc(oldProcAddr, hwnd, uMsg, wParam, lParam)
If uMsg = WM_NCLBUTTONUP Then
temp = Clipboard.GetText
SendKeys ("^C")
Debug.Print Clipboard.GetText '<replace this with what you want to do with the text
Clipboard.SetText temp
End If
End Function
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 21st, 2000, 01:29 AM
#5
Addicted Member
Ked, how would you use that piece of code?
-
Jun 21st, 2000, 02:25 AM
#6
transcendental analytic
Oh! I always forget the most important part, how to use the code. Ok here goes:
Code:
'to start subclassing
startsubclassing hwnd
'to stop subclassing
stopsubclassing
You should put the first one in form load and the other in unload.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 21st, 2000, 04:59 AM
#7
Thread Starter
Addicted Member
I tried the code but I get the following error
Invalid use of AddressOf operator
-
Jun 21st, 2000, 07:42 PM
#8
Addicted Member
I have tryed this code and it works nice. Is this also possible for a ListBox ?
-
Jun 21st, 2000, 08:07 PM
#9
transcendental analytic
Mass, put that in code in a standard module
Karl, What do you mean? This code copies a selection, that depends wheather copying a listitem in a foreign listbox is connected to clipboard or not.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 21st, 2000, 11:56 PM
#10
Addicted Member
Ked, I tried what you said. Place it in the form Load and Unload, but what exactly is it suppose to do?
In the form_load I have the following:
Code:
Private Sub Form_Load()
Dim lng_Return As Long
lng_Return = FindWindow(0&, "Microsoft Word - Document1")
Call startsubclassing(lng_Return)
End Sub
Sorry if i sound inexperience because I am.
-
Jun 22nd, 2000, 01:18 AM
#11
Thread Starter
Addicted Member
Ked, I know it is very stupid but I could'nt make it work
I put the code in a standard module and ran it
I did not get aynthing
-
Jun 22nd, 2000, 02:04 AM
#12
transcendental analytic
Ok, i need to tell you, it's called subclassing and it get's events vb didn't fire, in this case your subclassed window fires theses events. Mass, shark showed you how to use it
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 22nd, 2000, 02:25 AM
#13
Addicted Member
I understand the term SubClassing but what is the purpose and procedure of your codes
So, once I run your code, do I go to MS Word and highlight something? I placed a break on WndProc, but it never break there. I assumed that it never ran that procedure.
Thanks.
-
Jun 22nd, 2000, 05:09 AM
#14
transcendental analytic
That's odd, it should be fired all the time, if youre moving your mouse over it. Maybe youre hwnd argument isn't valid. what do you get in lng_Return
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 22nd, 2000, 05:25 AM
#15
Thread Starter
Addicted Member
Ked, When I said I ran it I did like Shark suggested
I think if I tell you exactly what I did, you may get my view of the picture. I put yoyr code in a standard module
and put the startsubclassing call with the handel of my notepad and put a textbox on my form and altered the debug print part to the textbox. then I selected some text in the notepad and got nothing in the textbox.
Sorry to bother you so much and thanks
-
Jun 22nd, 2000, 05:54 AM
#16
transcendental analytic
place a break in wndproc like shark did, if you don't get an event, you probably have the handle wrong, otherwise it's a problem with my code, anyway i have a subclassing control, i'll upload it on my homepage later...
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 22nd, 2000, 06:23 AM
#17
Thread Starter
Addicted Member
I did and it dosent seem to get the event.
I will check to make sure the handle is right. As I coulden't make your code to work I don't know if it answers
my other question (mouse events).
Just a thought, if we could detect the mouse down anywhere
then we can get the handle of the window and by using Appactivate and sendkey we could grab the text. I know the idea is not a good one but what do you expect?
I got some code (I can't remember where but I could look it up) which is suppos to do the job but I can't understand it.
Could I Email it to you and see what you think?
Thanks
-
Jun 22nd, 2000, 06:58 AM
#18
transcendental analytic
Sure thing
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 24th, 2000, 09:37 AM
#19
transcendental analytic
Sorry, I was getting a bit busy and forgot, well you did get the handle did you?
Well you could get an event for clickin anywhere by using the code at, posted by Fran C, i didn't find anything else:
http://forums.vb-world.net/showthrea...threadid=15494
You should replace WM_MOUSEMOVE with WM_NCLBUTTONUP
Using getforegroundwindow api you could get the handle for the window your selecting the text from
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 25th, 2000, 03:58 AM
#20
Thread Starter
Addicted Member
I used the code but I can't detect double click with WM_LBUTTONDBLCLK can anyone tell me why?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|