 
  		        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
 
          
                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
 
          
                I have JAR application ready. i have apple account also. Please give me steps to signed app upload 
i try But getting error as below : 
A...
              
            
            
          
              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
                         
                      
                       
          
                Reading something? Working on something? Planning something? Changing jobs even!? 
If you’re up for sharing, please let us know what you’...
              
            
            
          
              New
 
          
                I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
              
            
            
          
              New
 
          
                Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
              
            
            
          
              New
 
          
                Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: 
https://on...
              
            
            
          
              New
 
          
                This looks like a stunning keycap set :orange_heart: 
A LEGENDARY KEYBOARD LIVES ON
When you bought an Apple Macintosh computer in the e...
              
            
            
          
              New
 
          
                Author Spotlight 
Dmitry Zinoviev 
@aqsaqal 
Today we’re putting our spotlight on Dmitry Zinoviev, author of Data Science Essentials in ...
              
            
            
          
              New
 
          
                Author Spotlight 
Rebecca Skinner 
@RebeccaSkinner 
Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
              
            
            
          
              New
 
          
                Author Spotlight: 
Peter Ullrich 
@PJUllrich 
Data is at the core of every business, but it is useless if nobody can access and analyze ...
              
            
            
          
              New
 
          
                Curious what kind of results others are getting, I think actually prefer the 7B model to the 32B model, not only is it faster but the qua...
              
            
            
          
              New
 
          
                Background
Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
              
            
            
          
              New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /ruby
- /wasm
- /erlang
- /phoenix
- /keyboards
- /python
- /rails
- /js
- /security
- /go
- /swift
- /vim
- /clojure
- /haskell
- /emacs
- /java
- /svelte
- /onivim
- /typescript
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /elm
- /flutter
- /vscode
- /ash
- /opensuse
- /html
- /centos
- /php
- /zig
- /deepseek
- /scala
- /sublime-text
- /lisp
- /textmate
- /react-native
- /nixos
- /debian
- /agda
- /kubuntu
- /arch-linux
- /django
- /revery
- /deno
- /ubuntu
- /nodejs
- /spring
- /manjaro
- /diversity
- /lua
- /julia
- /slackware
- /c




 
    




