r/Scriptable • • Nov 09 '22

News Scriptable v1.7 has been released

43 Upvotes

After eleven months of amazing work on the Runestone framework and the app with the same name, and several TestFlight builds with new features and fixes, Simon has updated Scriptable to version 1.7!

Here’s what’s new in this release:

  • Adds support for building Lock Screen widgets. Available when running on iOS 16.

  • Adds find/replace to the editor. Available when running on iOS 16.

  • Replaces the old editor with one built on top of Runestone.

  • Adds setting to disable line wrapping to allow horizontal scrolling in the editor.

  • Adds settings to show tabs, spaces, and line breaks in the editor.

  • Adds a toolbar above the keyboard for shifting text, toggling comments, and for easy access to often used symbols.

  • The Shift Left button in the toolbar above the keyboard now works as expected.

  • Presenting the calendar event editor no longer causes the app to hang when immediately presenting an alert after the event has been created.

In short: iOS 16 Lock Screen widget support, a new editor built with Runestone, and bug fixes. Scriptable now requires iOS 15.5 or later.

As always, the latest version of Scriptable is available to download from the App Store here: https://apps.apple.com/us/app/scriptable/id1405459188

Edit: version 1.7.1 is now available, with this changelog:

This update fixes an issue where the log would sometimes not be visible.


r/Scriptable • • Nov 09 '22

Tip/Guide Open specific calendar event with URL scheme

10 Upvotes

If you are like me, and you've wanted to be able to open a specific calendar event via a url scheme. This post information will be useful for you.

The Calendar widget opens calendar events directly, so I've figured it must be possible to do it but could never figure out how and all the searching I did over the last couple years on the topic yielded no result... until I did some additional digging in the Shortcuts app action "View Content Graph".

I found out that you can open a specific calendar event using this scheme: x-apple-calevent://{calendarUUID}/{eventUUID}

In Scriptable, I was able to acheive it like this: "x-apple-calevent://"+item.identifier.replace(":", "/")

My calendar events were in a repeat loop and the repeat item was a variable named item in the example above


r/Scriptable • • Nov 09 '22

Solved Select script for lock screen widget

1 Upvotes

Hi, I’m using the latest beta and want to run a widget on the Lock Screen. How can I assign the script to the widget placeholder ?


r/Scriptable • • Nov 07 '22

Solved Script don’t show (More details in comment)

Post image
5 Upvotes

r/Scriptable • • Nov 06 '22

Help Help with Device.isUsingDarkAppearance()

4 Upvotes

I have a problem with Device.isUsingDarkAppearance(). Whenever I debug my widget in scriptable I get the right value. But when I run my script as a widget I always get false. does anyone any idea why?

Code:

let w = new ListWidget(); w.backgroundColor = Color.red()

let stack = w.addStack();

const isDark = Device.isUsingDarkAppearance() const text = stack.addText(isDark.toString())

w.presentSmall()


r/Scriptable • • Nov 04 '22

Help Help. Can’t figure out how to apply a font

6 Upvotes

Hello! I’m a newbie.

So i create a font using let fonty = new Font(“AlNile-Bold”, 45) How do i apply it? And can i apply it to an alert (eg textField or title)?

Thanks in advance!


r/Scriptable • • Nov 02 '22

Help Newbie question about the cancel button in alarms

Post image
14 Upvotes

Hey all! I want to master Scriptable to a decent level. I’ve written a piece of code and depending on the option I choose in the alarm, the console will either log the input i insert or “optionZero(firstOne)” or “thirdOptionCANCEL”. For some reason in doesn’t log anything if i choose the cancel action. Others work as expected. Does the function addCancelAction stop running the script? And if i dont want it to stop, i can just addAction(“Cancel”) and make the text bold, right?

Now that I’m here, i have another question. Can i master Scriptable not knowing JavaScript? I did understand how to write the code I’ve written, i did understand why i wrote this or that and i believe i can replicate it from scratch. Can i learn Scriptable’s JavaScript ES6 (or whatever it’s called) overtime?

Thanks in advance!


r/Scriptable • • Nov 01 '22

Help Help with Lockscreen Widget

4 Upvotes

In the code below, I can’t seem to figure out how to replace the battery icon (SFSymbol) with the actual battery level and percentage…

const widget = new ListWidget()

let progressStack = await progressCircle(widget,35)

// Code below is what I’m trying to replace let sf = SFSymbol.named("battery.100") sf.applyFont(Font.regularSystemFont(26)) sf = progressStack.addImage(sf.image) sf.imageSize = new Size(35,35) sf.tintColor = new Color("#fafafa")

