[SOLVED] Stop/resume Google Drive sync

Using UI browser I got this, but I'm not sure which "application" I need to target?
I see some scripts using "System Events", but I don't know what that is and don't know if that would be what I would need to use in an AppleScript. Or would I just use "Google Drive" as seen in the first image below?

When I hover over the menu bar icon:
SCR-20240208-oivy

When I click the icon and hover over the cog wheel:
SCR-20240208-oizh

When I hover over the "pause syncing" option:

UPDATE: with some "courage" to test and fail, I almost got it :slight_smile:

This is what I got so far and it clicks the first 2 buttons, but when it gets to the actual option to pause/resume, it doesn't work. At this point I could just use the keystroke 3x to go to the option and another for Enter, but if I could do it all with AS, even better.

tell application "System Events"
	tell process "Google Drive"
		click menu bar item 1 of menu bar 1
		click pop up button 1 of group 1 of group 1 of group 1 of group 3 of UI element 1 of window 1
		click group 1 of group 1 of group 1 of group 1 of group 4 of group 1 of UI element 1 of window 1
	end tell
end tell

UPDATE 2:
In case I need to rely on keystrokes, I did some research and learned how to do that inside AS, along with "repeat" and I got this below (I know this is super basic for most of you, but to me it's a great accomplishment, knowing how to do these little things, so I'm just celebrating :champagne:)

tell application "System Events"
	tell process "Google Drive"
		click menu bar item 1 of menu bar 1
		delay 1
		click pop up button 1 of group 1 of group 1 of group 1 of group 3 of UI element 1 of window 1
		delay 1
		--- click group 1 of group 1 of group 1 of group 1 of group 4 of group 1 of UI element 1
	end tell
	
	repeat 3 times
		tell application "System Events" to key code 125
		delay 1
	end repeat
	
	tell application "System Events" to key code 36
	
end tell

I will adjust the delays, but I wanted to make sure that this was working.
Is there a way to add the "pause until" version of KM into AS itself? That would replace the delay.

FINAL UPDATE: I got it!
For some reason I got the wrong information from UI Browser. I probably hovered over the wrong element.

The final script:

tell application "System Events"
	tell process "Google Drive"
		click menu bar item 1 of menu bar 1
		delay 0.5
		click pop up button 1 of group 1 of group 1 of group 1 of group 3 of UI element 1 of window 1
		delay 0.5
		click menu item 4 of menu 1 of group 1 of group 2 of group 1 of group 3 of group 1 of UI element 1 of window 1
	end tell
	
end tell

So my final question is: instead of delay is it possible to use some kind of pause until so it can wait until the next element is available?