Any way to paste my mac's IP address?

I'm trying to find a way of "typing" my IP address via touchbar. So far it seems only by copying it to the clipboard I'd be able to do it. In the new preferences window it seems I can chain events like I would do on automator, but alas, I can't find a way of transfering the data from a previous event. Is there any way? Thoughts?

IM assuming you already have your AppleScript able to get your IP and displayed in Touch Bar. Just copy that variable to clipboard. Something like this...

 set the clipboard to (text returned of theIP) 

Then create the action for a button on your Touch Bar to Insert/Type/Paste = (BTT)@clipboard(BTT)

...which could have been better illustrated as a complete working example:

set the clipboard to the IPv4 address of the (system info)

text returned isn’t the right expression anyway. That’s the name of a property belonging to the data object associated with display alert and its siblings. Currently, your line of code throws an error:

error "Can’t get text returned of ${var}." number -1728 from text returned of ${var} 

[ Note: ${var} is a dummy expression inserted at the time of writing. ]

Thanks for the responses, but this is not what I asked. I asked for a way of pasting my IP without the clipboard (I said I knew about it, because I did it.) I want to maintain my clipboard data.

If I overwrite my clipboard, my previous data is lost. Unless Better Touch Tool provides me a way of storing it in a variable somehow or I save it to a file. Given that the clipboard can handle other types of data, I don't want to go there, lest I have to create a massive routine to get an IP address.

So... is there a way to it without the clipboard? Ideas?

That's probably how I'd do it. I can't think of a way that doesn't use the clipboard that would work consistently in any application. Here's how both options might be implemented with AppleScript:

  1. Have AppleScript retrieve your computer's IP address and do the pasting for you. This lets AppleScript store the original clipboard data to a variable without having to write out to a file, and everything gets handled in one script.

    The disadvantage of this is the invocation of System Events to perform the action of pasting by way of programmatically clicking on the "Paste" menu item. This is probably fine for most situations, but wouldn't work if you were in an application that didn't have a visible menu bar, or didn't have a "Paste" menu item.

    set pbdata to the clipboard as record -- Original clipboard data
    
    -- Get your machine's local IP address
    set the clipboard to the IPv4 address of (system info)
    -- Paste it
    tell application "System Events" to tell (menu items of menus of ¬
            menu bar items of menu bar 1 of (the first process where ¬
            frontmost = true) where name = "Paste") to click item 1
    
    set the clipboard to pbdata -- Load previous data back onto clipboard
    
  2. Use your present method to paste the IP address, making sure you get AppleScript to write your clipboard data out to a temporary file beforehand and read it back onto the clipboard afterwards. This is more flexible and lets you do whatever you need to in between, but obviously creates a multi-step workflow that requires calling two individual scripts—one to write out the clipboard data, and one to read it back in:

    ## SCRIPT 1: WRITE CLIPBOARD TO FILE
    property file : "/tmp/pb"
    
    -- This is just a quick and dirty way of
    -- creating a blank file with minimal fuss
    open for access my file
    close access my file
    set eof of my file to 0
    
    -- Write the clipboard data out to file
    write (the clipboard as record) to my file
    
    ## SCRIPT 2: READ FILE TO CLIPBOARD
    property file : "/tmp/pb"
    
    -- Read the clipboard data stored in file
    -- and put it back onto the clipboard
    set the clipboard to (read f as record)
    

You didn't say WITHOUT using clipboard. I read it as "it seems only by copying it to the clipboard I'd be able to do it". Just figured you weren't sure how.

Possibly by writing to a file and reading the contents of the file, but dont know if BTT can output text stored with use of copy/paste.

I found out that AppleScript can simulate typing (apparently):

set ipaddress to IPv4 address of (get system info)
tell application "System Events"
    keystroke ipaddress
end tell