User Tools

Site Tools


script_launch_first_item

====== About the script ====== * Purpose : Launch the first (the topmost leftmost item) from a folder without opening the folder. * Author : TBog * Link: www.google.com/+BogdanTautuTBog ====== How to use the script ====== - Set this script as long tap action on a folder ====== Script code ====== <code> var item = LL.getEvent().getItem(); if ( item.getType() != 'Folder' ) { alert('Not a folder'); return; } var items = item.getContainer().getItems(); var count = items.getLength(); if ( count == 0 ) { alert('Empty folder'); return; } var minItem; var i = 0; /* make sure we find at least a shortcut */ while ( i < count ) { minItem = items.getAt(i++); if ( minItem.getType() == 'Shortcut' ) { break; } } if ( i == count ) { alert('No shortcut found'); return; } var minTop = minItem.getCell().getTop(); var minLeft = minItem.getCell().getLeft(); /* find the topmost leftmost shortcut */ for ( ; i < count; i+=1 ) { item = items.getAt(i); if ( minItem.getType() != 'Shortcut' ) continue; var r = item.getCell(); /* check if it is the topmost leftmost */ if ( (r.getTop() < minTop) && (r.getLeft() < minLeft) ) { minTop = r.getTop(); minLeft = r.getLeft(); minItem = item; return; } } /* launch app */ minItem.launch(); </code>

script_launch_first_item.txt · Last modified: 2014/03/12 00:53 by tbog