# Setting Touchscreen mode for autologin computers

**URL:** <https://forum.inductiveautomation.com/t/setting-touchscreen-mode-for-autologin-computers/273>\
**Category:** Archived Topics\
**Created:** [May 8, 2007, 8:27pm UTC](https://forum.inductiveautomation.com/t/setting-touchscreen-mode-for-autologin-computers/273 "2007-05-08T20:27:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![clark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/clark/32/2_2.png) [@clark](https://forum.inductiveautomation.com/u/clark)\
**Post date:** [May 8, 2007, 8:27pm UTC](https://forum.inductiveautomation.com/t/setting-touchscreen-mode-for-autologin-computers/273/1 "2007-05-08T20:27:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nathan](https://forum.inductiveautomation.com/u/nathan)\
**Post date:** [May 8, 2007, 8:45pm UTC](https://forum.inductiveautomation.com/t/setting-touchscreen-mode-for-autologin-computers/273/2 "2007-05-08T20:45:46Z")

</div>

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)`

---

<div class="post-metadata">

**Author:** ![clark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/clark/32/2_2.png) [@clark](https://forum.inductiveautomation.com/u/clark)\
**Post date:** [May 8, 2007, 8:52pm UTC](https://forum.inductiveautomation.com/t/setting-touchscreen-mode-for-autologin-computers/273/3 "2007-05-08T20:52:39Z")

</div>

That worked well! Thanks.

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

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nathan](https://forum.inductiveautomation.com/u/nathan)\
**Post date:** [May 8, 2007, 9:49pm UTC](https://forum.inductiveautomation.com/t/setting-touchscreen-mode-for-autologin-computers/273/4 "2007-05-08T21:49:43Z")

</div>

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.

```auto
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.

```auto
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’].

```auto
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.
