How does Applescript click button "Delete" in Mojave Image Capture?
In ML, this works --
activate application "Image Capture"
tell application "System Events"
click button 3 of group 1 of splitter group 1 of window "Image Capture" of application process "Image Capture" of application "System Events"
end tell
-- and I have not yet got the equivalent for Mojave. Thank you.
They moved things around a little. Try this:
tell application "System Events"
tell process "Image Capture"
set frontmost to true
click window "Image Capture"'s splitter group 1's group 2's button "Delete"
key code 48 -- tab to move focus to 'delete'
-- key code 36 -- return key
end tell
end tell
I added code that clears the "Are you sure?" dialog and automatically deletes the image, but I commented out the 'key code 36' line, which simulates a return key, because I didn't want you to accidentally delete something important.
Debugging GUI scripting
if the above code throws an error, and you don't have UIElementExplorer or UIBrowser (apps that drill down through the GUI), you can debug this running the following code in Script Editor:
tell application "System Events"
tell process "Image Capture"
tell window "Image Capture"
tell splitter group 1
entire contents
end tell
end tell
end tell
end tell
This is slow, and produces a huge mass of text in the script log that shows every element of the GUI from splitter group 1 on down. Search for 'Delete' in the log as I did in the image below: click the log button (circled in green), type command-F and enter the term 'delete' (circled in red), and it will show you the entry for the delete button. Then just copy that path into code.
You may need to change focus (i.e. put the entire contents line after the window "Image Capture" line to get a wider scope).
Note that the GUI may change as you add different devices and browse in different modes, and when the GUI changes all of the indexes (splitter group 1, group 2, button 7) might change as well. You may need to test this with a couple of different configurations if you use multiple devices to see what's going on.
Related
Currently stuck with this. There is a popup menu accessed by right clicking on a track name in the application "Pro Tools". I need to access this menu. After some time I have figured out how to click every other pop up menu on the button apart from one. The first part of the script is to identify the name of the window because it changes depending on the project but I've included it anyway.
Other buttons such as these:
pop up button "Playlist selector"
button "Track Record Enable"
button "TrackInput Monitor"
button "Solo"
button "Mute"
pop up button "Track View selector"
pop up button "Automation Mode selector"
pop up button "Track options"
All work fine.
The only difference is the name of the button.
The button I need is identified in UIElementInspector as
pop up button "Track name
\"Rhythm L\""
I believe the issue is caused by the fact there are " " 's in side of another set. When I run the script it says "expected end of line but found identifier"
activate application "Pro Tools"
tell application "System Events"
# Get the frontmost app's *process* object.
set frontAppProcess to first application process whose frontmost is true
end tell
# Tell the *process* to count its windows and return its front window's name.
tell frontAppProcess
if (count of windows) > 0 then
set window_name to name of front window
end if
end tell
tell application "System Events" to tell process "Pro Tools"
click pop up button "Track name "Rhythm L "" of group "Rhythm L - Audio Track " of window window_name
end tell
Windows 10 SciTE 3.6.6
I have a window with a toolbar that contains a drop down that I am trying to get a value from but I am unable to find the window handle
The menu and item looks like this
I need to wait for a process to finish (but nothing is busy so waiting for a window does not seem to help). I know for sure that the process is finished if this drop down contains a 1, it will be blank while the process is running. I could also check if a sub menu item under Documents is enabled, but I have not been able to find a handle to the menu either.
When I drag the selector from AU3Info over the item outlines the main window and all values in the Control tab are blank
I'm trying to write a small AppleScript which will click the OneNote toolbar Extension, so I can bind it to a keyboard shortcut. The script below works perfectly as long as the instance of Safari is in windowed mode, but in full screen it fails and returns the error:
error "System Events got an error: Can’t get window 1 of process \"Safari\". Invalid index." number -1719 from window 1 of process "Safari"
I have exported this script as an application and granted accessibility access to it. Effectively it seems as though a full screen Safari window is not given an index or is no longer a window and is now a different object.
tell application "System Events"
tell process "Safari"
click button whose description contains "OneNote" of toolbar 1 of window 1
end tell
end tell
MacBook Pro (Retina, 13-inch, Late 2013)
OS X El Capitan, Version: 10.11.6 (15G1004)
try this script. It works whether Safari is in full screen mode or not:
set myButton to "OneNote"
tell application "System Events"
tell process "Safari"
set isfullscreen to value of attribute "AXFullScreen" of window 1
if isfullscreen is true then
click ((buttons of toolbar 1 of group 1 of window 1) whose description contains myButton)
else
click ((buttons of toolbar 1 of window 1) whose description contains myButton)
end if
end tell
end tell
Replace "OneNote" with any button you'd like to click.
I have ASP.net webform that opens a popup window. example window.open(""); The POPUP window closes itself when a hyperlink is clicked inside. [Like search for person by name, select person and pass the person back to the parent form.] Then posts back from the javascript. When it is a full window[not a popup], It does not postback or close the window. When not recording for a test, it opens the modal popup and closes\posts back fine.
The real problem is you cannot finish a test if you cannot close the popup and transfer the selected values back to the parent form.
How do I stop the test recorder from opening the window in full screen. Or how can I make the popup perform normally[close and postback the data] when windowed.
Here is a little info. In the popup I force a postback after closing the window here.
function CancelPopupWindow() {
self.close();
//Here to force a post back on the parent. This is used to automatically save the data
window.opener.__doPostBack('', '');
}
Anyone else hating this problem. Please vote for a fix at User Voice.
https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/16390135-make-web-performance-popup-javascript-dialogs-open
There is a workaround. The program Fiddler can be used to record the entire test then use Fiddler's menu => File => Export sessions => All sessions => Visual Studio web test and then follow the remaining prompts. That will produce a .webtest file. Like any other .webtest file it will probably need work to resolve dynamic data etc.
A variations is to record as much as you can with Visual Studio. From the start of the test up until the problem occurs. If possible you could also record the completion of the test. So just the piece with the problem is omitted. You can also record the problem part with Fiddler and save that. Now you have two or possible three .webtest files that cover the whole test. Now just merge them. With the Visual Studio web test editor you can copy requests and paste them into other tests. (Or else where in the same test. You can also drag requests in a .webtest to reorder them.
The purpose of recording the steps that use JavaScript is to learn enough of what they do so as to replicate enough of their action for the web test. So mixing pieces from different recordings is valid.
The .webtest file contains XML and so can be edited with a text editor. I often make changes in this way, for example to replace many occurrences of the same string with a context parameter. Editing at this text level can help when merging pieces from multiple files. Just be careful to make backups. Visual Studio just gives refuses to load .webtest files with mal-formed XML.
Functionnaly :
On one of my components of my application, I have an editing/lock system. When a user starts editing, he locks the file so other users cannot edit it.
Problem scenario : When the user activates "edition mode" and leaves screen, I would like to show a alert with two options : save changes, or discard changes.
There are different ways to exit screen :
There is a List on the left side containing other possible editabel data. A click changes the data in my component.
There is a menubar on top leading to other screens.
The edition component is embedded in a Tab navigator. When changing tabs, the alert has to show.
Closing browser.
Do I have to catch all of these events and plug at all those places?
Is there any kind of focusout mecanism?
The answer to the first question is: YES.
You need to watch all possible exit events that could harm the currently edited data.
Well, the problem is now how to manage this properly. Using an MVC framework you would trigger the appropriate commands from your components:
CHANGE_LIST_ITEM (new item)
CHANGE_TAB (new tab)
CHANGE_SCREEN (new screen)
Each command then checks if the currently edited tab has been saved or not. If not, it displays the Alert. Else, if there are no changes, it allows the list, the screen chooser and the tab bar to continue.
So your components (list, screens, tabs) need to implement some kind of rollback or preventDefault mechanism. Generally, changing their state must be allowed by a central validator (in MVC the command).
In the case of the list: I would suggest that the list is not selectable by mouse click but only programmatically. You set a listener on the list item click event. If the command allows setting of a new item it will notify the list. In MVC usually by sending an async message that gets received by the list's mediator. [[And even more correct: The command would set some model properties (e.g. currentListItem) and the model than sends an async message.]]
Edit: For the browser close event, you need to call a JavaScript expert.