Форум программистов, компьютерный форум, киберфорум
Visual Basic
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
 
Рейтинг 4.69/29: Рейтинг темы: голосов - 29, средняя оценка - 4.69
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69

Disable the input method of the text control of other programs

15.12.2020, 15:09. Показов 5979. Ответов 35
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
I have a program, when I use a QR code scanner to scan the code, I must set the text control to the English input method. Otherwise, the scan will fail. It should be because I don’t have the source code. I want to know how to specify this text box The input method of the control is English. I want to make a plug-in to automatically perform this operation. Automatically detect when the cursor is in the target text box, modify the input method. Thank you

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Public Function FindCaretHwnd() As Long
    Dim iHwnd   As Long
    Dim iThread As Long
    Dim iGTI    As GUITHREADINFO
    
    iHwnd = GetForegroundWindow
    iThread = GetWindowThreadProcessId(iHwnd, 0&)
    iGTI.cbSize = Len(iGTI)
    GetGUIThreadInfo iThread, iGTI
 
    FindCaretHwnd = iGTI.hwndcaret
  Debug.Print FindCaretHwnd
    ' Debug.Print " Focus " & iGTI.hwndFocus & vbCrLf & "Active: " & iGTI.hwndactive & vbCrLf & "Caret: " & iGTI.hwndcaret & vbCrLf & "Capture: " & iGTI.hwndCapture
 
End Function
Call PostMessage(mhwnd, WM_INPUTLANGCHANGEREQUEST, 0, ENid) ' //ENid = Use Language ID 0x0409(English PRC)

But it doesn’t seem to work perfectly in win10. Is there any other good way?


ImmAssociateContext(mHwnd, 0) It can only act on its own process and has no effect on other processes

ImmAssociateContextEx(mHwnd, 0, 0) It can only act on its own process and has no effect on other processes
0
Programming
Эксперт
39485 / 9562 / 3019
Регистрация: 12.04.2006
Сообщений: 41,671
Блог
15.12.2020, 15:09
Ответы с готовыми решениями:

Как сделать disable для input text?
Вопрос заключается в следующем, как при выборе определенной опции в select'e делать определенный input disable(select и input принадлежат...

Проблема с формой (<form action=1.php method=post> <input type=text name='first'> <input type=submit value=ok>)
Я пишу: &lt;form action=1.php method=post&gt; &lt;input type=text name='first'&gt; &lt;input type=submit value=ok&gt; по идее 1.php должен принять...

How to determinate cursor position in HTML <input type=text> control.
How to determinate cursor position in HTML &lt;input type=text&gt; control. Thanx in advance.

35
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69
28.12.2020, 10:47  [ТС]
Студворк — интернет-сервис помощи студентам
i want used this api "DisableCurrentIme" to disable input method in the other program .i want injected dll to the program.and run DisableCurrentIme.

Visual Basic
1
2
3
            Dim res As Long
            res = DisableCurrentIme(wParam)
            SendMessage hWndServer, WM_SENDMESSAGE, res, ByVal 0&
======================================== ==
test.zip have a test.exe .this is the target program! run this exe ,click the button will show work form.now i want hook this window,and then when the text control have forcus. dll can run DisableCurrentIme !

I want to try this technique.

Добавлено через 1 час 19 минут
thank you sir.

in the test.zip .you can see test.exe.

i want injection dll to the hook the work form .when the text control have forcuse i want run this API DisableCurrentIme to disable

