Interactive message button to copy contents to clipboard - slack

my bot returns some contents and I want to copy that content over to the clipboard. Obviously, the user can select the content and copy. But, from a UI perspective since this is a slack BOT, I was thinking about adding an interactive button - "copy" which when clicked will copy the contents to the clipboard. I know this sounds weird but this was an ask from an exec for whom I am building the app. Let me know if you need more details.

Interactive buttons in Slack do not directly support copying content to the user's clipboard. They only do one of two things:
Send a request to a Slack app for further processing (see interactive buttons)
Redirect the user to a webpage (see link buttons)
However, to implement this feature you could redirect to a webpage that implements the copy to clipboard feature via java script (example).

Related

Is there a way to automate webpage login and download report?

Is there a way to automate a task a webpage login and download report maybe with power-automate or some other method?
open web page
enter any parameters.
click download button.
save download to local drive.
Thanks
Yes it is possible to automate it using Power Automate Desktop, you can take control of the browser, If the webpage structure remains the same and the login doesn't ask additional captcha except usual login and password fields.
You can configure the automation by
First opening the webpage using Browser Control in PAD(Power Automate Desktop)
Entering the username password can be automatically done with PAD (both should
be defined in the
automation)
Capture the web element using the action to click a button - either to
navigate the page or download something.
Can save the file into local system using PAD by usual browser download or mentioning separate path in the automation.
If you know how to code such as Python. Then Selenium,playwright,Clicknium would be a good choice. Clicknium should be the most simple one, but it can only run in Windows. In include a Recorder to identity the UI element and include APIs for click and set_text.
If you don't want to code, you can use RPA tools, such as power automate and UI path.

Cannot complete download from popup when prompting location with saveAs

I've been working on a browser extension allowing users to generate epub files from any webpage.
To use the extension, a user has to click on a toolbar button which opens a popup. On the latter, after specifying a config, the user clicks on "Generate". Here is my issue though:
When I use the download API directly, and specify saveAs to false (i.e the user is NOT prompted where to save the file), then the download is completed as expected and the file saved in some location.
However, when I do set saveAs to true --- which is what I want in the final version --- then once the user has selected the location under which to save the file, the download fails. My intuition is that as soon as the file location window pops up, the popup looses focus and dies, which makes the download impossible to resume.
Is that the explanation? And is there a way to prevent such a problem? I do not find my use case to be much of a stretch, and do not get why popups associated with browser actions are not allowed to loose focus for file selection.
Another weird thing is that I'm pretty confident this problem only appeared recently in firefox, since when I started developing the extension, I had no issue.
My intuition is that as soon as the file location window pops up, the
popup looses focus and dies, which makes the download impossible to
resume.
That's right...
Browser Action Popup is page and once page is closed, async operations will lose their reference. It is best to pass async operations to the background script.
You can use
runtime.sendMessage()
to pass a message to the background script to run the download.
You can also use the async
runtime.getBackgroundPage() to run a function in the background script but the first option works
easier as you dont need to wait for the async response as in runtime.getBackgroundPage()

How to access Print dialog's 'Open PDF in Preview' in os x programmatically

I am building a Delphi application which opens an image and its metadata and prints it. For the Windows version I build a form to generate the PrintPreview, but in Mac I can use the Print Dialog's 'Open PDF in Preview' instead. When I click on it, a PDF file is generated and I can see it, its OK. The problem is I want to access this option directly from a button, so when the button is clicked, the PDF in Preview is opened and the user does not have to open the Print Dialog, then click the 'PDF' and then select 'Open PDF in Preview'. How can I do this?
I read about using Automator, apple scripts etc, but I still can't find it.
Is there any path this generated PDF Preview is stored, so maybe I can open it from there?...
TIA
Possible duplicate of Using Automator or Applescript or both to recursively print documents to PDF but I'll answer anyways.
To answer your question directly see the question I linked to. Basically you need to use System Events from applescript to accomplish that exactly
However, there's a quicker solution using /usr/sbin/cupsfilter. Check the man page for more.
You can call cupsfilter <an-image-file> and you'll get a PDF on stdout, courtesy of OSX's printing daemon. It looks quite configurable but I just learned about it a while ago.
If you want this to open for the user you can save it in a nice place or you can do it the one-shot way and do cupsfilter <your-image> | open -f -a "Preview" to open the PDF right up.

