Client Keystroke Script

The client (and designer) are built in Jython, a Java-based implementation of Python. This means you can access the Java-based GUI of the client. Doing this, you have more (unsupported by IA) control over the client and how it reacts. See this page for more information on input/action maps and how to work with them.

I explored this input map stuff, you can take a look here. In this example, it prints out a lot of stuff and then when it finds the entry in an inputmap that is just for pressing F10, it removes it. What you’d want to do is add an action to that component’s action map, and add that action’s key to the input map for F10 (where in my script, I just have a blank string). Hope this helps.

	from javax.swing import SwingUtilities as su
	from javax.swing import JComponent
	
	
	ancWin = su.getWindowAncestor(self).getComponent(0)
		
	inMap = ancWin.getInputMap()
	
	consts = [ 	['ancestor of focused', JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT],
				['whenfocused', JComponent.WHEN_FOCUSED],
				['when in focused window', JComponent.WHEN_IN_FOCUSED_WINDOW]
				]
	
	def recMap(c, i = 0):
		selfMap = {}
		try:
			for x in consts:
				selfMap[x[0]] = c.getInputMap(x[1])
		except:
			selfMap = None
		
		
		for k, v in selfMap.items():
			if v != None:
				if v.allKeys() is not None:
					print c
					print '  %s:' %  k
					for imk in v.allKeys():
						print '    %s: %s' % (imk, v.get(imk))
						if str(imk) == 'pressed F10':
							v.put(imk, "") ####Here, replace the blank quotes with the key to a new entry in component c's actionmap
		
		try:
			if i < 5:	#prevent too much recursion
				for c in c.getComponents():
					recMap(c, i + 1)
		except:
			pass
			
	recMap(ancWin)

Edit: I put this on a button for testing purposes. but I think you might put it in one of your ‘open on startup’ visionWindowOpened scripts.

5 Likes