Controlling Hardware

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jwbuzz
Posts: 39
Joined: Tue Apr 13, 2010 7:56 pm

Controlling Hardware

Post by jwbuzz » Wed May 05, 2010 9:28 pm

Hi guys.. I'm using revolution to build a kiosk. I'd like to build in functionality to where it will communicate back to a central server via http so that we can control these kiosks in various stores. Specifically, I'm wondering if you can do the following in revolution on a Mac.

1. Reboot the machine
2. Determine running applications/processes

Thanks,
Justin

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: Controlling Hardware

Post by bn » Wed May 05, 2010 11:37 pm

Hi Justin,
you can do that via applescript

Code: Select all

tell application "System Events"
	set tAllProcesses to ""
	set tProcessItems to the name of every process
	repeat with anItem in tProcessItems
		set tAllProcesses to (tAllProcesses & anItem as text) & linefeed
	end repeat
	return tAllProcesses
end tell

Code: Select all

tell application "System Events"
	restart
end tell
you can run this in the script editor (applescript)
in Rev you can put the applescript into a field e.g. named "fAllProcesses" and than

Code: Select all

on mouseUp
   put field "fAllProcesses" into tAllProcessesThatRun
   do tAllProcessesThatRun as applescript
   put the result into tAllTheRunningStuff
   put char 2 to -2  of tAllTheRunningStuff into tAllTheRunningStuff --  remove quotes
   put tAllTheRunningStuff
end mouseUp
for restart the same
regards
Bernd

Edit: forgot to remove a trailing linefeed. You might want to put

Code: Select all

 put char 2 to -3  of tAllTheRunningStuff into tAllTheRunningStuff --  remove quotes & trailing linefeed
into above code instead of the original line.
B.

jwbuzz
Posts: 39
Joined: Tue Apr 13, 2010 7:56 pm

Re: Controlling Hardware

Post by jwbuzz » Thu May 06, 2010 2:10 pm

Thanks Bernd. I'll give this a try today. Can you have a Revolution app with fields but no visible cards? I'm thinking now I'll just build this as a "service" type app that runs in the background on the machine.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: Controlling Hardware

Post by bn » Thu May 06, 2010 2:32 pm

Justin,
you dont have to put the applescript into a field. You might just as well put it into a custom property. Or you might construct in a script on the fly. The reason it is in a field is that for me that is the easiest way to look at it, debug/replace it. Once the script works you might try the other options: (though I dont like constructing the aplescript on the fly because of all the quoting needed, it makes it error prone for me)

Without knowing what you want to do with your app in the background: shure you can hide the stack after startup. Probably in a opencard script of the first and only card you could say:

Code: Select all

on opencard
   send "hideThisStack" to me in 1 second -- adjust
end opencard

on hideThisStack
   set the visible of this stack to false
end hideThisStack
regards
Bernd

jwbuzz
Posts: 39
Joined: Tue Apr 13, 2010 7:56 pm

Re: Controlling Hardware

Post by jwbuzz » Thu May 06, 2010 2:49 pm

Bernd,
Thanks again for the reply.. don't think I stated my question clearly enough. What I meant was can I run a Rev app as a service where it doesn't show up if the user does cmd + tab, doesn't have a menu, etc. That may be more of an Apple question than a revolution question, but I thought I'd check. Basically, I want this app to start when the machine starts but be running in the background.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: Controlling Hardware

Post by bn » Thu May 06, 2010 3:31 pm

Justin,
jwbuzz wrote:can I run a Rev app as a service where it doesn't show up if the user does cmd + tab, doesn't have a menu, etc.
I don't think so. But someone else might know more about this.
regards
Bernd

RRobert
Posts: 151
Joined: Sat Feb 28, 2009 8:20 pm

Re: Controlling Hardware

Post by RRobert » Fri May 07, 2010 8:23 am

jwbuzz wrote:Thanks Bernd. I'll give this a try today. Can you have a Revolution app with fields but no visible cards? I'm thinking now I'll just build this as a "service" type app that runs in the background on the machine.
See LSUIElement if your application should not appear in the Dock or in the Force Quit window.

You could also add- and remove login items by AppleScript.

Robert

Post Reply