SendKeys "{HOME}" และ SendKeys "{END}" บนฟิลด์ Text

เริ่มโดย nonc31, 04 ม.ค 23 , 15:18:30

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

nonc31

เหมือนจะง่าย  แต่กว่าจะเข้าใจ  นำมาฝากครับ  วินโดว์ 7 ขึ้นมา ใช้ SendKeys "{HOME}" และ  SendKeys "{END}" ไม่ได้แล้ว

Option Compare Database

#If Win64 Or VBA7 Then
    Private Declare PtrSafe Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Private Declare PtrSafe Function GetKeyState Lib "user32.dll" (ByVal nVirtKey As Long) As Integer
#Else
    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Private Declare Function GetKeyState Lib "user32.dll" (ByVal nVirtKey As Long) As Integer
#End If

    Private Const VK_HOME = &H24
    Private Const VK_END = &H23
    Private Const VK_F2 = &H71
   
Private Sub Command2_Click() 'SendKeys HOME
    Me.Text0.SetFocus
    keybd_event VK_F2, 1, 0, 0
    keybd_event VK_F2, 1, KEYEVENTF_KEYUP, 0
    keybd_event VK_HOME, 1, 0, 0
    keybd_event VK_HOME, 1, KEYEVENTF_KEYUP, 0
End Sub

Private Sub Command3_Click() 'SendKeys END ใช้ F2 แทน
    Me.Text0.SetFocus
    keybd_event VK_F2, 1, 0, 0
    keybd_event VK_F2, 1, KEYEVENTF_KEYUP, 0
End Sub
  •  
    โพสต์นี้ได้รับคำขอบคุณจาก: UnKnown, Un