problem to get Notepad's ImmGetContext
VB Code:
Private Declare Function ImmGetContext Lib "imm32.dll" (ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Long
Private Sub Command1_Click()
dim hwnd as long,hIMC as long
hwnd = FindWindow("Notepad", vbnullstring)
if hwnd<>0 then
hIMC=ImmGetContext(hwnd)
msgbox hIMC
end if
end sub
but hIMC always return 0,how can i get notepad 's ImmGetContext,anyone can help me? :(
Re: problem to get Notepad's ImmGetContext
What is notepad's ImmGetContext? What is an ImmGetContext?
Re: problem to get Notepad's ImmGetContext
I have never worked with IME so my knowledge is rather vague. First, is the IME program installed on your computer. If it is, I think it's the Notepad edit window that is provided with IME.
As I said, my knowledge is vague.
Re: problem to get Notepad's ImmGetContext
What is IME? What are you trying to do? Get the text in an open notepad window?
Re: problem to get Notepad's ImmGetContext
Re: problem to get Notepad's ImmGetContext
ImmGetContext
Returns the input context associated with the specified window.
HIMC ImmGetContext(
HWND hWnd
);
Parameters
hWnd
[in] Handle to the window for which to retrieve the input context.
Return Values
Returns the handle to the input context.
Remarks
An application should routinely use this function to retrieve the current input context before attempting to access information in the context.
------------------------------------------------------
the problem is if hwnd isn't myself process,then this APIdoesn't work
if i set hwnd = FindWindow("", "Form1") or hwnd=form1.hwnd or hwnd=text1.text
it's both work
if hwnd is external process's hwnd,then it's doesn't work:(
anyone can help me?
Re: problem to get Notepad's ImmGetContext
maybe can use c++ write a dll,this dll can get ImmGetContext,then use VB inject this dll to notepad,but i don't know how to write it in c++....
Re: problem to get Notepad's ImmGetContext
So you want to get the text that is typed in a notepad instance, right? Try searching for the FindWindow, FindWindowEx and GetWindowText APIs.
Re: problem to get Notepad's ImmGetContext
Quote:
Originally Posted by manavo11
So you want to get the text that is typed in a notepad instance, right? Try searching for the FindWindow, FindWindowEx and GetWindowText APIs.
no,i want get IME CandidateList's text,so your way doesn't work