
WillKuo
How to capture the popup window information in the Mac desktop by Apple Script?
For my iOS e2e test, sometimes the test is blocked by the Mac pop-up window alert. The possible pop-up as follows:
- Java Access Pop-up
- Accessibility Pop-up
- SystemProperty Pop-up
- and so on…
In order to fetch the unexpected pop-up dialog window when executing e2e tests. I write a simple Apple script get_popup_windows.scpt as follows:
tell application "System Events"
set allProcesses to processes whose background only is false
-- Log the count of allProcesses
log "Number of processes found: " & (count of allProcesses)
set dialogInfos to {}
repeat with eachProcess in allProcesses
try
tell eachProcess
log "Process Name: " & (name of eachProcess as text)
set allWindows to (windows whose subrole is "AXStandardWindow" or subrole is "AXDialog")
log "Number of allWindows found: " & (count of allWindows)
repeat with eachWindow in allWindows
set uiElements to UI elements of eachWindow
log "eachWindow: " & (name of eachWindow as text)
set the end of dialogInfos to {title:(name of eachWindow as text), processName:(name of eachProcess as text)}
end repeat
end tell
end try
end repeat
end tell
return dialogInfos
However, when I execute the script: osascript get_popup_windows.scpt The result as follows:
Number of processes found: 10
Process Name: Terminal
Number of allWindows found: 1
eachWindow: scripts — osascript get_popup_windows.scpt — 143×41
Process Name: Google Chrome
Number of allWindows found: 1
eachWindow: Gemini - Google Chrome - Will
Process Name: sublime_text
Number of allWindows found: 0
Process Name: Notes
Number of allWindows found: 0
Process Name: Music
Number of allWindows found: 0
Process Name: Finder
Number of allWindows found: 0
Process Name: app_mode_loader
Number of allWindows found: 0
Process Name: Simulator
Number of allWindows found: 0
Process Name: app_mode_loader
Number of allWindows found: 0
Process Name: Script Editor
Number of allWindows found: 0
title:scripts — osascript get_popup_windows.scpt — 143×41, processName:Terminal, title:Gemini - Google Chrome - Will, processName:Google Chrome
=> I cannot fetch the target pop-up window in the Mac desktop. Please guide me if you have any suggestions, thanks.
Popular Macos topics

When I purchased this Mac it was fast. However some months on and it is noticeably slower now, and where I notice it most is on starting ...
New

I’m not sure if this is a Big Sur issue or whether I’ve just noticed it, but on looking at my hard drive usage it says I have used 465.0...
New

I have a new MacBook Pro which I’m connecting to an external monitor. I know why it is heating but I want to know if anyone having the sa...
New

Since we’re talking about Mac, which of the filesystems should I use on an external hard drive (non-SSD), which I’ll be using with my Mac...
New

Just wasted hours trying to figure out why my Apple Magic keyboard 2 started lagging after the latest macOS upgrade - tried SMC and PRAM ...
New

I am intending to show an alert message in macOS through a C++ based application. I am using CFUserNotificationDisplayAlert for the same....
New

I’m searching for a tool that can (anonymously) collect crash reports from users of my macOS app (not iOS). Previously I used Fabric whic...
New

Dear forum,
New on macos. Need to create a .pkg file on the command line. The tooling seems to be pkgbuild(1) and productbuild(1). My pr...
New

I am trying to draw NSPanels on texts of other apps using AXObserverAddNotification with the attribute of kAXValueChangedNotification on ...
New

For my iOS e2e test, sometimes the test is blocked by the Mac pop-up window alert. The possible pop-up as follows:
Java Access Pop-up
...
New
Other popular topics

A PragProg Hero’s Journey with Brian P. Hogan @bphogan
Have you ever worried that your only legacy will be in the form of legacy...
New

New

Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face:
Perhaps if there’s enough peop...
New

On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New

A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New

The File System Access API with Origin Private File System.
WebKit supports new API that makes it possible for web apps to create, open,...
New

Author Spotlight:
Tammy Coron
@Paradox927
Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New

I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc.
However, I don’t...
New

Hello,
I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New

This is cool!
DEEPSEEK-V3 ON M4 MAC: BLAZING FAST INFERENCE ON APPLE SILICON
We just witnessed something incredible: the largest open-s...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /ash
- /vscode
- /opensuse
- /centos
- /php
- /deepseek
- /scala
- /html
- /zig
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /react-native
- /sublime-text
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /spring
- /django
- /manjaro
- /diversity
- /lua
- /nodejs
- /julia
- /c
- /slackware
- /neovim