Jump to content

Recommended Posts

  • Moderators
Posted

yetrael,

As far as I know you cannot use the Tab key directly in an edit control - you need to use Ctrl-Tab to insert a @TAB character into the text. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • Moderators
Posted

yetrael,

This is a Windows limitation - not AutoIt - as Windows uses the TAB key to change the keyboard focus to the next control in the TABSTOP list. So I doubt you will find an easier workaround than you already have in Ctrl-TAB. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted (edited)

Don't doubt me! :-D

Func _GUICtrlEdit_InsertTab()
If Not $bHotKeyFunctionRunning Then
$bHotKeyFunctionRunning = True
$iCharIndex = _GUICtrlEdit_GetSel($hEdit)[0]
_GUICtrlEdit_InsertText($hEdit, Chr(9), $iCharIndex)
$bHotKeyFunctionRunning = False
EndIf
EndFunc ;==>_GUICtrlEdit_InsertTab

Ans that is for the While...WEnd loop of the GUI:

Dim $bHotkeySet = False
While 1
$cFocus = ControlGetHandle($mGUI, "", ControlGetFocus($mGUI))
If $cFocus = $hwndEdit And $bHotkeySet = False Then
$bHotkeySet = True
HotKeySet("{TAB}", "_GUICtrlEdit_InsertTab")
ElseIf $cFocus <> $hwndEdit And $bHotkeySet = True Then
$bHotkeySet = False
HotKeySet("{TAB}")
EndIf
WEnd

Can still be improved!

Edited by yetrael
Posted

You'd be better off using GUISetAccelerator than using HotKeySet. Although, typing CTRL-Tab is still just as easy.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

  • Moderators
Posted

BrewManNH,

+ 1 :thumbsup:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

You sure? I always thought GUISetAccelerator would create an event for a button etc. Of course, I could create a dummy control and use it within this one.

I'll will check which one is faster and more usable.

And yes, CTRL-TAB is still handy. But I'm used to just Tab...

Posted

BTW, your code doesn't run. This line "$iCharIndex = _GUICtrlEdit_GetSel($hEdit)[0]" is formatted incorrectly.

This might work better for what you're attempting.

#include <GUIConstantsEx.au3>
#include <guiedit.au3>
Local $iEditID
Example()

Func Example()
     GUICreate("Custom MsgBox", 225, 80)

     $iEditID = GUICtrlCreateEdit("", 10, 10, 210, 20)
     Local $aAccelKeys[1][2] = [["{Tab}", $iEditID]]
     GUISetAccelerators($aAccelKeys)

     GUISetState() ; Display the GUI.

     While 1
          Switch GUIGetMsg()
               Case $GUI_EVENT_CLOSE
                    MsgBox(4096, "You selected", "Close")
                    ExitLoop

               Case $iEditID
                    _GUICtrlEdit_InsertTab()
          EndSwitch
     WEnd
     GUIDelete() ; Delete the GUI.
EndFunc   ;==>Example

Func _GUICtrlEdit_InsertTab()
     Local $iIndex = _GUICtrlEdit_GetSel($iEditID)
     _GUICtrlEdit_InsertText($iEditID, Chr(9), $iIndex[0])
EndFunc   ;==>_GUICtrlEdit_InsertTab

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

Thanks BrewManNH,

I like the solution with the GUISetAccelerators, updated my script.

And yes, if you use the AutoIt beta, you can do it like I did!

  Quote

3.3.9.3 (8th April, 2012) (Beta)

AutoIt:

- Added #1191: Explicit size of arrays optional for explicit initialization.

- Added: Array access on expression: StringSplit("a,b", ",")[1]

Posted

But, it won't run on the non-beta version of AutoIt, and that should have been mentioned in the post that you were using it on the Beta. Someone coming across this wouldn't know that, and using it on the production version throws an error.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...