Page 2 of 2 <12
Topic Options
#140379 - 2005-06-01 12:35 AM Re: Start Menu Query
iffy Offline
Starting to like KiXtart

Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
Hmm... I apparently lost my brain there for a bit... the comments about the UDF's and MSDN were meant to give info about how to extract info from a shortcut. But... if you want to run the shortcut you can of course just do that... run it So "only" the icon extraction issue is still open...
Top
#140380 - 2005-06-01 11:39 AM Re: Start Menu Query
Arkane Offline
Getting the hang of it

Registered: 2004-08-14
Posts: 50
Loc: Bath, UK
Yeah, I've got the 'UNLINK()' UDF now which looks like I could modify it to perhaps grab more info than it currently does. I cannot find the EditShortCut UDF, I did a search but it turned up nothing, is there a hidden gold-mine of UDFs somewhere else that may have this one? (I got a reply from M$ forums too.. yay - maybe I'll actually finish this off in time for it to be rejected by management )
Top
#140381 - 2005-06-01 11:54 AM Re: Start Menu Query
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here's a script to get you started. You'll need KiXforms registered.

This script will load the contents of $sFolderToDisplay into a window, and attempt to associate the icons (which is gets mostly right ).

If you double click on an icon then a message is displayed to the console giving the command line associated with it.

I'll leave you to sort out the form details, the icon sizes and the actual command execution.

Code:

.
See newer version later in thread
.


Top
#140382 - 2005-06-01 11:59 AM Re: Start Menu Query
iffy Offline
Starting to like KiXtart

Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
See http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB12&Number=82797

Interesting that a search didn't it tho?

Top
#140383 - 2005-06-01 12:25 PM Re: Start Menu Query
Arkane Offline
Getting the hang of it

Registered: 2004-08-14
Posts: 50
Loc: Bath, UK
Richard: Oooh, that's about 20 times more advanced than what I currently have. While I'm going to carry on with what I have, I'll make use of what you post here so I can add bits to my own and learn how it works rather than do a straight 'copy and paste' of it. I learn faster that way.
Iffy: Yeah it is odd, I did a search for 'editshortcut' in the UDFs forum but it came back with nothing.

The M$ forum merely said 'look at CreateShortcut method' in WSH, so I have the guide for the methods it has. I have solved the 'execution' issue I had, it now executes it, albeit not exactly cleanly.

Thanks for all your help though, I feel I'm much closer to completing this than I was 48 hours ago... now I just gotta hope it works how management expect... yaaay

Top
#140384 - 2005-06-01 12:29 PM Re: Start Menu Query
iffy Offline
Starting to like KiXtart

Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
I could make SO many comments about the expectations of management but that would be too easy so I won't go there
Top
#140385 - 2005-06-01 01:55 PM Re: Start Menu Query
Arkane Offline
Getting the hang of it

