Export HTML5 using command line

Hi.

I have 300 hype-documents and
I have to export them 300 times to get HTML format.

So, I want to do this heavy job using command-line.
Please tell me a way using a command line.

(I tried AppleScript. And I found that Hype dose not support AppleScript.)

Thanks.

1 Like

Have you tried using Automator in the Mac OS?

2 Likes

We tried this way but it doesn’t work, also it applies only to one file and not to all the files in the folder. We’d like to have something similar to

hype2.app --export project.hype
or even better
hype2.app --export --folder project_folder
but there are no such solutions proposed online. Is there a way to use the command line, as asked by amrkm, or another solution to export a lot of projects at once? (again, automator does not do the trick)

thanks

Any update on this feature request?

I have the similar scenario and would like to include Hype into our CI/CD process, ideally the DevOps server should be able to grab the file and export/deploy it automatically.

There's nothing to report at the moment.

To verify though, you are using a Mac for your CI/CD machine? A command line export would pretty much only be available to a computer running macOS.

Yes, I’m using a Mac M1. Do you mean it is possible? Can you please provide more details?

Thanks in advance!

Just quickly wrote an Automator App but it was hit and miss with the Permissions in opening all files dragged and dropped onto to it. You can set you own way of getting the files to the input, i.e selected finder items, choose folder etc you may have to adjust depending on how you do it. You can also have it do all methods

I.e it does the first two but I get this on the next one.

Screenshot 2023-02-20 at 23.13.55

Until I realised some of them seemed to need to be freshly opened by Hype before I tried to run them through the App.

Also I personally hate this type of key stroke scripts as they are prone to problems, not limited to timing issues, hence all the delays. And no feed back from the targets again hence all the delays..
Also note the quit Hype at the end between each file. That's because we get a connection error again due to this type of script.

on run {input, parameters}
	
	
	
	repeat with i from 1 to number of items in input
		
		tell application "Hype4" to activate
		
		delay 2
		
		set this_item to item i of input
		
		tell application "Hype4" to open (POSIX path of this_item)
		
		
		tell application "System Events" to keystroke "e" using {command down, shift down}
		
		delay 1
		
		tell application "System Events" to keystroke return
		
		
		delay 2
		
		
		tell application "Hype4" to quit
		
		
		
		delay 2
	end repeat
	
end run

Would be really good actually to a have a CL to do this ( with wait until task is complete to iterate over next file...)


For those that are interested. This is the code I put into an Automator App. ( Run AppleScript Action)

Note once you save the App you will need to make sure it is Allowed permissions.

System Settings > Privacy & Security > Automations

And

System Settings > Privacy & Security > Accessibility

Any time you resave the App , i.e if you make a change to it.

Remove it from

System Settings > Privacy & Security > Accessibility

And the Add it again.


2 Likes

Wow, thanks a lot Mark! I will give it a try...

It is a shame that this is a very useful feature while being left there for more than 7 years.

I quite like Hype4 and have been trying to use it for large scale projects, CI/CD is a major pain point though, really would like to see Hype4 can get some CLI functions like Sketch

2 Likes

Me too, I've always suspected behind the scenes it already has some for the developer side usage that could be made public.

I have made Mac apps in the past that have had CLI commands hook into functions of the main app.
It was not terribly hard to do (Objective - C days) as I remember.

So hooking the export functions up imho should not be too hard but then I do not know what really going on under the hood and features need a certain level of demand for a developer to commit the time to not only implement but support

Here is an AppleScript App version.

In Script Editor.app - Save as Application

1, Double clicking or opening the App will prompt for you to Choose a Folder with hype Files of Choose Some Hype Files

The App will only deal with Hype files it finds in the folder even if the folder contains other file types, so you do not need to worry about mixed file type folders

2, you can drag and drop on to the App and it will process the files.

If there is a file of type that should not be included nothing will happen ( AppleScript is buggy on this, it should really just ignore the no hype files but seems to just stop all processes. Not really a problem but not expected behaviour )


property maxTime : 2


(* For drag n drop *)
on open input
	
	openProjectAndSave(input)
	
	
end open


(* For Open Actions *)
on run {}
	
	display dialog "" buttons {"Cancel", "Choose Folder", "Choose Hype Projects"} default button 3
	
	if the button returned of the result is "Choose Folder" then
		
		set theFolder to choose folder with prompt "Please select folder with Hype Files:"
		
		tell application "System Events" to set input to every file in theFolder whose type identifier is {"com.tumult.hype.document"}
		
	else if the button returned of the result is "Choose Hype Projects" then
		set input to choose file with prompt "Please select some Hype Files:" of type {"com.tumult.hype.document"} with multiple selections allowed
	end if
	
	openProjectAndSave(input)
	
end run

on openProjectAndSave(input)
	repeat with i from 1 to number of items in input
		set currentTime to 0
		
		set this_item to item i of input
		
		tell application "System Events" to set typeIdentifier to type identifier of this_item
		if typeIdentifier contains "com.tumult.hype.document" then
			
			
			tell application "Hype4" to activate
			
			repeat until application "Hype4" is running or currentTime is equal to maxTime
				delay 0.5
				currentTime to currentTime + 0.5
			end repeat
			
			
			
			tell application "Hype4" to open (this_item)
			
			
			delay 2
			tell application "Hype4" to activate
			tell application "System Events" to keystroke "e" using {command down, shift down}
			
			delay 1
			tell application "Hype4" to activate
			tell application "System Events" to keystroke return
			
			
			delay 2
			
			
			tell application "Hype4" to quit
			
			
			
			delay 2
			
		end if
	end repeat
	
end openProjectAndSave

2 Likes