Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/19/2022 in all areas

  1. Here's a version that even works if the AutoIt window is not involved. #include <GuiMenu.au3> #include <SendMessage.au3> #include <WinAPIGdi.au3> #include <WinAPIMisc.au3> #include <WinAPIProc.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> Local $hEventProc = DllCallbackRegister('_EventProc', 'none', 'ptr;dword;hwnd;long;long;dword;dword') Global $g_tRECT, $g_iIndex, $g_hMenu = 0 OnAutoItExitRegister('OnAutoItExit') Local $hEventHook = _WinAPI_SetWinEventHook($EVENT_SYSTEM_FOREGROUND, $EVENT_SYSTEM_FOREGROUND, DllCallbackGetPtr($hEventProc)) Run(@SystemDir & '\notepad.exe') While 1 Sleep(1000) WEnd Func OnAutoItExit() _WinAPI_UnhookWinEvent($hEventHook) DllCallbackFree($hEventProc) EndFunc ;==>OnAutoItExit Func _EventProc($hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadId, $iEventTime) #forceref $hEventHook, $iObjectID, $iChildID, $iThreadId, $iEventTime Switch $iEvent Case $EVENT_SYSTEM_FOREGROUND ConsoleWrite(TimerInit() & @CRLF) Local $hWnd_Active = WinGetHandle("[ACTIVE]", "") ConsoleWrite($hWnd_Active & @TAB & WinGetTitle($hWnd_Active) & @CRLF) EndSwitch EndFunc ;==>_EventProc
    1 point
  2. How about this? #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> Example() Func Example() Local $hGUI = GUICreate("Testing WM_ACTIVATEAPP", 400, 60, -1, -1, $WS_OVERLAPPEDWINDOW) Local $idButton_1 = GUICtrlCreateButton("Button 1", 100, 15, 80, 25) Local $idButton_Close = GUICtrlCreateButton("Close", 215, 15, 80, 25) ConsoleWrite("$hGUI = " & $hGUI & @CRLF & @CRLF) GUIRegisterMsg($WM_ACTIVATEAPP, "WM_ACTIVATEAPP") GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton_Close ExitLoop Case $idButton_1 MsgBox($MB_TOPMOST, "Title", "Button_1 pressed") EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example ;================================================= Func WM_ACTIVATEAPP($hWnd, $iMsg, $wParam, $lParam) Local Static $iCount $iCount += 1 ConsoleWrite($iCount & " WM_ACTIVATEAPP : $hWnd = " & $hWnd & " $wParam = " & $wParam & " $lParam = " & $lParam & @CRLF) Local $hWnd_Active = WinGetHandle("[ACTIVE]", "") ConsoleWrite($hWnd_Active & @TAB & WinGetTitle($hWnd_Active) & @CRLF) Return $GUI_RUNDEFMSG EndFunc ;==>WM_ACTIVATEAPP
    1 point
  3. I’m on vacation but will have a look when I’m back.
    1 point
  4. @hahnhwang https://www.autoitscript.com/wiki/WebDriver#FAQ #7 You don't need an array in this case. However, Local $sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="mat-tab-label-0-0"]/div/span/app-number-viewerapp', 100, 5000) Local $sText = _WD_ElementAction($sSession, $sElement, 'property', 'innerText') MsgBox(0, "Total", $sText)
    1 point
×
×
  • Create New...