回覆列表
  • 1 # 使用者4535004975032

    "新增窗體Form1,卷標Label1,定時器Timer1,然後新增如下程式碼:Private Declare Function GetForegroundWindow Lib "user32" () As LongPrivate Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPrivate Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As LongDim hWnd1 As LongPrivate Sub Form_Load() Label1.AutoSize = True Timer1.Interval = 500End SubPrivate Sub Timer1_Timer() hWnd1 = GetForegroundWindow() "得到活動視窗的控制代碼 Label1.Caption = getCaption(hWnd1)End Sub"根據視窗控制代碼得到該視窗的標題Function getCaption(hWnd As Long) Dim hWndlength As Long, hWndTitle As String, A As Long hWndlength = GetWindowTextLength(hWnd) hWndTitle = String$(hWndlength, 0) A = GetWindowText(hWnd, hWndTitle, (hWndlength + 1)) getCaption = hWndTitleEnd Function

  • 中秋節和大豐收的關聯?
  • python text中按字典序排列最小的子序列?