Jump to content

Buttons & shotcuts


Recommended Posts

Hello to all,

need help to 'map' keyboard shortcut to a button.

In some application (eg: notepad) some menu entries are mapped with keyboard shortcut

and relative letter is underlined (Eg: letter F in file that means alt+f does an operation)

Sorry for long and silly explanation, but can't explain better without an image.

anyone can help me ?

thank you,

m.

Link to comment
Share on other sites

You can make the control or menu item with the ampersand sign before the letter to get the alt+letter effect like "Button &1" and then alt+1 will trigger this button click event.

You can also take a look at the GuiSetAcceletators function, there are some nice examples there.

Link to comment
Share on other sites

Hello to all,

need help to 'map' keyboard shortcut to a button.

In some application (eg: notepad) some menu entries are mapped with keyboard shortcut

and relative letter is underlined (Eg: letter F in file that means alt+f does an operation)

Sorry for long and silly explanation, but can't explain better without an image.

anyone can help me ?

thank you,

m.

Perhaps HotKeySet() is enough. Or, perhaps you are creating a menu on your own GUI, and just need to read up on GUICtrlCreateMenuItem() in the help file?

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

must explain scenario.

My boss want an hardware inventory. I have 300-400 pieces to insert (model, serial, floor etc.)

I buy a barcode gun to avoid most job and want to map some keyboard shorcut to buttons.

#include <GUIConstants.au3>
#include <GuiComboBoxEx.au3>
#include <String.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <misc.au3>

#Include <File.au3>
#Include <Constants.au3>

dim $progressivo = 0
dim $sede = "", $Descrizione = "", $marca = "", $modello = "", $matricola = "", $dislocazione = "", $tipo_cespite = "", $NOTE = ""

#Region ### START Koda GUI section ### Form=
$GUI_Inventario = GUICreate("INVENTARIO", 635, 636, 278, 117)
$Group1 = GUICtrlCreateGroup("Group1", 0, 0, 633, 633)

$sede = GUICtrlCreateInput("", 170, 14, 345, 56)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
$descrizione = GUICtrlCreateInput("", 170, 70, 345, 56)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
$marca = GUICtrlCreateInput("", 170, 126, 345, 56)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
$modello = GUICtrlCreateInput("", 170, 182, 345, 56)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
$matricola = GUICtrlCreateInput("", 170, 238, 345, 56)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
$dislocazione = GUICtrlCreateInput("", 170, 294, 345, 56)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
$tipo_cespite = GUICtrlCreateInput("", 170, 350, 345, 56)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
$note = GUICtrlCreateInput("", 170, 407, 345, 56)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")
$progressivo = GUICtrlCreateInput("", 170, 463, 345, 56)
GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif")

$Seriale = GUICtrlCreateLabel("S/N", 16, 24, 130, 40)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$Descrizione = GUICtrlCreateLabel("Descrizione", 16, 144, 130, 40)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$Marca = GUICtrlCreateLabel("Marca", 16, 208, 130, 40)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$Modello = GUICtrlCreateLabel("Modell", 16, 256, 130, 40)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$Matricola = GUICtrlCreateLabel("Matricola", 16, 320, 130, 40)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$Dislocazione = GUICtrlCreateLabel("Dislocazione", 16, 368, 130, 40)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$Tipologia_cespite = GUICtrlCreateLabel("Tip", 16, 424, 130, 40)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$Sede = GUICtrlCreateLabel("Sede", 24, 88, 130, 40)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$NOTE = GUICtrlCreateLabel("NOTE", 16, 480, 130, 40)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")



$UP_tab = GUICtrlCreateButton("UP", 544, 16, 73, 225, 0)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$DOWN_shift_tab = GUICtrlCreateButton("DOWN", 544, 241, 73, 225, 0)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$OK = GUICtrlCreateButton("OK", 544, 466, 73, 73, 0)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")


GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

this GUI is awfull but save me a lot of work.

To start want to map :

- up button with [shift+tab]

- down with [tab]

- ok with [return]

i'e an hard job, please help me to AUTOmatize IT :P

thank you,

m.

Link to comment
Share on other sites

So use the same hot-key function you handle the buttons with this key combination, or on event and check if the active window is yours to process this hot-key or to pass it to the active window.

Another approach as mentioned, you can read about GuiSetAccelerators (the syntax is same as the Send function) and use it without having to deal with the active window issue, preferable in my opinion.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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