Appearance
Mastering Brainwrite Swift: An Introduction to Blocks and Routine Automation
Hello everyone! I hope you're always safe and healthy wherever you are. Today, we'll be diving into an exciting topic: "Introduction to Blocks" in Brainwrite Swift. If you're looking to streamline your daily tasks and automate repetitive processes, Brainwrite Swift is a fantastic tool to explore. In this blog, I'll explain how to build a routine using triggers and blocks, showcasing some awesome scenarios and features in Brainwrite Swift.
Building Basic Routines in Brainwrite Swift
Getting Started with the Brainwrite Swift Editor
To start creating routines in Brainwrite Swift, head over to the Brainwrite Swift dashboard. Here’s a step-by-step guide:
- Go to the dashboard: Select routines from the left menu.
- Add a new routine: Type a name, such as "example".
You'll begin with a trigger block as your starting point. Brainwrite Swift offers various triggers to activate routines, including Manual, General, Browser, Web Interaction, Online Services, and Conditions. Let’s start with a Browser trigger.
Example: Opening Google Translate
- Add a New Tab block: Connect it with the starting point to open Google Translate.
- Save and run: Click the Save and Run button to see Google Translate open automatically.
Next, we need to fill in the input field. Use the Element Selector from the Brainwrite Swift extension to identify the input form element, copy the selector, and paste it into the editor.
- Select Forms block: Paste the selector, check "Wait for Selector", select text field, and fill in the input (e.g., "Halo Kevin").
- Add a delay: To humanize typing, set a delay (e.g., 150ms).
- Connect blocks: Link the Forms block to the New Tab block and save.
Executing this routine will open Google Translate and type "Halo Kevin", translating it to "Hi everybody".
Advanced Routine: Translating Web Page Text
Brainwrite Swift's new feature allows translating a part of a web page and automatically opening Google Translate.
- Change the Trigger block: Set it to the context menu and name it "Translate to English".
- Update Forms block: Change the input value to
{{ variables.ctxTextSelection }}
{{ variables.ctxTextSelection }}
and save.
On a web page like Wikipedia, select the text, right-click, choose Brainwrite Swift, and select "Translate to English". Google Translate will open and provide the translation.
Running Translations in the Background
If you prefer the translation to run in the background, uncheck "Set as active tab". To get the translation result:
- Add Get Text block: Use the Element Selector to identify the translation result element, copy the selector, and paste it.
- Check options: Select "Wait for selector" and assign it to a variable (e.g., "result").
- Close the tab: Optionally, close the tab after retrieving the translation.
- Run Javascript code: Use the Brainwrite Swift function to display the result e.g.,
bwswiftRefData("variables", "result")
bwswiftRefData("variables", "result")
Saving and executing this routine will translate the text in the background and display the result.
Automating WhatsApp Messages
Brainwrite Swift can also automate sending messages via WhatsApp Web.
- Create a new routine: Name it "WhatsApp" and add a New Tab block to open WhatsApp Web.
- Element selection: Use the Element Selector to identify chat room elements.
- Click Element block: Use attributes like title to select a chat e.g.,
[title="M Norwood"]
[title="M Norwood"]
- Forms block: Select the message input field and type your message (e.g., "Hello everyone!").
- Click Send button: Use Element Selector to identify the send button and automate the click action.
Executing this routine will open WhatsApp Web, type your message, and send it.
Adding Context Menu Triggers
Create an auto-quote feature that sends selected text from a web page to WhatsApp using the context menu:
- Change the trigger to context menu: Name it "Send to WhatsApp".
- Update Forms block: Set the value to
{{ variables.ctxTextSelection }}
{{ variables.ctxTextSelection }}
- Include source URL: Use the Active Tab block to get the current URL and include it in the message.
Selecting text on a page, right-clicking, and choosing "Send to WhatsApp" will send the text along with the source URL to WhatsApp.
Conclusion
Brainwrite Swift is a powerful tool that can automate a variety of tasks, from simple daily routines to complex web interactions. By leveraging triggers and blocks, you can create efficient routines that save time and effort.
If you have any questions or seek further insights into Brainwrite Swift's capabilities, we encourage you to join our Discord server and share your thoughts. We're here to help you unlock the full potential of automation with Brainwrite Swift.
(Note: The images and URLs provided in the screenshots are placeholders and should be replaced with actual screenshots and URLs from the video for an authentic blog post.)