Create hyperlink in DIalogue Box using Applescript ? - hyperlink

display dialog "Sample
i . Go to Google [http://wwww.google.com']
. .. … ….. …….. …………. ……..…………." buttons {"Proceed"} default button 1
How to create an actual working hyperlink inside of a dialogue box using Applescript ?

Related

Applescript print by selecting preset and format

I am trying to define the print parameters as presets with AppleScript.
I managed to open the pdf file with acrobat, open the print panel and define the number of copies, but then I was unable to "click" on the "Stampante..." (image 1) and subsequent (image 2) buttons. I do not find what are the commands to act on the window. Do you have any suggestions
#apro file con acrobat
#definire posizione la prima volta del programma
tell application "Adobe Acrobat Reader DC"
activate application
#apro file creare percorso per file su temp
open file "giungete:users:corrado:desktop:201.188_001.pdf"
#uso pulsanti per eseguire comando
tell application "System Events"
tell window "201.188_001.pdf"
#apro stampa
keystroke "p" using command down
delay 1
#vado copie
keystroke tab
delay 0.1
keystroke tab
delay 0.1
keystroke tab
delay 0.1
#definisco copie
keystroke "120"
delay 0.1
keystroke tab
delay 0.1
#do invio
#keystroke return
end tell
end tell
end tell
image 1
image 2
The example AppleScript code, shown below, was tested in Script Editor under macOS Monterey with Language & Region settings in System Preferences set to Italiano — principale and Inglese (US) and worked for me without issue1.
1 Assumes necessary and appropriate settings in System Preferences > Security & Privacy > Privacy have been set/addressed as needed.
Assuming you are Italian, and with no disrespect intended, I am not sure how well you will understand my answer or why I coded the example AppleScript code in the manner I have, however, I will try to explain some of it.
If you have a document opened in Adobe Acrobat Reader DC and you bring up the Print dialog box, it is a modal window and as such can simply be addressed as window 1 and no need to necessarily use window "Print" in general. The same goes for e.g. window "201.188_001.pdf", it can simply be addressed as window 1, but to just print an opened document the document window does not need to be relevant in my example AppleScript code because of how it is coded.
As there are multiple pop up button being clicked on the second |Print| window I wrapped the code in a handler so they can be clicked by number or name and number or name of the menu item. Keep in mind that by number the menu separators count as an incremented number.
I am using a choose file command to select the target PDF document to open and print in Adobe Acrobat Reader DC. You can of course choose not to use it and just set the print thisFile command to e.g.: print file "giungete:users:corrado:desktop:201.188_001.pdf"
I have added comments through the example AppleScript code to help explain what is happening.
Example AppleScript code:
property |Copies| : "120"
property |Print| : "Stampa"
property |Show Details| : "Mostra dettagli"
set thisFile to ¬
choose file of type "com.adobe.pdf" with prompt ¬
"Choose a PDF document:" default location ¬
(path to documents folder) without invisibles
tell application id "com.adobe.Reader"
activate
ignoring application responses
print thisFile
end ignoring
end tell
tell application id "com.apple.systemevents"
tell window 1 of application process "AdobeReader"
-- ## First |Print| window. ##
repeat until its name is |Print|
delay 0.01
end repeat
-- # Set the number of copies to print.
set value of first text field of group 1 to |Copies|
-- # Clicking the |Printer...| button causes a
-- # ~5 second delay, therefore tab to it instead.
-- # Tested in macOS Monterey and it took 18 tabs
-- # from the default opening of the |Print| window,
-- # however, it needs to be checked manually in
-- # other versions of macOS first.
repeat 18 times
key code 48 -- # tab key
delay 0.01
end repeat
key code 36 -- # enter key
-- # Wait a moment for the second |Print| window.
delay 1
-- ## Second |Print| window. ##
-- # Make sure second |Print| window is expanded.
if (the name of its button 2) is |Show Details| then
click button 2
delay 1
end if
-- # Click and select on Preset:
my clickPopUpButtonMenuItem(2, 1)
delay 0.25
-- # Click and select on Layout:
my clickPopUpButtonMenuItem(3, 1)
delay 0.25
-- # Click the Print button on the second |Print| window.
click button 4
delay 0.25
-- ## First |Print| window. ##
-- # Click the Print button on the first |Print| window.
-- # Leave commented until testing is finished.
--click button 4
end tell
end tell
-- # Handler #
on clickPopUpButtonMenuItem(PopUpButton, MenuItem)
-- # PopUpButton - Can be either an integer or the name.
-- # MenuItem - Can be either an integer or the name.
-- # MenuItem - Menu separators count as an incremented number.
tell application id "com.apple.systemevents"
tell window 1 of application process "AdobeReader"
click pop up button PopUpButton
click menu item MenuItem of menu 1 of pop up button PopUpButton
end tell
end tell
end clickPopUpButtonMenuItem
Notes:
As previously mentioned I chose not to click the Printer... (Stampante...) button because of the ~5 second delay if clicked. I believe the delay is caused because the second |Print| window opens and it has to time out because the button clicked it is from the first |Print| window which is now actually window 2, not window 1, and this is why tabbing makes more sense to avoid the delay.
I also tested the example AppleScript code in macOS Catalina and it was 17 tab stops to the Printer... (Stampante...) button, not 18 like in macOS Monterey.
Keep in mind that the number of tabs will be different if you change any of the other setting in the first |Print| window and it was based on your "image 1" link in that the only default you changed was the number of copies. You can always choose to click the Printer... (Stampante...) button instead and wait the ~5 second delay. It would be click button 2 instead of the repeat loop.
UI Scripting is kludgy and prone to failure and can break easily from one version of macOS to another as Apple and developers continually changes things, e.g. the hierarchical UI element structure. Case in point, 17 tabs in macOS Catalina vs. 18 tabs in macOS Monterey in this particular use case, the first |Print| window in Adobe Acrobat Reader DC.
Add-on to address request in comment
Even though the question originally focused on Adobe Acrobat Reader DC, nonetheless, as the author of the OP asked in comments about doing it in Preview, here is some example AppleScript code for use in macOS Monterey and Preview.
I thought it would be an interesting contrast to the different hierarchical UI element structure of the Print dialog box between the two applications to under the same version of macOS and how fragile UI Scripting can be preforming the same basic task between two different applications. While this would work with Preview in macOS Big Sur and macOS Monterey, it will not in macOS Catalina as the hierarchical UI element structure for the Print dialog box differs slightly, as there is no splitter group 1 of sheet 1 of window 1.
Example AppleScript code:
-- # Example AppleScript code for use in macOS Monterey and Preview.
property |Copies| : "120"
property |Print| : "Stampa"
property |Show Details| : "Mostra dettagli"
set thisFile to ¬
choose file of type "com.adobe.pdf" with prompt ¬
"Choose a PDF document:" default location ¬
(path to documents folder) without invisibles
tell application id "com.apple.Preview"
activate
open thisFile
end tell
tell application id "com.apple.systemevents"
-- launch -- # Used in an attemp to workaround a bug.
-- # Used to see the full large print dialog if Preview opens
-- # the document too tight on the left side of the screen.
tell window 1 of application process "Preview"
set currentPosition to its position
if item 1 of currentPosition is less than 70 then ¬
set its position to {70, item 2 of currentPosition}
end tell
-- # Bring up the Print dialog box.
keystroke "p" using command down
-- # Wait until the Print dialog box is ready.
repeat until exists button 1 of ¬
splitter group 1 of sheet 1 of window 1 of ¬
application process "Preview"
end repeat
tell splitter group 1 of sheet 1 of window 1 of application process "Preview"
-- # Show Details if necessary. (Mostra dettagli)
if exists button |Show Details| then
click button |Show Details|
delay 1
end if
-- # Printer: pop up button. (Stampante:)
click pop up button 1
click menu item 1 of menu 1 of pop up button 1
-- # Preset: pop up button.
click pop up button 2
click menu item 1 of menu 1 of pop up button 2
-- # Copies: text field. (Copie:)
set value of text field 1 to |Copies|
-- # Paper Size: pop up button. (Dimensioni pagina:)
click pop up button 3
click menu item 5 of menu 1 of pop up button 3
click menu item 2 of menu 1 of menu item 5 of menu 1 of pop up button 3
-- # Preview pop up button (By default.) (Anteprima)
click pop up button 4
click menu item 1 of menu 1 of pop up button 4
delay 1
-- # The following will vary based on menu selection of pop up button 4.
tell group 3
click pop up button 1
click menu item 1 of menu 1 of pop up button 1
-- click pop up button 2
-- click menu item 1 of menu 1 of pop up button 2
-- click pop up button 3
-- click menu item 1 of menu 1 of pop up button 3
end tell
-- # Print button. (Stampa)
-- click button 4 -- # Or click by name.
click button |Print|
end tell
end tell
Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.
Thanks for the answers. I followed your advice I am clear to me the command to use the problem is what the window opens is called!
Example link
if not (exists (1st window whose value of attribute "AXIdentifier" is "MessagesPreferencesWindow")) then
Then Identifies the window and now with a new version of messages the menus changed but work
this works !!! link
I always get and only
System Events ha trovato un errore: Impossibile ottenere window "201.188_001.pdf – 1 pagina" of window "201.188_001.pdf".
I downloaded ui browser and found the correct path but I always get error
thanks corrado

How to add fields to a Dialog

Iam new in BlackBerry programming. I want to make a Dialog with 2 inputtext, 2 labels and OK and Cancel button something like this:
|PIN|:|inputtext|
|Bumber|:|inputtext|
|Button(OK)||Button(Cancell)|
Your requirement is nothing but "Custom Popup"
For this the below link will help you:
CustomPopupScreen#WordPress
or
CustomPopupScreen#BlogSpot
Check this and change according to your requirement.

PhoneGap-iOS, how to show dialog with red button?

I am working with Phonegap on iOS, and here is the codes to show the dialog:
navigator.notification.confirm(
'Which color do you like most?'
, confirmCB
, 'Title | Confirm'
, 'Green,Red'
);
I want to show a confirmation dialog with red cancel button but I don't know how. Please helps.
That is not possible with phonegap.
navigator.notification.confirm uses the native UIAlertView, and the UIAlertView buttons are blue/gray, and the cancel button darker blue/gray
You can try to create a plugin with this library BlockAlerts And ActionSheets
Or use a javascript/css alert replacements

How to add a simple button actionscript

I am using Adobe Flash CS4. I don't know why I do the sample actionscript code here.
on (release) {
gotoAndPlay(1);
}
And now I'm dealing with a button function. I already created a box then press "F8" and choose button. Now I click on the button box, and press "F9" for the actionscript.
It said that "Current selection cannot have actions applied to it"
Then choose "ActionScript 1.0 & 2.0"
Global Function > Movie Clip Control > On
** but "On" is disabled, how to solve this problem of mine to put this simple code.
Thank you.
Have you changed your publish settings? Open: File -> Publish Settings, the in the Flash tab change Script to ActionScript 2.0

Rad Upload control | Add tooltip on browse button

I want to add tooltip to my Rad upload control browse button. Anyone knows about it or have worked on this before please reply
See this Telerik example:
http://www.telerik.com/help/aspnet-ajax/localization-upload-client-side.html
For the select/browse button just include a title value for the input button
input.title = "This is the add more files button";

Resources