Keyboard input method.

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
' // Window procedure
Private Function WndProc(ByVal hwnd As Long, _
                         ByVal uMsg As Long, _
                         ByVal wParam As Long, _
                         ByVal lParam As Long) As Long
    Dim sendData As MsgData
    Dim prevProc As Long
    Dim mHwnd    As Long
 
    Select Case uMsg
 
            ' // Check if the main application queries the subclassing completion
        Case uMsg = WM_SENDMESSAGE
    
            ' // Get the original window handle
            prevProc = GetProp(hwnd, CLng(aPrevProc) And &HFFFF&)
            ' // Restore the original window handle
            SetWindowLong hwnd, GWL_WNDPROC, prevProc
            ' // Clean
            Clear
        
            ' // Disable subclassing
            ' // It's possible that GetMsgProc is called when hook has not been disabled in the main application.
            ' // This flag prevents the re-initialization
           
            disabled = True
            FindedHwnd = False
            Exit Function
 
            ' // Now UnhookWindowsHookEx will be called and this dll will be unloaded
 
        Case WM_SETCURSOR '(&H20) 'wParam=&H2A0ADE lParam=&H2000012 Result=&H0
 
            If FindedHwnd = False Then
                mHwnd = GetFocus
 
                If mHwnd <> 0 Then
                    If GetDlgCtrlID(mHwnd) = &H1 Then '//。
                        '                        wParam = mHwnd
                        '                        lParam = mHwnd
                       ' Dim res As Long
                        Call DisableCurrentIme(mHwnd)
                        FindedHwnd = True
                        SendMessage hWndServer, WM_SENDMESSAGE, 666, ByVal 0&
                        
                    End If
                End If
            End If
            '        Case WM_KILLFOCUS '&H8) ' wParam=&H0 lParam=&H0 Result=&H1
            '            wParam = GetFocus
            '            lParam = GetFocus
    End Select
    
    ' // Check if it's needed to process the message
    
    prevProc = GetProp(hwnd, CLng(aPrevProc) And &HFFFF&)
    WndProc = CallWindowProc(prevProc, hwnd, uMsg, wParam, lParam)
    
End Function
but when i inject dll to the exe .But the program crashes after execution

see the picture 18#

Добавлено через 3 минуты
Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
' // Window procedure
Private Function WndProc(ByVal hwnd As Long, _
                         ByVal uMsg As Long, _
                         ByVal wParam As Long, _
                         ByVal lParam As Long) As Long
    Dim sendData As MsgData
    Dim prevProc As Long
    Dim mHwnd    As Long
 
    Select Case uMsg
 
            ' // Check if the main application queries the subclassing completion
        Case uMsg = WM_SENDMESSAGE
    
            ' // Get the original window handle
            prevProc = GetProp(hwnd, CLng(aPrevProc) And &HFFFF&)
            ' // Restore the original window handle
            SetWindowLong hwnd, GWL_WNDPROC, prevProc
            ' // Clean
            Clear
        
            ' // Disable subclassing
            ' // It's possible that GetMsgProc is called when hook has not been disabled in the main application.
            ' // This flag prevents the re-initialization
           
            disabled = True
            FindedHwnd = False
            Exit Function
 
            ' // Now UnhookWindowsHookEx will be called and this dll will be unloaded
 
        Case WM_SETCURSOR '(&H20) 'wParam=&H2A0ADE lParam=&H2000012 Result=&H0
 
            If FindedHwnd = False Then
                mHwnd = GetFocus
 
                If mHwnd <> 0 Then
                    If GetDlgCtrlID(mHwnd) = &H1 Then '//。
                        '                        wParam = mHwnd
                        '                        lParam = mHwnd
                       ' Dim res As Long
                        Call DisableCurrentIme(mHwnd)
                        FindedHwnd = True
                        SendMessage hWndServer, WM_SENDMESSAGE, 666, ByVal 0&
                        
                    End If
                End If
            End If
            '        Case WM_KILLFOCUS '&H8) ' wParam=&H0 lParam=&H0 Result=&H1
            '            wParam = GetFocus
            '            lParam = GetFocus
    End Select
    
    ' // Check if it's needed to process the message
    
    prevProc = GetProp(hwnd, CLng(aPrevProc) And &HFFFF&)
    WndProc = CallWindowProc(prevProc, hwnd, uMsg, wParam, lParam)
    
End Function
i want inject dll to the test.exe in the test.zip to disable the ime . But the program crashes after execution

see 17 # .18#
0
Модератор
10057 / 3902 / 884
Регистрация: 22.02.2013
Сообщений: 5,853
Записей в блоге: 79
28.12.2020, 23:52
Do you need to disable the IME only for a specific window?
0
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69
29.12.2020, 02:17  [ТС]
@the trick. yes. you are right.

Добавлено через 3 минуты
I just want to disable the input method of a specific window!

