hi,
I try to create a Snippet manager, for do that i send key to the external application.
The problem is some application have several tab, and even if i enumerate the class into this application i'm not sure to send the text to the good tab.
Have you a way for obtain the handle where the cursor is ??
Best regards
Handle of the object holding the cursor
Handle of the object holding the cursor
Sorry but, Google translate is my friend 

Re: Handle of the object holding the cursor
WindowFromPoint_(), ChildWindowFromPoint_(), RealChildWindowFromPoint _() ??
Re: Handle of the object holding the cursor
Thanks for your answer.
The SendKey works, it's the most simple method
But i believe, i need a little bit of help for the sendmessage, i don't know how use this API
And i have search RealChildWindowFromPoint on the forum, the only one answer is your post
The SendKey works, it's the most simple method
But i believe, i need a little bit of help for the sendmessage, i don't know how use this API

And i have search RealChildWindowFromPoint on the forum, the only one answer is your post

Code: Select all
Hwnd = FindWindow_(0, "*Untitled1 - Code::Blocks 10.05")
; SendKey method (Works)
SetForegroundWindow_(Hwnd)
keybd_event_(#VK_H, 0, 0, 0)
keybd_event_(#VK_H, 0, #KEYEVENTF_KEYUP, 0)
Delay(10)
keybd_event_(#VK_E, 0, 0, 0)
keybd_event_(#VK_E, 0, #KEYEVENTF_KEYUP, 0)
Delay(10)
keybd_event_(#VK_L, 0, 0, 0)
keybd_event_(#VK_L, 0, #KEYEVENTF_KEYUP, 0)
Delay(10)
keybd_event_(#VK_L, 0, 0, 0)
keybd_event_(#VK_L, 0, #KEYEVENTF_KEYUP, 0)
Delay(10)
keybd_event_(#VK_O, 0, 0, 0)
keybd_event_(#VK_O, 0, #KEYEVENTF_KEYUP, 0)
Delay(10)
; SendMessage method
GetCursorPos_(@p.POINT)
ScreenToClient_(Hwnd, @p)
Debug p\y
Debug p\x
Object = RealChildWindowFromPoint_(Hwnd, p\y<< 32+p\x)
SendMessage_(Object, #WM_SETTEXT, 0, @"Goodbye")
CallDebugger
Sorry but, Google translate is my friend 

Re: Handle of the object holding the cursor
I tried with this code, the word goodbye is sent, but the caption panel codeBlock before called "SCIwindow" is now called "goodbye" 
The text is not sending to the cursor

The text is not sending to the cursor
Code: Select all
Procedure EnumChildProc(hwnd, lParam)
If hwnd
result = 1
tLen = SendMessage_(hwnd, #WM_GETTEXTLENGTH, 0, 0)
text$ = Space(tLen)
SendMessage_(hwnd, #WM_GETTEXT, tLen + 1, @text$)
If Trim(Text$) <>""
Debug text$
EndIf
If Trim(Text$) = "SCIwindow"
SetForegroundWindow_(Hwnd)
SendMessage_(hwnd, #WM_SETTEXT, 0, @"Goodbye")
EndIf
Else
result = 0
EndIf
ProcedureReturn result
EndProcedure
hwnd = FindWindow_(0,"*Untitled1 - Code::Blocks 10.05")
If hwnd
EnumChildWindows_(hwnd, @EnumChildProc(), hwnd)
EndIf
Sorry but, Google translate is my friend 

Re: Handle of the object holding the cursor
Nobody can help me ?
My program works with items like keys CTRL+C / CTRL+V and also with sending each character.
But I would have loved to have the direct method sending a text, if it is possible of course.
To show you what I've done, here's a draft of my program.
It is super simple to use, well I hoped
1 / Choose the IDE text you want to copy a SNIPPET "NotePad, NotePad++, CodeBlock, PB IDE, VC, etc. .." and put the cursor at the position where you want to copy SNIPPET
2 / Starting the program (Attention at the beginning the program is in the systray, you can modify like you want after)
3 / Click on "Select window"
4 / Click on the title bar of the selected IDE (The title should appear in the combo box at the bottom)
You can also directly select in the combo box if you don't want select by the mouse
5 / SNIPPET Select one of the categories in the TreeGadget (For each snippet selected, the comment appears at the bottom of the window)
6/ Double click it, the text should normally appear in your favorite IDE
- It is therefore for the moment, send the text by two different methods
- You can position the window of four ways (On the left side, she hides automatically as in the PB IDE, or in the systray, or free modal or free no-modal)
- You can adjust the speed at which it hides
- You can also choose the language
To do list
Find how to send a text cursor with the API (SendMessage or other)
The creation / deletion of snippets and classes
Detection of the language use (C, PB, Html, etc ...)
Make it pretty (icons, skins, etc ...)
And maybe other ideas along the way (From you or me, of course
) mainly if i can
http://passion.ne.free.fr/SnippetManagER.zip
Thank you for your interest.
My program works with items like keys CTRL+C / CTRL+V and also with sending each character.
But I would have loved to have the direct method sending a text, if it is possible of course.
To show you what I've done, here's a draft of my program.
It is super simple to use, well I hoped
1 / Choose the IDE text you want to copy a SNIPPET "NotePad, NotePad++, CodeBlock, PB IDE, VC, etc. .." and put the cursor at the position where you want to copy SNIPPET
2 / Starting the program (Attention at the beginning the program is in the systray, you can modify like you want after)
3 / Click on "Select window"
4 / Click on the title bar of the selected IDE (The title should appear in the combo box at the bottom)
You can also directly select in the combo box if you don't want select by the mouse
5 / SNIPPET Select one of the categories in the TreeGadget (For each snippet selected, the comment appears at the bottom of the window)
6/ Double click it, the text should normally appear in your favorite IDE

- It is therefore for the moment, send the text by two different methods
- You can position the window of four ways (On the left side, she hides automatically as in the PB IDE, or in the systray, or free modal or free no-modal)
- You can adjust the speed at which it hides
- You can also choose the language
To do list
Find how to send a text cursor with the API (SendMessage or other)
The creation / deletion of snippets and classes
Detection of the language use (C, PB, Html, etc ...)
Make it pretty (icons, skins, etc ...)
And maybe other ideas along the way (From you or me, of course


http://passion.ne.free.fr/SnippetManagER.zip
Thank you for your interest.
Sorry but, Google translate is my friend 

Re: Handle of the object holding the cursor
Apparently my project does not interest many people.
I progressed through a code of FWEIL, I can now list the classes and thanks to DIGGER I can focus on the good.
It remains problematical and not least, I still do not know how to detect the object in focus, so whoever at the cursor when the window gets focus
In VC + + 2005, for exampler, all tabs have the same name of class, and my text is sent in each.
Someone he would pity a beginner ??

I progressed through a code of FWEIL, I can now list the classes and thanks to DIGGER I can focus on the good.
It remains problematical and not least, I still do not know how to detect the object in focus, so whoever at the cursor when the window gets focus
In VC + + 2005, for exampler, all tabs have the same name of class, and my text is sent in each.
Someone he would pity a beginner ??

Code: Select all
Structure FindWindowData
hFW.l ; variable to store a handle
sFW.s ; variable to store a Window name
cFW.s ; variable to store a window class name
EndStructure
Global NewList FindWindow.FindWindowData()
Procedure.l EnumChildProc(hChild, lParam)
ChildClass.s = Space(255)
GetClassName_(hChild, @ChildClass, 255)
If ChildClass = "VbaWindow" ; VB6
SendMessage_(hChild, #WM_CHAR, #VK_A, 1)
EndIf
If ChildClass = "Afx:400000:8" ; VC6++
SendMessage_(hChild, #WM_CHAR, #VK_A, 1)
EndIf
If ChildClass = "wxWindowClassNR" ; CodeBlock v10.5
SendMessage_(hChild, #WM_CHAR, #VK_A, 1)
EndIf
If ChildClass = "Scintilla" ; PB and NotePad++
SendMessage_(hChild, #WM_CHAR, #VK_A, 1)
EndIf
ProcedureReturn 1
EndProcedure
Procedure.l EnumWindowsProc(hFind, lParam)
WindowName.s = Space(255)
WindowClass.s = Space(255)
If GetWindowText_(hFind, WindowName, 255)
Result = GetClassName_(hFind, WindowClass, 255)
AddElement(FindWindow())
FindWindow()\hFW = hFind
FindWindow()\sFW = WindowName
FindWindow()\cFW = WindowClass
EndIf
ProcedureReturn 1
EndProcedure
If EnumWindows_(@EnumWindowsProc(), 0)
ResetList(FindWindow())
While NextElement(FindWindow())
EnumChildWindows_(FindWindow()\hFW, @EnumChildProc(), 0)
Wend
EndIf
Sorry but, Google translate is my friend 

Re: Handle of the object holding the cursor
I'm not sure I understand exactly what it is you're attempting, but if you are attempting to capture keystrokes in another application so you can add/switch the text, you might want to investigate a keyboard hook. There are examples in the forums, but it's not exactly a beginner project.
cheers
cheers
Re: Handle of the object holding the cursor
Have you try the exe in the link ???
If you try it you understand what i want to do
I want just can copy text in another application and paste it in PB appli, and of course the opposite.
Since yesterday i have found another way to send text to another application.
It's again a code of Netmaestro
using SendInput API, and that works great.
http://www.purebasic.fr/english/viewtop ... 87#p289987
I'll add this method in my combobox of methods
Send text has an external program is not very reliable, so I'll put all the possible methods, how the user can choose the one that suits him best.
I have now this methods:
KeybEvent key by key method (Works but if the text is long, the user must not touch the keyboard, while sending text)
ClipBoard CTRL KeybEvent c+v (Works, but the clipboard is used, and if the user have something into it...it is lost)
ClipBoard Sendmessage WM_PASTE method (Works, but the clipboard is used, and if the user have something into it...it is lost)
SendInput method (Works, i don't now if the user can disturb while the sending of the text ??)
Sendmessage WM_CHAR method (I have not found again, how send #CRLF$, and lowercase) if someone know ??
If you try it you understand what i want to do

I want just can copy text in another application and paste it in PB appli, and of course the opposite.
Since yesterday i have found another way to send text to another application.
It's again a code of Netmaestro

http://www.purebasic.fr/english/viewtop ... 87#p289987
I'll add this method in my combobox of methods
Send text has an external program is not very reliable, so I'll put all the possible methods, how the user can choose the one that suits him best.
I have now this methods:
KeybEvent key by key method (Works but if the text is long, the user must not touch the keyboard, while sending text)
ClipBoard CTRL KeybEvent c+v (Works, but the clipboard is used, and if the user have something into it...it is lost)
ClipBoard Sendmessage WM_PASTE method (Works, but the clipboard is used, and if the user have something into it...it is lost)
SendInput method (Works, i don't now if the user can disturb while the sending of the text ??)
Sendmessage WM_CHAR method (I have not found again, how send #CRLF$, and lowercase) if someone know ??

Sorry but, Google translate is my friend 
