AutoHotkey Community

It is currently May 27th, 2012, 2:24 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: February 9th, 2010, 1:40 am 
Offline

Joined: September 4th, 2007, 10:11 pm
Posts: 24
I'm having trouble putting this to words. I want the user to doubleclick an INI, making my program run, and use that INI for its information.

Seems tricky. I've been looking at PostMessage or OnMessage, but I'm not seeing anything helpful.

Thanks in advance!
-Shane


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 2:34 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
No, no, no. The INI file extension is already defined for windows as a Configuration file.
My advise is to not mess with existing protocol.

If you wanted, you could create a different file extension and associate your program with that new file extension.

This would sorta be like TXT files opened in Notepad, PDF files in Acrobat Reader, or DOC files in MicroSoft Word or Wordpad.

What type of application are you wanting to make?
Maybe the forum can suggest a better alternative solution.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 3:01 am 
Offline

Joined: September 4th, 2007, 10:11 pm
Posts: 24
yes, I did not literally want to change all INIs to my program. sorry for not being clear. I was going to make a new file extension which I would use exactly like an INI, but it would only be used between a couple of my programs.

Here's the plan. One program gathers information, saves it to INI alternative: "SINI"

That file is sent to another user, who can then double click it, which opens another Gui program simply to display the saved information.

I could use the fileselectfile, but I thought this would be nicer.

I have come across something of interest here. Thanks shimanov. It uses DLLCalls to gather all processes and displays their name and command line.

I took from it what I needed in order to simply get the name of the file which triggered my program to run, then opened it with INIREAD.

His script was way over my head, and so were my ambitions, but I got it working, and hope to have a moment to study his work.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 3:17 am 
Code:
info =
(
var = 10
msgbox, `% var
)

FileDelete, %A_desktop%\Test.ahk
FileAppend, %info%, %A_desktop%\Test.SINI


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 3:18 am 
correction:
Code:
info =
(
var = 10
msgbox, `% var
)

FileDelete, %A_desktop%\Test.SINI
FileAppend, %info%, %A_desktop%\Test.SINI


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 4:21 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
Hi dicanus,

I can't vouch for the script, but I found this is in the forum.
Perhaps it will help you with completing the task.

How to create a file association (sample script)
http://www.autohotkey.com/forum/topic27599.html


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 4:30 am 
Offline

Joined: August 26th, 2009, 11:15 pm
Posts: 38
Location: Canada
oh snap i just did this for the AHK MouseRecorder (MoRe)
, I used a GUI, heres a snip:

Code:
GUI, 2:Default
Gui, Add, ListView, r20 w700 gMyListView, Name|Size (KB)
Loop, %A_scriptdir%\*.mr2
    LV_Add("", A_LoopFileName, A_LoopFileSizeKB)
LV_ModifyCol() 
LV_ModifyCol(2, "Integer") 
Gui, Show
return

MyListView:
if A_GuiEvent = DoubleClick
{
    LV_GetText(RowText, A_EventInfo)  ; Get the text from the row's first field.
    ToolTip, Closing GUI launching "%RowText%"
GUI, DESTROY   
gosub 2guiclose
    }
return

2GuiClose:
tooltip, %rowtext% now playing.
  FileRead,Mouse_moves, %RowText% ; you would change this part, and some others but can you see whats going in there, also inb4 i copypasta right from the ahk help rtfm and all that.


_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 13th, 2010, 8:45 pm 
Offline

Joined: September 4th, 2007, 10:11 pm
Posts: 24
OK, I have found my solution! I am posting here in case anyone stumbles across this looking for an answer to the same question.


Code:
commandLine := DllCall("GetCommandLineA" , "Str")


Simple enough. It returns the program being run, and the program/file that triggered it. Now I can take an INI and drag it onto the compiled program's icon, and the program will run, reading the contents of that INI.

I'm sorry I got caught up in the whole SINI bit, that was not part of the concern; it was only the dynamic INI possibilities.

Thanks to all those who helped!
-Shane


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2010, 1:03 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
Have you seen these ?

Built-in Variables
http://www.autohotkey.com/docs/Variables.htm#BuiltIn

Script Properties: command line parameters, A_WorkingDir, A_ScriptDir, A_ScriptName, (...more...)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2010, 3:24 am 
Offline

Joined: September 4th, 2007, 10:11 pm
Posts: 24
No, I was looking for the command that triggered this instance of the program... not the program itself.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, Bing [Bot], LazyMan, rbrtryn and 25 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group