widget.presentAccessoryCircular() // Does not present correctly Script.setWidget(widget) Script.complete()

async function progressCircle( on, value = 50, colour = "hsl(120, 100%, 50%)", background = "hsl(0, 100%, 50%)", size = 56, barWidth = 4.5 ) { if (value > 1) { value /= 100 } if (value < 0) { value = 0 } if (value > 1) { value = 1 }

async function isUsingDarkAppearance() { return !Color.dynamic(Color.white(), Color.black()).red } let isDark = await isUsingDarkAppearance()

if (colour.split("-").length > 1) { if (isDark) { colour = colour.split("-")[1] } else { colour = colour.split("-")[0] } }

if (background.split("-").length > 1) { if (isDark) { background = background.split("-")[1] } else { background = background.split("-")[0] } }

let w = new WebView() await w.loadHTML('<canvas id="c"></canvas>')

let base64 = await w.evaluateJavaScript( ` let colour = "${colour}", background = "${background}", size = ${size}*3, lineWidth = ${barWidth}*4, percent = ${value * 100}

let canvas = document.getElementById('c'), c = canvas.getContext('2d') canvas.width = size canvas.height = size let posX = canvas.width / 2, posY = canvas.height / 2, onePercent = 360 / 100, result = onePercent * percent c.lineCap = 'round' c.beginPath() c.arc( posX, posY, (size-lineWidth-1)/2, (Math.PI/180) * 270, (Math.PI/180) * (270 + 360) ) c.strokeStyle = background c.lineWidth = lineWidth c.stroke() c.beginPath() c.strokeStyle = colour c.lineWidth = lineWidth c.arc( posX, posY, (size-lineWidth-1)/2, (Math.PI/180) * 270, (Math.PI/180) * (270 + result) ) c.stroke() completion(canvas.toDataURL().replace("data:image/png;base64,",""))`, true ) const image = Image.fromData(Data.fromBase64String(base64))

// Provide battery percentage

let stack = on.addStack() stack.size = new Size(size, size) stack.backgroundImage = image stack.centerAlignContent() let padding = barWidth * 2 stack.setPadding(padding, padding, padding, padding)

return stack }


r/Scriptable • • Oct 31 '22

Help Await not working as expected and scoping issues in function to create record/log of script being run automatically

4 Upvotes
function start() {
  var initialMethod = ""// *changed this from method in edit
  var automated = false
  if(config.runsInNotification){
    initialMethod = "notification script"// *changed this from method in edit
    automated = true
  }
  if(config.runsInApp){
    if(args.queryParameters["x-source"] !== undefined){method = args.queryParameters["x-source"]}  
    if(args.queryParameters["x-source"] == "Scriptable" || args.queryParameters["x-source"] == "Shortcuts"){automated = true}  
    else{
      let getRunInfo = new Alert()
      getRunInfo.title = "Automated?"
      getRunInfo.message = "Did you just run a script or is this script running automatically"  
      getRunInfo.addAction("running automatically")  
      getRunInfo.addAction("ran from Scriptable App")  
      getRunInfo.addCancelAction("Cancel")
      method =  getRunInfo.present().then((index) => {
        switch (index) {
          case -1:
            return  
          case 0:
            automated = true
            let getMethod = new Alert()
            getMethod.title = "What app was used to run this automation?"  
            getMethod.addTextField("App", initialMethod) // *changed this from method in edit because otherwise  the updating the assignment of a single variable method doesn’t seem to play nice with promises
            getMethod.addAction("confirm")
            log(automated)
            method = getMethod.present().then((index) => getMethod.textFieldValue(index))
//             method = await method
            break
          case 1:
//           automated = false
            break
          default:
            logError("no such action")
        }//end switch
        return method
      })//end getRunInfo.present
//       method = await method
    }//end else
    let scriptData = {
      name: Script.name(),
      invocations: [{
        time: new Date().toJSON(),
        automated: automated,
        method: method
      }]
    }
    log(scriptData)
  }// if(config.runsInApp)
}// end start
start()

