KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Kix Association

 
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
dr-rick
KiXforms Dabbler
KiXforms Dabbler


Joined: 23 Mar 2011
Posts: 13
Location: Guam

PostPosted: Mon Oct 22, 2012 5:14 pm    Post subject: Kix Association Reply with quote

Is a compiled KIXforms Script capable of file association? I have a comma delimted script that processes data read from a csv file. It would be handy if one could associate the compiled script with the OS to launch and open the csv file automatically.
_________________
Regards,
Dr Rick
Back to top
View user's profile Send private message Visit poster's website
enahsyemotp
KiXforms Regular
KiXforms Regular


Joined: 22 Sep 2010
Posts: 40
Location: Tulsa, OK

PostPosted: Fri Oct 26, 2012 4:18 pm    Post subject: Reply with quote

Have you considered the Kix2EXE application?
Back to top
View user's profile Send private message
enahsyemotp
KiXforms Regular
KiXforms Regular


Joined: 22 Sep 2010
Posts: 40
Location: Tulsa, OK

PostPosted: Fri Oct 26, 2012 4:22 pm    Post subject: Reply with quote

It can be found here. It's a simple tool that packages kix scripts into an exe, along with any other files you wish.
Back to top
View user's profile Send private message
dr-rick
KiXforms Dabbler
KiXforms Dabbler


Joined: 23 Mar 2011
Posts: 13
Location: Guam

PostPosted: Sat Oct 27, 2012 12:42 pm    Post subject: Kix2Exe Reply with quote

I am familiar with the creation of executable files using Kix2Exe. I was wondering if there was a UDF or function that could be added to the script that would allow files to be opened directly via file association to the executable. For example my csv script has a load function when a button or menu item is clicked it launches the open file dialogue. I would like to see the script automatically read and load the data file when clicked in lieu of the launching the script and loading the data manually.
_________________
Regards,
Dr Rick
Back to top
View user's profile Send private message Visit poster's website
enahsyemotp
KiXforms Regular
KiXforms Regular


Joined: 22 Sep 2010
Posts: 40
Location: Tulsa, OK

PostPosted: Sat Oct 27, 2012 2:25 pm    Post subject: Reply with quote

So you want to be able to double-click a csv file and it be opened with your script? Still not clear on what you're wanting to do.
Back to top
View user's profile Send private message
dr-rick
KiXforms Dabbler
KiXforms Dabbler


Joined: 23 Mar 2011
Posts: 13
Location: Guam

PostPosted: Sat Oct 27, 2012 6:24 pm    Post subject: Reply with quote

Yes I would like to associate my executable script to automatically open the script and read the file by double clicking on the csv file.
_________________
Regards,
Dr Rick
Back to top
View user's profile Send private message Visit poster's website
enahsyemotp
KiXforms Regular
KiXforms Regular


Joined: 22 Sep 2010
Posts: 40
Location: Tulsa, OK

PostPosted: Sat Oct 27, 2012 9:12 pm    Post subject: Reply with quote

I'm fairly certain you can get the file association to work, where a kix script is ran when the file is double clicked. The problem then is, how does the kix script know which file was clicked that launched it...hmm.
Back to top
View user's profile Send private message
dr-rick
KiXforms Dabbler
KiXforms Dabbler


Joined: 23 Mar 2011
Posts: 13
Location: Guam

PostPosted: Sun Oct 28, 2012 8:37 pm    Post subject: Reply with quote

I suppose that one could look at the command line at execution and parse it for an entry with csv in it. Then strip off everything except the csv file and use that information to send to the script to open. Does anyone know of a UDF already created for this purpose? There would be no sense in recreating the wheel if the UDF was already available.
_________________
Regards,
Dr Rick
Back to top
View user's profile Send private message Visit poster's website
dr-rick
KiXforms Dabbler
KiXforms Dabbler


Joined: 23 Mar 2011
Posts: 13
Location: Guam

PostPosted: Mon Oct 29, 2012 12:51 am    Post subject: Reply with quote