In addition, I want to know, what is wrong with my use of your dll inject method? Can you tell this defect
0
Модератор
10057 / 3902 / 884
Регистрация: 22.02.2013
Сообщений: 5,853
Записей в блоге: 79
29.12.2020, 14:37
Лучший ответ Сообщение было отмечено xxdoc как решение

Решение

Цитата Сообщение от xxdoc Посмотреть сообщение
@the trick. yes. you are right.
There is the more simple way to do that without runtime initialization.
Вложения
Тип файла: zip injectdll.zip (16.1 Кб, 25 просмотров)
0
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69
29.12.2020, 17:43  [ТС]
thank you

I'm glad you have time to reply to my question. I also tested your demo and it works well. But I modified it a bit. I hope to hook the text box automatically. There is a problem here. Please see the attachment,if hooked i have to click on the window of Injector.exe first, after transferring the focus, click on the text box. Then I can disable the input method.


injectdll.zip


By the way, is there any problem with the previous dll inject method?

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
        Case WM_SETCURSOR '(&H20) 'wParam=&H2A0ADE lParam=&H2000012 Result=&H0
 
            If FindedHwnd = False Then
                mHwnd = GetFocus
 
                If mHwnd <> 0 Then
                    If GetDlgCtrlID(mHwnd) = &H1 Then '//。
                        '                        wParam = mHwnd
                        '                        lParam = mHwnd
                       ' Dim res As Long
                        Call DisableCurrentIme(mHwnd)
                        FindedHwnd = True
                        SendMessage hWndServer, WM_SENDMESSAGE, 666, ByVal 0& 
                        
                    End If
                End If
            End If
I want to understand the direct information exchange between this dll and the control program.I hope to be able to use other aspects
0
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69
02.01.2021, 03:37  [ТС]
It seems that if you don't understand OD or other languages, you can't figure it out.

This is the trick that can be used very well. And we will have all kinds of doubts

Happy New Year!
0
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69
03.01.2021, 06:11  [ТС]
This is the effect I achieved with non-dll injection. I hope to use dll to achieve it again

used this dll inject

https://www.vbforums.com/showt... ost5505050

I think this method of dll injection and file mapping to transfer data is very useful
Миниатюры
Disable the input method of the text control of other programs  
0
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69
04.01.2021, 10:25  [ТС]
can give me a demo ?used timer

sub timer

if true then
dll inject
else

unload hook

end sub
0
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69
06.01.2021, 11:41  [ТС]
Thanks the trick

now i konw why ...

There is the more simple way to do that without runtime initialization.
Добавлено через 5 часов 24 минуты
in win10 ;If the injected program is not an administrator runed, it cannot be injected. how can fixed this
0
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69
07.01.2021, 09:47  [ТС]
cant used timer ... It's a big problem!

in ide used timer work well ,but exe cant used timer .crashes or becomes nonresp~~~

Добавлено через 3 часа 3 минуты
because this timer have a do loop to find a window handle !
0
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69
08.01.2021, 08:36  [ТС]
I am ready to give up looking for a solution. Maybe it is more practical to learn a new language and write dll
0
Модератор
10057 / 3902 / 884
Регистрация: 22.02.2013
Сообщений: 5,853
Записей в блоге: 79
08.01.2021, 09:40
Please provide a normal example.

Добавлено через 18 минут
Цитата Сообщение от xxdoc Посмотреть сообщение
I am ready to give up looking for a solution. Maybe it is more practical to learn a new language and write dll
I've already provided the example here.
0
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69
08.01.2021, 12:12  [ТС]
I've already provided the example here.
I know your demo. And it works very well. But I am not very familiar with the way you share data between processes. I prefer to pass data through file mapping. This can be used by me in future code.

So I like your dll injection function in vbfroums.

see 27# gif . This is the effect display


