Bonjour à tous !
Alors j'ai besoin d'un peu d'aide s'il vous plait !
Je m'explique, en fait j'ai abandonné l'idée d'appeler un clavier virtuel (osk.exe) car en fait la tablette est munie d'un clavier (dans la barre d'outils en bas et ce n'est pas le même que osk.exe, celui de la tablette windows s'appelle TabTip.exe mais impossible de lui fournir le chemin) et j'ai remarqué que lorsque je clique avec la tablette sur une zone où il est permis d'écrire quelque chose (style moteur de recherche, ou recherche dans le menu, etc...) et bien le clavier se lance automatiquement ! J'ai fait pas mal de recherche hier et j'ai trouvé ce qu'il me faut ====> https://code.msdn.microsoft.com/wind...hId=1342120152
Il propose gratuitement de le télécharger, c'est ce que j'ai fait, et il s'avère que ça fonctionne parfaitement sur ma tablette Windows !
En revanche c'est du C#, lorsque j'ai voulu convertir son projet en vb.net.... je me prends pas mal d'erreur...
Je vous montre :
C#
Mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 using System.Windows; using System.Windows.Interop; namespace ModernWPF.Win8TouchKeyboard.Desktop { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); // Disables inking in the WPF application and enables us to track touch events to properly trigger the touch keyboard InkInputHelper.DisableWPFTabletSupport(); this.Loaded += MainWindow_Loaded; } private void MainWindow_Loaded(object sender, RoutedEventArgs e) { // Enables WPF to mark edit field as supporting text pattern (Automation Concept) System.Windows.Automation.AutomationElement asForm = System.Windows.Automation.AutomationElement.FromHandle(new WindowInteropHelper(this).Handle); // Windows 8 API to enable touch keyboard to monitor for focus tracking in this WPF application InputPanelConfigurationLib.InputPanelConfiguration inputPanelConfig = new InputPanelConfigurationLib.InputPanelConfiguration(); inputPanelConfig.EnableFocusTracking(); } } }
VB.NET
InkInputHelper C# :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 ' To change this template use Tools | Options | Coding | Edit Standard Headers. ' Imports System Imports System.Collections.Generic Imports System.Text Imports System.Windows Imports System.Windows.Controls Imports System.Windows.Data Imports System.Windows.Documents Imports System.Windows.Input Imports System.Windows.Media Imports System.Windows.Interop Namespace ModernWPF.Win8TouchKeyboard.Desktop ''' <summary> ''' Interaction logic for MainWindow.xaml ''' </summary> Public Partial Class MainWindow Inherits Window Public Sub New() MyBase.New 'InitializeComponent() ' Disables inking in the WPF application and enables us to track touch events to properly trigger the touch keyboard InkInputHelper.DisableWPFTabletSupport Me.Loaded = (Me.Loaded + MainWindow_Loaded) End Sub Private Sub MainWindow_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs) ' Enables WPF to mark edit field as supporting text pattern (Automation Concept) Dim asForm As System.Windows.Automation.AutomationElement = System.Windows.Automation.AutomationElement.FromHandle((New WindowInteropHelper(Me) + Handle)) ' Windows 8 API to enable touch keyboard to monitor for focus tracking in this WPF application Dim inputPanelConfig As InputPanelConfigurationLib.InputPanelConfiguration = New InputPanelConfigurationLib.InputPanelConfiguration inputPanelConfig.EnableFocusTracking End Sub End Class End Namespace
InkInputHelper vb.net :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 using System; using System.Reflection; using System.Windows.Input; namespace ModernWPF.Win8TouchKeyboard.Desktop { public static class InkInputHelper { public static void DisableWPFTabletSupport() { // Get a collection of the tablet devices for this window. TabletDeviceCollection devices = System.Windows.Input.Tablet.TabletDevices; if (devices.Count > 0) { // Get the Type of InputManager. Type inputManagerType = typeof(System.Windows.Input.InputManager); // Call the StylusLogic method on the InputManager.Current instance. object stylusLogic = inputManagerType.InvokeMember("StylusLogic", BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, InputManager.Current, null); if (stylusLogic != null) { // Get the type of the stylusLogic returned from the call to StylusLogic. Type stylusLogicType = stylusLogic.GetType(); // Loop until there are no more devices to remove. while (devices.Count > 0) { // Remove the first tablet device in the devices collection. stylusLogicType.InvokeMember("OnTabletRemoved", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, null, stylusLogic, new object[] { (uint)0 }); } } } } } }
Evidemment j'ai utilisé des convertisseurs C# to Vb.net sur le net puis j'ai modifié moi même ce que je connaissais.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 ' To change this template use Tools | Options | Coding | Edit Standard Headers. ' Imports System Imports System.Web.Mvc Imports System.Reflection Imports System.Windows.Input Namespace ModernWPF.Win8TouchKeyboard.Desktop Public Class InkInputHelper Public Shared Sub DisableWPFTabletSupport() ' Get a collection of the tablet devices for this window. Dim devices As TabletDeviceCollection = System.Windows.Input.Tablet.TabletDevices If (devices.Count > 0) Then ' Get the Type of InputManager. Dim inputManagerType As Type = GetType(System.Windows.Input.InputManager) ' Call the StylusLogic method on the InputManager.Current instance. Dim stylusLogic As Object = inputManagerType.InvokeMember("StylusLogic", (BindingFlags.GetProperty _ Or (BindingFlags.Instance Or BindingFlags.NonPublic)), Nothing, InputManager.Current, Nothing) If (Not (stylusLogic) Is Nothing) Then ' Get the type of the stylusLogic returned from the call to StylusLogic. Dim stylusLogicType As Type = stylusLogic.GetType ' Loop until there are no more devices to remove. While (devices.Count > 0) ' Remove the first tablet device in the devices collection. stylusLogicType.InvokeMember("OnTabletRemoved", (BindingFlags.InvokeMethod _ Or (BindingFlags.Instance Or BindingFlags.NonPublic)), Nothing, stylusLogic, New Object() {CType(0,UInteger)}) End While End If End If End Sub End Class End Namespace
Il me reste 5 erreurs... par rapport à cette ligneet celle ci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part Me.Loaded = (Me.Loaded + MainWindow_Loaded)
Code : Sélectionner tout - Visualiser dans une fenêtre à part Dim asForm As System.Windows.Automation.AutomationElement = System.Windows.Automation.AutomationElement.FromHandle((New WindowInteropHelper(Me) + Handle))
Si quelqu'un pourrait m'aider svp
Partager