I added a function to perform this task. I called the function from the main script at execution and have successfully generated the executable script and associated it with the Window 7 so that it automatically opens the csv file. You can even drop the csv file on the script and it loads automatically. It can be used on UNC paths as well.

....
Set_Infile
IF $Infile<>"" Read_File() EndIf
....

Function Set_InFile()
$CL = GetCommandline(1)
For each $item in $CL
IF instr(lcase($item),".csv")
If Instr($item,":") $starting_pos=Instr($item,":") - 1 EndIf
If Instr($item,"\\") $starting_pos=Instr($item,"\\") EndIf
$trailing_pos= Instr(lcase($item),".csv")
$trailing_pos= $trailing_pos+3
$length=($trailing_pos+1)-($starting_pos)
$item=SUBSTR ($item, $starting_pos, $length)
Update_Status("auto loading CSV file " + $item+".")
$InFile=trim($item)
EndIf
Next
EndFunction

_________________
Regards,
Dr Rick
Back to top
View user's profile Send private message Visit poster's website
enahsyemotp
KiXforms Regular
KiXforms Regular


Joined: 22 Sep 2010
Posts: 40
Location: Tulsa, OK

PostPosted: Mon Oct 29, 2012 3:26 pm    Post subject: Reply with quote

Ok I got it to work finally. You can probably edit the association of csv files in the registry to make it work. But I would recommend just renaming the csv you are working with to have a unique extension so that all csv files on the system are not effected. You can then use the code below to associate the new extension to whatever kix script you want. Just change the wkix32.exe path, and the newext_files.kix path. The $file variable will hold the path of the file that called the script once it's ran.

Code:
$nul = setoption("NoVarsInStrings","On")
$nul = setoption("NoMacrosInStrings","On")

$nul = WriteValue("HKEY_CLASSES_ROOT\.newext","","newext document","REG_SZ")
$nul = WriteValue("HKEY_CLASSES_ROOT\newext document","","New Extension","REG_SZ")
$nul = WriteValue("HKEY_CLASSES_ROOT\newext document\DefaultIcon","","","REG_SZ")
$nul = WriteValue("HKEY_CLASSES_ROOT\newext document\Shell\open\command","",'%%windir%%\wkix32.exe "C:\newext_files.kix" $file="%%1%%"',"REG_SZ")
Back to top
View user's profile Send private message
dr-rick
KiXforms Dabbler
KiXforms Dabbler


Joined: 23 Mar 2011
Posts: 13
Location: Guam

PostPosted: Mon Oct 29, 2012 5:05 pm    Post subject: Reply with quote

Thanks I will look at that. My full intention was to launch the csv data file to launch and load the script. I liked the idea of adding it to the launch menu. Here is a link to the script location and some sample data files.
_________________
Regards,
Dr Rick
Back to top
View user's profile Send private message Visit poster's website
dr-rick
KiXforms Dabbler
KiXforms Dabbler


Joined: 23 Mar 2011
Posts: 13
Location: Guam

PostPosted: Mon Oct 29, 2012 5:09 pm    Post subject: Reply with quote

Latest compiled iReport II script.
_________________
Regards,
Dr Rick
Back to top
View user's profile Send private message Visit poster's website
enahsyemotp
KiXforms Regular
KiXforms Regular


Joined: 22 Sep 2010
Posts: 40
Location: Tulsa, OK

PostPosted: Mon Oct 29, 2012 6:47 pm    Post subject: Reply with quote

You could add a script option to the right click menu as well...like so.

Code:
$nul = setoption("NoVarsInStrings","On")
$nul = setoption("NoMacrosInStrings","On")

$csvbranch = "HKCR\"+ReadValue("HKCR\.csv","")+"\shell"
$nul = WriteValue($csvbranch+"\scriptopen\command","",'"C:\program files\iReport II\iReport II.exe" /file "%%1%%"',"REG_SZ")


Just change the path to the report II.exe, and change the 'scriptopen' to whatever description you'd like.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group