please help me modify this code!! I want to use partial matching to find the window handle,This is the most important place.
Вложения
Тип файла: zip helpSubclassNativeDLL.zip (33.2 Кб, 8 просмотров)
0
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69
11.01.2021, 04:16  [ТС]
Waiting is really a bad feeling. please reply
0
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69
15.01.2021, 04:48  [ТС]
now used EnumWindows find hwnd .now work ok .game over
0
7 / 7 / 0
Регистрация: 10.07.2015
Сообщений: 69
20.01.2021, 09:43  [ТС]
same code in win10 work ok. in win7 work not ok. Unable to debug, the injected program does not respond. This is estimated to be only a toy for me. give up
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
inter-admin
Эксперт
29715 / 6470 / 2152
Регистрация: 06.03.2009
Сообщений: 28,500
Блог
20.01.2021, 09:43
Помогаю со студенческими работами здесь

результат выборки из БД: rs.next(); String text=rs.getString('text'); <input type=text name=name value=<%=text%>>
Возникла проблема в текстовое поле надо вывести результат выборки из БД rs.next(); String text=rs.getString('text'); &lt;input...

How programatically disable all controls within frame without actually specifying each control name?
Hello! I have Control array of 5 frames on the form. Each frame containes different controls. When I disable each frame, how...

Нажав на checkbox, input text появится у первого checkbox всегда, хотя должен input text появится у того checkbox
Добрый день. php создаёт такие блоки. Но если нажать на checkbox, то input text появится у первого checkbox'а всегда, хотя должен input...

Одинаковая ширина для полей input text & input password
Никак не получается выровнять ширину двух тектовых полей: input type='text' и input type='password' Помогите, пожалуйста.

Одинаковая ширина для полей input text & input password
Никак не получается выровнять ширину двух тектовых полей: input type='text' и input type='password' Помогите, пожалуйста.


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
36
Ответ Создать тему
Новые блоги и статьи
Модульная разработка через nuget packages
DevAlt 07.03.2026
Сложившийся в . Net-среде способ разработки чаще всего предполагает монорепозиторий в котором находятся все исходники. При создании нового решения, мы просто добавляем нужные проекты и имеем. . .
Модульный подход на примере F#
DevAlt 06.03.2026
В блоге дяди Боба наткнулся на такое определение: В этой книге («Подход, основанный на вариантах использования») Ивар утверждает, что архитектура программного обеспечения — это структуры,. . .
Управление камерой с помощью скрипта OrbitControls.js на Three.js: Вращение, зум и панорамирование
8Observer8 05.03.2026
Содержание блога Финальная демка в браузере работает на Desktop и мобильных браузерах. Итоговый код: orbit-controls-threejs-js. zip. Сканируйте QR-код на мобильном. Вращайте камеру одним пальцем,. . .
SDL3 для Web (WebAssembly): Синхронизация спрайтов SDL3 и тел Box2D
8Observer8 04.03.2026
Содержание блога Финальная демка в браузере. Итоговый код: finish-sync-physics-sprites-sdl3-c. zip На первой гифке отладочные линии отключены, а на второй включены:. . .
SDL3 для Web (WebAssembly): Идентификация объектов на Box2D v3 - использование userData и событий коллизий
8Observer8 02.03.2026
Содержание блога Финальная демка в браузере. Итоговый код: finish-collision-events-sdl3-c. zip Сканируйте QR-код на мобильном и вы увидите, что появится джойстик для управления главным героем. . . .
Реалии
Hrethgir 01.03.2026
Нет, я не закончил до сих пор симулятор. Эта задача сложнее. Не получилось уйти в плавсостав, но оно и к лучшему, возможно. Точнее получалось - но сварщиком в палубную команду, а это значит, в моём. . .
Ритм жизни
kumehtar 27.02.2026
Иногда приходится жить в ритме, где дел становится всё больше, а вовлечения в происходящее — всё меньше. Плотный график не даёт вниманию закрепиться ни на одном событии. Утро начинается с быстрых,. . .
SDL3 для Web (WebAssembly): Сборка библиотек: SDL3, Box2D, FreeType, SDL3_ttf, SDL3_mixer и SDL3_image из исходников с помощью CMake и Emscripten
8Observer8 27.02.2026
Недавно вышла версия 3. 4. 2 библиотеки SDL3. На странице официальной релиза доступны исходники, готовые DLL (для x86, x64, arm64), а также библиотеки для разработки под Android, MinGW и Visual Studio. . . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru