How to copy to clipboard clicking on mouse extra buttons? - binding

I am using xbindkeys and xvkbd for copy and paste by clicking on side buttons on mouse having this config
cat ~/.xbindkeysrc
"xvkbd -text '\Cv'"
b:8 + Release
"xvkbd -text '\Cc'"
b:9 + Release
But that works so bad: sometimes key "Control" remains to be pressed, sometimes instead of Ctrl+c it just pressing key 'c' and breaks my text replacing it with 'c'. I need another method, I hoped xclip, xsel can help, but actually this does not work:
"xclip -o"
b:8 + Release
"xclip -sel clip"
b:9 + Release
so, this does not copy and paste as expected, when I try to paste to browser address bar or to text editor.
Is it possible to bind mouse extra buttons to paste and copy reliably?

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

iOS - Shortcut for jumping to definition in Xcode 9?

In previous Xcode version , I could jump to definition with simple
Cmd + click on that method/variable .
But in Xcode 9, I feel uncomfortable to jump to definition .
Does anyone has a better solution for jumping to definition in Xcode 9 ?
I am tired of selecting options from dropdown list.
Ashish and Ghulam's answers were great but it still kinda bugged me that things had changed and I couldn't jump to definition as before. Then I found this...
Xcode9Beta2-Preferences->Navigation->Command-click on Code:->Jump To Definition:
Solution 1:
Go to Xcode menu
Click on Preferences
Select Navigation Tab from Top
Select Command-click on Code
Change to "Jumps to Definition"
Solution 2:
Use
Ctrl + ⌘ + Left click
There is short cut displayed on drop down menu, just use-
1. Control, Command and left mouse button
OR
2. Command plus Right Mouse Click
instead of command left mouse button.
In Xcode 9 Beta, you can go definition by Cmd + Right Click
Standard hot key for jump to definition is ctrl+cmd+j. Set cursor to the class/method you are interested in and press this buttons to switch to declaration. Also you can try to press ctrl+opt+cmd+j. In this case definition will be opened in assistant editor
If dont like to use mouse click(I certainly don't like) you could use
Command + Ctrl + J
In Xcode 9 both of these work:
⌘ + Right Click
OR
⌘⌃ + Click
When I ⌘-click on a symbol in Xcode 9 I see
That means you have to ⌃⌘-click on the symbol to skip the popup.
Nevertheless there is even a keyboard shortcut:
I don't know how Cmd + Option + Left Click worked for you guys, but the shortcut (at least for me) was Cmd + Ctrl + Left Click.
I've tried on both Apple keyboard and MacBook keyboard and this is the one that did it.
In Xcode 9 Beta, it has been changed to Cmd + Ctrl + Left Click.
Solution to your question: Ctrl + ⌘ + Left click
Xcode >> Preference >> Key Bindings >> Here is list of all short cuts
of Xcode.
Deleting everything under the Derived data and re-opening Xcode fixed everything for me.

How do I change Atom ctrl-tab to not show pane?

In Sublime when cycling through tabs using ctrl-tab it opens and shows the file as I cycle through them. In Atom it shows a pane / list of the recently viewed files. I want to turn this off and just have it cycle through the files and display them as I press ctrl-tab like Sublime. How do I do this?
Go to File > Keymap...
Enter in the following code:
'body':
'ctrl-tab': 'unset!'
'ctrl-tab ^ctrl': 'unset!'
This should disable the pane feature completely.
If you want to cycle through the tabs, you press CTRL+PAGEDOWN for left to right; and CTRL+PAGEUP from right to left.
If you want to change the keybind entirely, as in you want to use CTRL+TAB to cycle through the tabs, you can insert this snippet into the Keymap:
'body':
'ctrl-tab': 'pane:show-next-item'
Move tabs settings (Settings > Packages > Tabs)
and uncheck 'Display MRU Tab Switching List'

XCode 7: code editor in "full screen" mode shortcut

There is a shortcut in XCode to make the code editor (or at least, the current focused window panel) full screen*? In Netbeans, this functionality is achieved with shift+esc: the focused panel expands, hiding other panels.
Thanks in advance.
*Not in the sense of "full screen" Mac OS feature, but the editor panel takes all the visible area, hiding other panels (like the Navigation panel, Property panel, etc).
You can create a new Behavior and assign a shortcut to it. At the top menu, select Xcode > Behaviors > Edit Behaviors...:
In the screenshot, I assigned it a shortcut key of Cmd + Esc but you can choose anything you want.
As far as I know there is not one button to do it all.
You can double click on the file and it will open a new editor window with just the text.
These three combinations will close each of the major three panels:
Command + 0 - Hide/show the Navigator
Shift + Command + Y - Hide/Show the Debug area
Alt + Command + 0 - Hide/Show the Utilities
You can change these in XCode -> Preferences -> Key Bindings

Xcode 4 keyboard shortcut to switch build target destination

Is there a keyboard shortcut in Xcode 4 to switch the build target destination; that is, to switch from simulator to device and vice versa?
There is, is called Destination>select next destination. Go in the prefs in xcode and then in the key bindings tab, search for that, it will show what key it is set at.
For me, is cmd+alt+ctrl+] and [ to switch. Is quite useful, saves a few seconds.
In Xcode 4.6, the shortcut is ctrl+option+cmd+[ and ctrl+option+cmd+]
You can use ctrl + cmd + [ or ctrl + cmd + ] to select scheme, or use ctrl + cmd + [alt] [ or ctrl + cmd + [alt] ] to select product
Or you can just search in the preference panel of key bindings for more information
You can write applescript and bind it to some hotkey (using FastScripts for example - free up to ten bindings).
Next script will click for you on your scheme button in the Xcode toolbar:
tell application "System Events"
tell process "Xcode"
click ((pop up buttons of list 1 of group 2 of tool bar 1 of front window) whose description is "Active Run Destination")
end tell
end tell
then you can just use Up/Down to switch destination.
Note that you need to enable access for assistive devices under the SystemPreferences -> Accessibility
You can go to the edit scheme menu with cmd+< which is actually cmd+shift+.
You should know
Build: cmd+B
Run: cmd+R
Test: cmd+U
Profile: cmd+I
Analyze: shift+cmd+B
But there isn't a command just to switch between the iPhone simulator, iPad simulator, and all of your external.
I have a slightly different problem but it might help you as well.
I have only one physical device which always stays at the top.
Its super simple to select top list device as a target.
Do:
pops up the list for target devices
CTRL + SHIFT + 0
takes you to the first device
CMD + UPARROW
selects that device
SPACE
Apple Script goes:
tell application "Xcode" to activate
tell application "System Events"
tell process "Xcode"
keystroke "0" using {control down, shift down}
delay 0.55
keystroke (ASCII character 29)
delay 0.55
keystroke (ASCII character 30) using command down
delay 0.55
keystroke (ASCII character 32)
delay 0.55
keystroke "r" using command down
end tell
end tell
Riffing on off Comradsky, the answer is then:
Cmd+Shift+, then Tab then Up/Down
You can also option-click on the scheme in the title bar to directly open the settings for the scheme (whereas a normal click opens the context menu that displays a list of all the schemes).
Show Destinations
To bring up the list of destinations use ⤵︎
^ + Shift + 0

Resources