Oppure

Loading
24/07/10 13:00
MagoDelC++
salve ragazzi... il mio problema è questo.. allora io vorrei mettere dei tasti di scelta rapida in un programma per far partire un evento.. esempio con firefox schiacciando control+n apre una nuova finestra.. io vorrei fare una cosa simile se provo a scrivere su google hotkeys o altro mi escono sempre i tasti di xp per la scelta rapida idem per msdn! qualcuno può aiutarmi per favore? :)
aaa
24/07/10 13:29
crash outside control
Ciao, se stai utilizzando dei controlli puoi utilizzare l'operatore "&" che messo davanti a una lettera nella proprietà "Text" di quel controllo fa in modo che alla pressione di quella lettera, corrisponda il click sullo stesso.
Esempio:
Button1.Text = "&Cliccami"
Il testo nel pulsante apparirà così:
Cliccami
Alla pressione della lettera "C" corrisponderà il click su questo pulsante.

Con i menù puoi anche usufruire della proprietà "ShortcutKeys" che ti permette di selezionare una sequenza di tasti di scelta rapida.

Se tutto questo non ti fosse possibile puoi con un timer controllare se una sequenza di tasti viene premuta e richiamare quello che ti pare.
Ultima modifica effettuata da crash outside control 24/07/10 13:31
aaa
24/07/10 16:50
MagoDelC++
ok "ShortcutKeys" mi interessa come lo posso utilizzare?
aaa
24/07/10 17:55
MagoDelC++
ok grazie al tuo aiuto sono riuscito a trovare un sempio funzionante su google... lo posto cosi anche altri possono vederlo:

Import the Interop namespace, since we have to call a Win32 API function to register the Hotkey.

using System.Runtime.InteropServices;

Add these static external methods to your form (or a separate class if you prefer).
[DllImport("user32.dll")]
public static extern bool RegisterHotKey(IntPtr hWnd,
  int id,int fsModifiers,int vlc);
[DllImport("user32.dll")]
public static extern bool UnregisterHotKey(IntPtr hWnd, int id);

Listen for the Hotkey windows message, by examining all windows messages passed to the form. Replace this.Activate() with your desired response to the Hotkey (eg: show the form, if you have a tray application).
protected override void WndProc(ref Message m)
{
   if (m.Msg == 0x0312)
      this.Activate();
   base.WndProc(ref m);
}

Now register your Hotkey. The first argument is the handle to this form (window). The second is, as far as I can make out, a code to identify your Hotkey. The third argument specifies which modifier keys to register (just add up the numbers in the comments depending on your desired combination). The fourth argument is the character code of the alphanumeric key (or even other keys). If you are specifying a letter, it must be uppercase.
// Alt = 1, Ctrl = 2, Shift = 4, Win = 8

FrmStartup.RegisterHotKey(this.Handle, 
  this.GetType().GetHashCode(), 3, (int)'J');



aaa
24/07/10 18:13
crash outside control
Basta aggiungere ad esempio il controllo "MenuStrip" aggiungere una voce e modificare la proprietà "ShortcutKeys" di quest'ultima ...

ok "ShortcutKeys" mi interessa come lo posso utilizzare?

Con i menù puoi anche usufruire della proprietà "ShortcutKeys"


P.S.: La prossima volta usa il tasto "edit" non scrivere due post consecutivi.
aaa