Setting Touchscreen mode for autologin computers

I have a touchscreen computers that are set to autologin.

How can I set them to touchscreen mode automatically?
How can I set other desktop computers to launch the projects without going into touchscreen?
Can the user toggle touchscreen mode?

Clark,
You can detect and set and touchscreen mode. To selectively “automatically” go into touchscreen mode, we will maintain a list of computernames or IP addresses of who will start in touchscreen mode. To allow the user to change the setting, you can add a button or menu item that will allow the user to switch modes.

You will need FactoryPMI 2.1.1 to use fpmi.gui.setTouchscreenMode(int).

Here’s how you would toggle touchscreen mode. You could place this code on a button on the screen or in the runtime menu.

touchscreenMode = fpmi.gui.isTouchscreenMode() fpmi.gui.setTouchscreenMode(not touchscreenMode)

Here is an example of how you might selectively set computers in touchscreen mode. We use a database table called hostList that contains columns IP and hostName. If the computer that runs this script comes up with a matching IP address or hostname, FactoryPMI will run in touchscreen mode. This script would work well in the Startup Global Event Script.

myName = fpmi.net.getHostName() myIP = fpmi.net.getIpAddress() allowedHosts = fpmi.db.runQuery("SELECT hostName, IP FROM hostList") for host in allowedHosts: if host['hostName'] == myName or host[1] == myIP: fpmi.gui.setTouchscreenMode(1)

That worked well! Thanks.

Could you explain what’s going on with host[‘hostName’] and host[1]?

the result of fpmi.db.runQuery, allowedHosts, is a PyDataSet, which can be thought of like a FactorySQL dataSet or a table in the database (I’m guessing that, technically, the PyDataSet this is a list or dictionary data type that contains dictionaries - feel free to correct me here). Each row is a Python dictionary data type, which is basically a list that allows you to reference columns by index or column name.

Let’s go through line by line:

allowedHosts will be our PyDataSet containing 2 columns (hostName and IP) and as many rows as the query returns.

allowedHosts = fpmi.db.runQuery("SELECT hostName, IP FROM hostList") 

This loop does a few things. It iterates through each row in allowedHosts. Each time around host will be the dictionary data type that represents all columns for the row of that iteration.

for host in allowedHosts: 

This line shows that host’s columns can be referenced by index or name. so host[0] is the same as host[‘hostName’], which represents the hostName column at whatever row in the iteration we’re at. Similarly, host[1] is the same as host[‘IP’].

if host['hostName'] == myName or host[1] == myIP:

If you have more questions, read about Python data types, specifically sequences. List and dictionary are important ones, don’t worry about tuples or others.