Invite to share screen (iMessage) - Automation - How? How can i automate an "Invite to share screen" from iMessages. 

I share screens a lot with my colleagues and it would just make sense to have an option to quick ask someone to view my screen. Yet now, i have to look the user up in the imessage window and "target practice" the small icon, then Invite ..

Would be easier if i could automate it, or somehow create a desktop shortcut.
You asked for an automative method to do this from within the Messages app, which this AppleScript can achieve.  You can place it in a Run AppleScript action.

use application "System Events"

property process : a reference to process "Messages"
property menu bar : a reference to menu bar 1 of my process
property menu bar item : a reference to menu bar item "Buddies" of my menu bar
property menu : a reference to menu 1 of my menu bar item

activate application "Messages"

set _M to a reference to (menu item "Invite to Share My Screen" in my menu)
tell _M to if not ((exists) and its enabled) then return false

click _M


However, it seems to me that, however this script is triggered, whether via an Automator service, Keyboard Maestro, the Scripts menu, or whatever; it will either require at least a couple of mouse clicks (e.g. to active a service from the context menu), or a keypress.

Therefore, in my mind, the easiest way to achieve the same outcome would be to set a keyboard shortcut for the appropriate menu item in Messages:


Keyboard Shortcuts in macOS High Sierra: System Preferences > Keyboard > Shortcuts > App Shorcuts

This screenshot is from High Sierra, so if you're running Mojave, it may be a little different.  The important things are to check the name of the relevant menu item in Messages in case it varies from High Sierra or you use a different language on your system; and to ensure that the entry you type for your App Shortcut is identical, including capitals and non-capitals used: so "Invite to Share My Screen" is not the same as "Invite To Share My Screen" and only the first one would work.




ADDENDUM: (added 12 hours after original answer)
@user3439894 kindly reminded me that my style of scripting can sometimes appear a little obtuse and more difficult to follow and understand to novice scripters.  Therefore, I am posting a version of the above code that this user recommended.  Functionally, it does exactly the same as the original (apart from activating Messages, which doesn't need to be done if the application is already active and being used).  This version utilises less ambiguous syntax and more of AppleScript's (in)famous natural-language flavour:


try
    tell application "System Events" to click ¬
        menu item "Invite to Share My Screen" of ¬
        menu 1 of menu bar item "Buddies" of ¬
        menu bar 1 of process "Messages"
end try