PDA

View Full Version : آموزش ساخت کلیدهای میانبر با 2 کاراکتر معمولی کیبورد



ROSTAM2
شنبه 15 مهر 1402, 08:23 صبح
سلام به همه
در این آموزش با استفاده از یک آرایه که 2 عنصر داره کلیدها گرفته می شه و رویداد مورد نظر بعد از گرفتن 2 کاراکتر از کلیدهای کیبورد اجرا می شه ...

ایده جالبی بود که من دستورش رو نوشتم:

برای تماشای ویدئو آموزشی لینک رو کلیک کنید ....

https://aparat.com/v/PIQYt

154996 (https://aparat.com/v/PIQYt)


Dim ShortcutKey(1) As Windows.Forms.Keys
Event CustomShortcutKeyPressed(firstKey As Keys, secondKey As Keys)

Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If (Not ShortcutKey(0) = Nothing) Then
If ShortcutKey(1) = Nothing Then
ShortcutKey(1) = e.KeyCode
End If
End If
If ShortcutKey(0) = Nothing Then
ShortcutKey(0) = e.KeyCode
End If
End Sub


Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
ShortcutKey(0) = Nothing
ShortcutKey(1) = Nothing
End Sub


Private Sub Form1_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp
If (Not ShortcutKey(0) = Nothing) AndAlso (Not ShortcutKey(1) = Nothing) Then
RaiseEvent CustomShortcutKeyPressed(ShortcutKey(0), ShortcutKey(1))
ShortcutKey(0) = Nothing
ShortcutKey(1) = Nothing
End If
End Sub


Private Sub Form1_CustomShortcutKeyPressed(firstKey As Keys, secondKey As Keys) Handles Me.CustomShortcutKeyPressed
Debug.Print(" >> {0}{1}", Chr(firstKey), Chr(secondKey))
Select Case (Chr(firstKey) + Chr(secondKey)).ToUpper
Case "9M"
Dim FRM As New Form
FRM.ShowDialog(Me)
End Select
End Sub