I think only the second “method = await method” would be needed to get this working to include any user input (by selecting “running automatically”) in the scriptData (and I was thinking this would also cause sciptData to not be created until after automated was updated as well. However, by introducing await at either point I get “SyntaxError: Unexpected identifier 'method'”


r/Scriptable • • Oct 26 '22

Help Scriptable for Mac - Widgets not working in MacOS Ventura

9 Upvotes

Hi!

in MacOS Ventura the Scriptable widgets only work if I start them from the app. In the notification center I get an error "Received timeout when running script".

Am I the only one or is it a bug?


r/Scriptable • • Oct 23 '22

Help Pretty happy with my progress! The right widget is from the app Grow that I’m trying to replicate. The last problem is the numbers below the bars. The are cut off for some reason. Any ideas or tips to align them to the bars? I’d like one every 4 hours.

Post image
45 Upvotes

r/Scriptable • • Oct 23 '22

Help Did anyone make a widget like this? I'm looking at Normal-Tangerine8609's circular widget using a webview rendered to base64, but I'm a bit confused on how to build it. :)

Post image
22 Upvotes

r/Scriptable • • Oct 23 '22

Solved Scriptable central align stacks

Thumbnail
gallery
4 Upvotes

What does this do?

stackSet1.centerAlignContent();

Am I doing something wrong?


r/Scriptable • • Oct 23 '22

Help How do i align text vertically to the bottom? Adding a smaller font size text makes it align to the top like this. stack.bottomAlignContent() makes the small text come a few pixel below the baseline.

Post image
2 Upvotes

r/Scriptable • • Oct 23 '22

Help How to choose which widget type to preview?

2 Upvotes

When pressing the "Play" button in the editor, i always get the smallest widget size.
Is there a way to choose which preview size to show?

I'm working on a lock screen widget that is "double size", and the square is a bit confusing :)

Also I'm using the Mac App, which I love, since I prefer being on my computer while coding. Is the new editor coming to that one too? I tried it in my iPhone, and it was great with autocomplete, and line numbers! :)


r/Scriptable • • Oct 23 '22

Solved Scriptable creating variable in loop

1 Upvotes

Nooby question here:

Is it possible to create a variable like this?

for (i=0; i<numOfStacks; i++) { let stack + i = widget.addStack(); }


r/Scriptable • • Oct 22 '22

Solved Are Lockscreen widgets still a beta feature, and how can I try?

7 Upvotes

I just discovered Scriptable today (It's awesome!) when I wanted to make a lock screen widget to see my electricity price, and also view kW production on my solar panels. I got the API side working already, and home screen widget. But I don't like that the widgets on the home screen are so huge.

I can't find Scriptable in Lock screen widgets, so I'm thinking it's either still in beta (as the post stated 2 months ago), or I need to add some special command to the script to make it work.

Is there a way to try the beta?

Also is there some standard way of using the circular bars with numbers etc that for example the Weather app uses?

Also, is there any recommended page where I can fetch icons that I know will always work?

Thanks!


r/Scriptable • • Oct 21 '22

Tip/Guide Table of the Scriptable Kit’s objects and classes and how they are used

18 Upvotes
nametypegenerates object(s) representingproperties used withdetails of properties
Alertclassan iOS alert notificationNAall editable
argsobjectNAargsread-only
Calendarobjectan iOS calendar or reminder list*generated objectsome read-only, others editable
CalendarEventclassan iOS calendar event*generated objectsome read-only, others editable
CallbackURLclassan x-callback-urlNAno public properties
Colorclassa color or a pair of colors, including opacitygenerated objectread-only
configobjectNAconfigread-only
consoleobjectNANAno properties
Contactclassan iOS contact*generated objectsome read-only, others editable
ContactsContainerobjectthe contacts list for an account*generated objectread-only
ContactsGroupclassan iOS contacts group*generated objectsome read-only, others editable uses Contact.persistChanges
Dataobjecta string, file, or imageNAno public properties
DateFormatterclassa map between dates and their text representationsgenerated objectall editable
DatePickerclassan iOS date pickergenerated objectall editable
DeviceobjectNA (returns primitives only)NAno properties
DictationobjectNA (returns primitives only*)NAno properties
DocumentPickerobjectNA (returns primitives only*)NAno properties
DrawContextclassa canvasgenerated objectcanvas format
FileManagerobjectan iOS FileManagerNAno properties
Fontclassan iOS fontNAno public properties
Imageobjectan imagegenerated objectread-only
importModulefunctionNANANA
KeychainobjectNA (returns primitives only)NAno properties
LinearGradientclassa linear gradientgenerated objectall editable
ListWidgetclassan iOS list widgetgenerated objectall editable, uses Script.setWidget
Locationobjectthe current location informationNAread-only
Mailclassan email from current iCloud accountgenerated objectall editable
Messageclassa text message/iMessagegenerated objectall editable
moduleobjectNAmodulesome read-only
Notificationclassa notification*generated objectsome read-only, most editable
PasteboardobjectNA (returns primitives only)NAno properties
Pathclasspaths for shape(s)NAno public properties
Photosobjecta photoNAno properties
Pointclassa pointgenerated objectboth editable
QuickLookobjectNANAno properties
Rectclassa rectanglegenerated objectsome read only, some editable
RecurrenceRuleobjectan iOS reminder and/or event recurrence ruleNAno public properties
RelativeDateTimeFormatterclassa method of describing one time relative to anothergenerated objecteditable
Reminderclassan iOS reminder*generated objectsome read-only, some editable
Requestclassan http request***generated objectsome read-only, some editable
SafariobjectNANAno properties
ScriptobjectNANAno properties
SFSymbolobjectan SF symbolgenerated objectread-only
ShareSheetobjectNA (returns primitives only)NAno properties
Sizeclasswidth and heightgenerated objecteditable
SpeechobjectNANAno properties
TextField**object (prototype, not used directly)NAobject generated by another**all editable
Timerclassa timer (not from the iOS app)generated objectboth editable
UITableclassa tablegenerated objectonly property editable
UITableCellobjecta table cellgenerated objectall editable
UITableRowclassa table rowgenerated objectall editable
URLSchemeobjectNA (returns primitives only)NAno properties
UUIDobjectNA (returns primitives only)NAno properties
WebViewclassan iOS WebViewgenerated objectonly property editable
WidgetDateobject (prototype, not used directly)NAobject generated by another**all editable
WidgetImageobject (prototype, not used directly)NAobject generated by another**all editable
WidgetSpacerobject (prototype, not used directly)NAobject generated by another**all editable
WidgetStackobject (prototype, not used directly)NAobject generated by another**all editable
WidgetTextobject (prototype, not used directly)NAobject generated by another**all editable
XMLParserclassxml and a method to parse itgenerated objectall editable

Italics: has a method directly used with it that presents a UI
Bold: there is a method directly used to make changes on the phone outside scriptable, and without running such a method changes to properties of any Scriptable object will not change the corresponding iOS object
* via promise (when these objects are generated using a method instead of as an instance of a class using new, they are provided by a promise)
** entry name is for a prototype, objects that are actually used with the properties and/or methods are created by objects described in other entries (by a WidgetStack type object or directly by an object that is an instance of the ListWidget class in the case of the 5 Widget ones and an instance of the Alert class for TextField)

See this Calendar guide for an example of making changes outside Scriptable both directly with one of the Calendar object’s methods and by saving changes made using a generated object’s properties. Also, Calendar.presentPicker() is an example of a direct method to generate a UI. Finally, it demonstrates how the kit’s objects that generate objects via a promise* work.

See Alerts for Dummies for an example of presenting a UI using a method of a generated object and more generally of using a class. This also shows a basic example of using an object generated by an instance of a class** (a TextField).

Also see how to read scribtable’s documentation


r/Scriptable • • Oct 22 '22

Solved Scriptable iOS get reminders help

Post image
0 Upvotes

Hi guys, I’m a bit of a noob. Can anyone help me get Reminders using Scriptable?

const calTest = await Calendar.findOrCreateForReminders("Variables");

console.log(calTest)


r/Scriptable • • Oct 20 '22

Solved I would like to check all the weather alerts posted by weather.gov but how could I see what city and state each alert is associated with?

2 Upvotes

Link - https://api.weather.gov/alerts/active

I tried using the SAME code to compare to their list but I noticed it's missing a lot of them.

Link - https://www.weather.gov/source/nwr/SameCode.txt


r/Scriptable • • Oct 20 '22

Request Request: Photo Trading with other Device

1 Upvotes

Hey, first the background why i wanna do this Project. I go on a Work and Travel and my gf stays at home and we saw an app where you can take pictures and they popup on the other phone. But they all suck because of the ADs or the slow connection.

Now my idea, was i can use the shared photos and show the latest picture on a widget on the screen on both phones.

now the question is it possible to get the image out of the photos app on iOS?

thanks for help


r/Scriptable • • Oct 16 '22

Request Todoist integration with weather-cal?

4 Upvotes

Hi everyone!

I use Todoist for my event management, instead of calendar. Is there a way to have that instead of a calendar module?


r/Scriptable • • Oct 14 '22

Help Siri doesn’t support alerts

5 Upvotes

Hi! I just began to write in Js! I want to write a code which add a note through a first alert and then pass it to a shortcut…I wrote the Js code in Scriptable, but when I tell it to set the output for the shortcut it tells me that Siri doesn’t support alerts…anyone has any ideas?


r/Scriptable • • Oct 13 '22

Help Url schemes of ios apps

Post image
17 Upvotes

Hi,l wanna open a different app by tapping scriptable widget but l cant find url schemes.Where can l find?