Registered: 2004-08-14
Posts: 50
Loc: Bath, UK
Now I've taken bits of Richards' functions above (well most of it actually as it's so much cleaner than mine), however the icons are all so tiny (as if forced to be 16,16). If I set the size of the icons to be 32,32 then it only displays the top half of the icon, I know the code to change it but I'm unsure how I would change this using Richards' code above.
Top
#140386 - 2005-06-01 03:20 PM Re: Start Menu Query
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I've updated the code so that the imagelist objects have the right size and the icons are loaded with these sizes (so that they look bettter.

The problem is that I still onely get the top left 16x16 bits of the icon in "Large Icon" view.

Code:



Working code in later post




Top
#140387 - 2005-06-01 04:54 PM Re: Start Menu Query
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Richard,

Tried to use your code and it appears to work fine, but cannot run any apps through it.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#140388 - 2005-06-01 05:00 PM Re: Start Menu Query
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Tried to use your code and it appears to work fine




Odd, in my environment the icons only display the upper left 16x16 bits of the icon.

Quote:

but cannot run any apps through it




No, I left that as an exercise for Arkane - the "command" is simply echoed to the console.

Top
#140389 - 2005-06-01 05:04 PM Re: Start Menu Query
iffy Offline
Starting to like KiXtart

Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
I only get the upper left 16x16 bits and not all icons seem to extract correctly (so I get duplicate icons). No time to dig in the code now tho.
Top
#140390 - 2005-06-01 05:06 PM Re: Start Menu Query
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Richard,

You are correct.. It wants to display the 1by1 iconset (http://www.mpesch3.de/ ) for a number of my desktop itemss.

(2) Easy fix..
Never mind..

I figured it out..

Change -
Code:

If VarType($oSelectedItem) AND $oSelectedItem.Selected
$sCommandToRun=$oSelectedItem.SubItems(1).Text
"Command to execute: "+$sCommandToRun+@CRLF
EndIf



To -
Code:

If VarType($oSelectedItem) AND $oSelectedItem.Selected
$sCommandToRun=$oSelectedItem.SubItems(1).Text
"Command to execute: "+$sCommandToRun+@CRLF
Run $sCommandToRun
EndIf



Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#140391 - 2005-06-01 05:13 PM Re: Start Menu Query
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Ok, it's a feature of KiXforms (for the moment )

You need to set the imagelist size before applying the imagelist to the listview object.

Thanks to Shawn for pointing me in the right direction over at the KiXforms forum.

Here's the working stuff, but you still need to code up the execution, work out how to get some of the icons and add the udfError() function which I accidentally stripped out when I tore this code from something else I had.

Code:
$=SetOption("ASCII","ON") $=SetOption("WrapAtEOL","ON") $=SetOption("Explicit","ON") Break ON
; Declare variables {{{
Global $SYSTEM,$FORMS

Global $TRUE,$FALSE
$TRUE=Not 0
$FALSE=Not $TRUE

Dim $sFolderToDisplay
$sFolderToDisplay=%USERPROFILE%+"\Desktop"
; }}}
; Initialise KiXforms system {{{
$SYSTEM=CreateObject("KiXtart.System")
If Not (9=VarType($SYSTEM)) $ERROR=@ERROR funError("Could not create KiXtart system - perhaps KiXforms is not registered?") Exit $ERROR EndIf
; Create a collection to index the forms. {{{
$FORMS=$SYSTEM.Collection()
; Make Form
udfMakeForm("frmMain")
If @ERROR Exit @ERROR EndIf
; }}}
; }}}
; Load the folder into the main form.
udfLoadProgramList($FORMS.Item("frmMain").controls("lvAppIcons"),$sFolderToDisplay)
$FORMS.Item("frmMain").Show
; Form event processing {{{
While $SYSTEM.ActiveForm.Visible
$=Execute($SYSTEM.ActiveForm.DoEvents())
Loop
; }}}
Exit 0
Function udfOnDoubleClick($sControl) ; {{{
Dim $oControl $oControl=$SYSTEM.ActiveForm.Controls($sControl)
Dim $oSelectedItem
;$oControl.View=1+$oControl.View
;If $oControl.View=4 $oControl.View=0 EndIf

Select
Case $oControl.Name="lvAppIcons"
Dim $sCommandToRun
$oSelectedItem=$oControl.FocusedItem
If VarType($oSelectedItem) AND $oSelectedItem.Selected
$sCommandToRun=$oSelectedItem.SubItems(1).Text
"Command to execute: "+$sCommandToRun+@CRLF
EndIf
Case "Unhandled"
"Unhandled double click on '"+$oControl.Name+"'"+@CRLF
EndSelect
EndFunction ; }}}
Function udfMakeForm($n) ; {{{
Dim $ERROR,$oControl,$f,$,$i,$oToolTip,$oSmallImageList,$oLargeImageList
Select
Case $n="frmMain"
$oToolTip=$SYSTEM.ToolTip()

$f=$SYSTEM.Form()
If Not (9=VarType($f)) $ERROR=@ERROR funError("Could not create new form - perhaps KiXforms is not registered?") Exit $ERROR EndIf
$f.Name=$n
$FORMS.Add($f,$f.Name)
$f.Caption="Custom Application Window"
$f.Width=690
$f.Height=335
$f.Center

$oControl=$f.Controls.Listview("lvAppIcons",0,0,688,300)
$oControl.Name="lvAppIcons"
$oControl.MultiSelect=$FALSE
$oControl.View=0 ; Large icons
$oControl.Sorted=$TRUE
$oSmallImageList=$SYSTEM.ImageList()
$oSmallImageList.ImageSize=$SYSTEM.Size(16,16)
$oControl.SmallImageList=$oSmallImageList
$oLargeImageList=$SYSTEM.ImageList()
$oLargeImageList.ImageSize=$SYSTEM.Size(32,32)
$oControl.LargeImageList=$oLargeImageList
$oControl.OnDoubleClick="udfOnDoubleClick('"+$oControl.Name+"')"
$oToolTip.SetToolTip($oControl,"Double click on an application to launch it")
$=$oControl.Columns.Add("Program",688,0)
$=$oControl.Columns.Add("File Path",0,0)
EndSelect
Exit 0
EndFunction ; }}}
Function udfLoadProgramList($oControl,$sFolder) ; {{{
Dim $oNewItem,$sFile,$sSuffix,$iIndex
$sFile=Dir($sFolder)
While Not @ERROR
$iIndex=InStrRev($sFile,".")
$sSuffix=SubStr($sFile,$iIndex+1)
If $sSuffix="exe" OR $sSuffix="lnk"
$oNewItem=$oControl.Items.Add
$oNewItem.SubItems(0).Text=Left($sFile,$iIndex-1)
$oNewItem.SubItems(1).Text=$sFolder+"\"+$sFile
$oNewItem.ImageIndex=udfLoadIcon($sSuffix,$oControl,$oNewItem,$sFolder+"\"+$sFile)
EndIf
$sFile=Dir("")
Loop
Exit 0
EndFunction ; }}}
Function udfLoadIcon($sSuffix,$oControl,$oItem,$sIconPath) ; {{{
Dim $oSmallIcon,$oLargeIcon,$oShell,$oShortCut
$udfLoadIcon=$FALSE
If $sSuffix="lnk"
$oShell=CreateObject("wscript.shell")
If 9=VarType($oShell)
$oShortCut=$oShell.CreateShortCut($sIconPath)
If $oShortCut.IconLocation<>",0"
;$sIconPath=Left($oShortCut.IconLocation,InStrRev($oShortCut.IconLocation,",")-1)
$sIconPath=$oShortCut.IconLocation
EndIf
EndIf
EndIf
$oSmallIcon=$SYSTEM.icon($sIconPath,16,16)
If VarType($oSmallIcon)=9
$udfLoadIcon=$oControl.SmallImageList.Images.Add($oSmallIcon)
$oLargeIcon=$SYSTEM.icon($sIconPath,32,32)
$udfLoadIcon=$oControl.LargeImageList.Images.Add($oLargeIcon)
EndIf
Exit 0
EndFunction ; }}}
; {{{ }}} vim: ai ts=4 sw=4 fdm=marker fdc=4 fml=0:


Top
#140392 - 2005-06-01 05:19 PM Re: Start Menu Query
iffy Offline
Starting to like KiXtart

Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
Works for me (except for some icons not loading correctly). Hey Richard, when was the last time someone told ya you're a genius?
Top
#140393 - 2005-06-01 05:27 PM Re: Start Menu Query
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Did you try searching for a UDF at one of the mirror sites?

I would try looking at Bryce's site for now, mine is currently still broken for updates.

This is a STICKY POST in the UDF Forum.
UDF Mirror Sites - Sorted List of UDF
 
Hopefully can get time soon to work with Howard B. to get my site working again.

Bryce's site is ISORG
 

Top
#140394 - 2005-06-01 06:39 PM Re: Start Menu Query
Arkane Offline
Getting the hang of it

Registered: 2004-08-14
Posts: 50
Loc: Bath, UK
Richard: Thanks for that update, I've now created something that works well (and doesn't need the big icons), the only trick now is to get folders in there too, so when you double-click a folder it goes into it, enumerates the icons and folders - in my other version I had this working well but the icons were total evil. Is there also a way to get it to load with no titlebars/borders or anything (so it's invisible except the icons?) and have it survive a 'Desktop refresh' and not be killable (so you can't ALT + F4 it?). This may sound real odd but I'm trying to get as close to our current desktop-solution as possible. If this can't do quite as much I'm sure I can run with it but it needs to withstand kids (end users) poking with it and trying to kill it off. Any thoughts (make it a service perhaps?)

NTDOC: Thanks for that link, much appreciated.

Top
#140395 - 2005-06-01 06:51 PM Re: Start Menu Query
Arkane Offline
Getting the hang of it

Registered: 2004-08-14
Posts: 50
Loc: Bath, UK
Richard: Just updated my code with your improved stuff, those big icons look great now - Thanks. I updated the icon handlers so that if it was a .bat file, it would use a generic icon from shell32.dll, other files (like .exe) I told it to use the first icon (index 0) in that exe file as a sort of 'generic' - it doesn't cater for the fact that an .exe may not have an icon or anything like that... but at the moment I just want to presentable to management to say 'hey boss - this is how far I got - bear in mind it isnt finished'. It'd be easier for me to just go back to repairing our various AD forests (at least then they don't want to know about it)
Top
#140396 - 2005-06-02 11:03 AM Re: Start Menu Query
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
The KiXforms "SYSTEM" object has a load of built-in icons that you can use for generic objects like folders and so-on.

Drilling down into folders is pretty trivial - just clear the listview and call udfLoadProgramList() with the (new) selected folder path - don't forget to add an "up" icon though, or a handler for the backspace key.

You can change the window style to get rid of buttons, title bars and so-on. You'd be better off over at http://www.kixforms.org/forum/ if you want to start tarting about with the look and feel of the window.

The easiest way to deal with a killed window is simply to respawn it.

Top
#140397 - 2005-06-02 05:39 PM Re: Start Menu Query
Arkane Offline
Getting the hang of it

Registered: 2004-08-14
Posts: 50
Loc: Bath, UK
Here's the sad part - management liked what I did but not enough that they consider it a replacement. This means that as far as official time goes, I can't work anymore on this. I will keep the code though because it's been a good learning experience and I may actually end up re-using it or doing something else with it. It makes little difference to me because I got something out of it whether they went for it or not, so it wasn't a waste of time I'd like to thank you all for your help with this, it's amazing how far a little bit of help can take you and also amazing how far alot of help can take you. Thanks muchly
Top
Page 2 of 2 <12


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 978 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.073 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org