Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not a valide command #33

Open
MrDesjardins opened this issue May 22, 2022 · 2 comments
Open

Not a valide command #33

MrDesjardins opened this issue May 22, 2022 · 2 comments

Comments

@MrDesjardins
Copy link

Hello,

Running the following AppleScript:

tell script "Slack"
	set status "working"
end tell

I see Slack coming up and executing the / but at some point it fails with the following Slackbot message:

/statusworking is not a valid command. In Slack, all messages that start with the "/" character are interpreted as commands.
If you are trying to send a message and not run a command, try preceding the "/" with an empty space.

I see in the Events window:

tell application "Slack"
	activate
end tell
tell application "System Events"
	keystroke "/"
	keystroke "status working"
	key code 36
	key code 36
end tell

I am running the script with the ScriptEditor on macOS Monterey 12.1

Thanks for script, and let me know if there is something I am not using properly.

@MrDesjardins
Copy link
Author

For people having the same issue, instead of using the slack applescript library, I wrote an AppleScript that performs mostly what this library is trying to perform. It's my first AppleScript so, might not be the best code (got an issue with space that I fixed by explicitly sending 49 but it works.

tell application "Slack"
	activate
end tell

tell application "System Events"
	keystroke "/"
	keystroke "update"
	key code 49
	keystroke "your"
	key code 49
	keystroke "status"
	delay 1
	key code 76
	delay 1
	set textBuffer to "Hello world!"
	repeat with i from 1 to count characters of textBuffer
		if character i of textBuffer = " " then
			key code 49
		else
			keystroke (character i of textBuffer)
		end if
		delay 0.05
	end repeat
	delay 0.1
	key code 76
end tell

@samknight
Copy link
Owner

Thanks for assisting others @MrDesjardins

What do you think is causing the issue from my library - I've assumed in the past it's a timing issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants