<div dir="ltr"><div dir="ltr">> here is the problem, when I put cursor in the desired textbox, it evokes<br>> the code and losing the focus the focus again the textbox making it evoking<br>> the same code again and so on<br><br>I can not understand the reason for the loss of focus, in the simple tests I made this does not happen, eg:<br><br>Public Sub TextBox1_GotFocus()<br><br>  keyboard(TextBox1)<br><br>End<br><br>Public Sub TextBox2_GotFocus()<br><br>  keyboard(TextBox2)<br><br>End<br><br>' Etcetera...<br><br>Private Sub keyboard(hTxt As TextBox)<br>  <br>  Dim s As String<br><br>  Desktop.SendKeys("{[Shift_L]6}")<br>  Wait 0.1<br>  s = Mid(hTxt.Text, hTxt.Pos, 1)<br>  Print s<br>  Wait 0.1<br>  Desktop.SendKeys("[BackSpace]")<br>  If s = "&" Then<br>    Print "Italian keyboard"<br>  Else<br>    Print "Stranger keyboard"<br>  Endif <br>  <br>End<br><br>Regards<br>Gianluigi<br></div></div><br><div class="gmail_quote"><div dir="ltr">Il giorno gio 4 ott 2018 alle ore 01:00 Gianluigi <<a href="mailto:bagonergi@gmail.com">bagonergi@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">If you get the layout when you open the app, it should work.<br>Just keep an eye on the switches, e.g:</div><div dir="ltr"><br></div><div dir="ltr">Private $bItalian As Boolean<br><br>Public Sub Form_Open()<br>  <br>  Dim s As String<br>  Dim hTxt As TextBox<br>  <br>  hTxt = New TextBox(Me)<br>  hTxt.Foreground = Color.Transparent<br>  hTxt.SetFocus  <br>  Me.Show<br>  Wait 0.1<br>  Desktop.SendKeys("{[Shift_L]6}")<br>  Wait 0.1<br>  s = hTxt.Text<br>  <br>  hTxt.Delete<br>  If s = "&" Then<br>    $bItalian = True<br>    Print "Italian keyboard"    <br>  Else<br>    $bItalian = False<br>    Print "Stranger keyboard"<br>  Endif<br>  Print $bItalian<br>  <br>End<br><br>Public Sub Form_KeyPress()<br>  <br>  ' I don't remember your shortcut to switch keyboard layout, supposing Ctrl+K<br>  If Key.Code = Key["K"] And If Key.Control Then<br>    $bItalian = Not $bItalian<br>    Print $bItalian<br>  End If<br>  <br>End</div><div dir="ltr"><br></div><div>Regards</div><div>Gianluigi<br></div></div></div><br><div class="gmail_quote"><div dir="ltr">Il giorno mer 3 ott 2018 alle ore 23:28 Wael M via User <<a href="mailto:user@lists.gambas-basic.org" target="_blank">user@lists.gambas-basic.org</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thank you very much Gianluigi for your help, grazie :)<br>
it worked and could detect my language but not the way I want<br>
let me tell you my story :)<br>
I came to linux from windows and I'm trying to translate an app I did with VB to the corresponding codes in Gambas.<br>
I realized that Gambas is not the same as VB because Linux is not the same as windows<br>
Gambas is just using the same names and following the main rules of VB <br>
in my app I had a form that with three textboxes are filled in Arabic and three are filled in English<br>
when I put the cursor in a textbox it detects the keyboard layout and change it to the desired language<br>
I followed the code you gave but I want to put the event of this code to be when textbox got focus<br>
here is the problem, when I put cursor in the desired textbox, it evokes the code and losing the focus the focus again the textbox making it evoking the same code again and so on<br>
so what I really need is to detect the keyboard layout like reading it directly from linux<br>
<br>
again and again thank you very much for your patience and help<br>
<br>
--------------------------------------------<br>
On Wed, 10/3/18, Gianluigi <<a href="mailto:bagonergi@gmail.com" target="_blank">bagonergi@gmail.com</a>> wrote:<br>
<br>
 Subject: Re: [Gambas-user] How to Change Keyboard Layout<br>
 To: "Gambas Mailing List" <<a href="mailto:user@lists.gambas-basic.org" target="_blank">user@lists.gambas-basic.org</a>><br>
 Date: Wednesday, October 3, 2018, 4:00 PM<br>
<br>
 With this code, I'm trying to explain better<br>
 what I meant to say:<br>
<br>
 Public<br>
 Sub TextBox1_GotFocus()<br>
   <br>
   Dim s As String<br>
   <br>
  <br>
 Desktop.SendKeys("{[Shift_L]6}")<br>
   Wait 0.1<br>
   s =<br>
 TextBox1.Text<br>
   Print s<br>
  <br>
 Wait 0.1<br>
   TextBox1.Clear<br>
   If s = "&" Then<br>
     Print "Italian keyboard"<br>
   Else<br>
     Print<br>
 "Stranger keyboard"<br>
   Endif<br>
   <br>
 End<br>
<br>
 Regards<br>
 Gianluigi<br>
<br>
 Il giorno<br>
 mer 3 ott 2018 alle ore 09:45 Gianluigi <<a href="mailto:bagonergi@gmail.com" target="_blank">bagonergi@gmail.com</a>><br>
 ha scritto:<br>
 >Lee, I subscribed to the list<br>
 you mentioned but should I repeate the same thread there or<br>
 what?<br>
<br>
<br>
<br>
 >Charlie, thanks for your answer but it didn't<br>
 exactly did what I want<br>
<br>
 >I'm using Ubuntu <br>
<br>
 >the code you put gave me this result:<br>
 XKBLAYOUT=us,ara<br>
<br>
 >what I need to get is the current keyboard layout<br>
<br>
 >maybe I wasn't clear while putting my problem, so<br>
 I"ll try to explain more<br>
<br>
 >I want to check my current keyboard layout so if its<br>
 Arabic, it would be changed to English (in >some<br>
 textboxes) and vices versa.<br>
<br>
 >i.e I want to use English in some textboxes and Arabic<br>
 in others, and I <br>
 want that to be done >through a code to check Keyboard<br>
 layout and change <br>
 it if needed or keep it if no need to change >it<br>
<br>
 >thanks in advance to everyone trying to help <br>
<br>
 This<br>
 code that need to do something else, maybe you can direct it<br>
 to a key that makes you understand if the keyboard is<br>
 'ara' or 'us'.<br>
 RegardsGianluigi<br>
<br>
<br>
 ----[ Gambas mailing-list is hosted by <a href="https://www.hostsharing.net" rel="noreferrer" target="_blank">https://www.hostsharing.net</a> ]----<br>
<br>
 -----Inline Attachment Follows-----<br>
<br>
<br>
<br>
----[ Gambas mailing-list is hosted by <a href="https://www.hostsharing.net" rel="noreferrer" target="_blank">https://www.hostsharing.net</a> ]----<br>
</blockquote></div>
</blockquote></div>