AutoHotkey Community

It is currently May 27th, 2012, 10:00 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: September 8th, 2008, 12:48 am 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
Hello and apologies if I missed the answer to the following - been searching for hours, honestly.

The problem is (?) simple: I'm trying to replace certain executable with my own compiled script, to contain its execution - so far, so good. Thing is, the respective executable might be called from within another application and possibly being passed parameters. I've been searching through the Help file and the forums board, however I couldn't find out how to find and pass the calling application's full path & name to my script, so it would display it (in a message box or whatever).

For example, an installer upon closing, launches a text file in Notepad, specifically. I replace Notepad.exe with my script and when the application runs Notepad passing <path>\filename.txt as parameter, I want my script to display something like:
C:\Windows\Temp\AUFJS067\install.exe tried to launch Notepad with the parameters:
C:\Program Files\SomeBogusName\filename.txt


I'd appreciate any directions on how to achieve this. Thanks in advance!

_________________
AHK tools by Drugwash (AHK 1.0.48.05 and Win98SE)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2008, 1:20 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
You can pass parameters to scripts, so you could try:

Code:
msgbox %1% %2%

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2008, 1:38 am 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
Thanks, I already knew that. My problem is only how to find out the name/path of the application that called my script.
Here's a sample script:
Code:
#NoTrayIcon
StringReplace, 1, 1, ",, All
if 0 = 0
   param := "no parameters."
else
   {
   if 0 = 1
      param := "one parameter:"
   else
      param = %0% parameters:
   }
MsgBox, 48, Warning !, An application tried to launch %A_ScriptFullPath% with %param%`n%1% %2% %3% %4% %5% %6% %7% %8% %9%
GuiClose:
ExitApp

Instead of An application, I want it to display the path/name of the application that called it, as per the example in the first post.

_________________
AHK tools by Drugwash (AHK 1.0.48.05 and Win98SE)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2008, 1:44 am 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
http://www.autohotkey.com/forum/viewtopic.php?t=18550
:)

I used it here.... http://www.autohotkey.com/forum/viewtopic.php?t=30759

_________________
Image
ʞɔпɟ əɥʇ ʇɐɥʍ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2008, 2:08 am 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
Thank you so much, that is what I needed! :)
(obviously I've been using the wrong keywords in my searches...)

Cheers! 8)

[EDIT]
Oh shoot, reading the original thread with shimano's posts, I notice Win9x are not supported by GetModuleFileNameEx( p_pid ). Thing is, I really needed this for all Windows versions, especially 98SE (which I'm running on a daily basis). :cry:
I may have to find a workaround, using another function/library... :(

[EDIT 2]
Scratch that, I noticed HuBa's script has
Code:
  if A_OSVersion in WIN_95, WIN_98, WIN_ME
    Return GetProcessName(ProcessID)

I'm too tired now, I'll shut up. Thanks again for the help! :oops:

_________________
AHK tools by Drugwash (AHK 1.0.48.05 and Win98SE)


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 9th, 2008, 1:33 am 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
Sorry for the multiple editing above, I was extremely tired. :oops:

I've tested HuBa's script in Win98SE and it didn't work. Looking closely through the code, I noticed a DllCall to a function not present in Win9x versions of ntdll.dll: RtlFillMemoryUlong.

However, I found the said function in radmin32.dll. I'm not sure if all Win9x family would work with this, but at least it works on my system. The change I suggest (to keep most of the original code intact) is as following:
Code:
if A_OSVersion in WIN_95,WIN_98,WIN_ME
   DllCall("radmin32.dll\RtlFillMemoryUlong", "UInt", &PE32, "UInt", 4, "UInt", 304)  ; Set dwSize
else
   DllCall("ntdll.dll\RtlFillMemoryUlong", "UInt", &PE32, "UInt", 4, "UInt", 304)  ; Set dwSize

I still gotta find a way to fix GetModuleFilenameEx(p_pid) to work with 9x - probably by using the available GetModuleFilenameA - but for now I'm getting result 0 from that call and need to figure out why.

I'll be back with news. :wink:

_________________
AHK tools by Drugwash (AHK 1.0.48.05 and Win98SE)


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, tomoe_uehara, XstatyK and 62 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