import "@johnlindquist/kit"
applescript(`
tell application "System Events" to tell process "GlobalProtect"
set connectionStatus to get help of every menu bar item of menu bar 2
if item 1 of connectionStatus = "Not Connected" then
click menu bar item 1 of menu bar 2 -- Activates the GlobalProtect "window" in the menubar
try
click button "Connect" of window 1
end try
click menu bar item 1 of menu bar 2 -- This will close the GlobalProtect "window" after clicking Connect/Disconnect. This is optional.
end if
end tell
`);