Windows API hook, custom save as file dialog to save directly to webserver via POST

I want to write a custom save as dialog that is hooked into the File -> "Save As" of most Windows program. This custom dialog will allow the user to enter their username, password, destination folder and uploads the file to the web server via a POST. If the user clicks cancel, it will call the original file dialog.
I've been reading up about Windows API hooking and this is vaguely how I think I would approach this:
Intercept "Save As"
Display my custom dialog, return some temporary path on the drive
Let the program write file to the temporary path, assume it calls WINAPI CreateFile(...) for now
Read the temporary file and upload to web server
Clean up temporary file
But I still can't get my head around the steps required to pull this off. Assuming I can intercept the "Save As" and CreateFile function, how do I detect the CreateFile was called from a "Save As" and not just any random file creation? I can think of a hack where I keep track of the time difference of when the File dialog got open and CreateFile got called.
My alternative solution is to use the existing file dialog and create a special folder on the disk, that is constantly monitored. When a file gets written there it will call an external program that uploads the file. I haven't looked into how to do this yet. I suspect this is easier.
UPDATE
As a first baby step, I wrote a .NET task tray application that allows the user to enter their login details and a folder to monitor. Whenever a file gets dropped in there there it will upload to the web server. So far it seems to work. Now I just need to figure out how to add a nice shortcut to the left pane of the file dialog. Once that's done I think I got a solution I'm happy with.
There is no need to hook or patch anything. Create a shell namespace extension that supports IStorage::CreateStream and implements it by returning a stream that POSTs its data to the Web server. The user can then choose to save the file to your namespace extension in order to upload the file.
Hooking the standard save dialog requires you to inject a DLL into every running process and have it replace the import stub of the the Win32 API GetSaveFileName() function in the process's PE header (something anti-virus and anti-malware apps are not likely to be happy about).
Then there is the new-style save dialog that was introduced in Vista using the new IFileSaveDialog COM interface instead of GetSaveFileName(). For that, you would have to uninstall and replace Microsoft's default FileDialog COM object with a custom implementation.
That does not count custom-made save dialogs, which you are not likely to hook.
If, by some miracle, you can hook the dialog and have it return a custom path of your own creation, you don't need to hook CreateFile() itself, Just monitor the folder that you create for your purposes. Place it where it is unlikely that any other app (or user) besides you will write files to. You can create a custom subfolder in the user's or system'ss AppData folder for that purpose. You can use SHGetSpecialFolderPath() and/or SHGetKnownFolderPath() to find those folders.
The tricky part will be detecting when the file is finished being written to and has been closed. You will have to monitor the folder for changes, such as with ReadDirectoryChangesW() or SHChangeNotifyRegister(), and periodically open new/modified files for exclusive access. If a file is still open by someone else, you won't be able to open it yourself. But once you do open it, you can do whatever you want with it.

How do I display a file or directory browser dialog using MATLAB

I have created a blank GUI and now I want to program a push button to display a file or directory browser dialog.
Your question could use a little more detail, but here's a general suggestion to get you started...
You could set the callback for your push button so that it invokes one of the built-in dialog boxes available in MATLAB. You may be most interested in UIGETDIR or UIGETFILE to browse for and select a directory or file, respectively.
In addition to gnovice's advice, if you want your directory browser to be embedded within your GUI (as opposed to opening in a separate dialog window), you can use Java component. Take a look at my UICOMPONENT utility on the File Exchange for a working example.
Alternately, you can design your own tree-view of folder contents within a matlab panel, using the documented yet unsupported UITREE function or a Java JTree component (take a look at my UIINSPECT or FINDJOBJ utilities for working examples).

Resources