AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AHK executing a command in the wrong way?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
brotherS



Joined: 01 Jun 2005
Posts: 174

PostPosted: Mon Mar 02, 2009 7:10 am    Post subject: AHK executing a command in the wrong way? Reply with quote

Hi,

I'm using AutoHotkey to start Locate (http://www.locate32.net/) with the Win+f key combination, and (annonyingly) often Locate wouldn't start another instance but only bring an instance that's already running to the foreground. And when that happens I can try as often as I want, Locate would NOT start another instance. I'm using this code:

Code:
#Persistent
#f::
IfExist,C:\Program Files\Locate
  run, C:\Program Files\Locate\Locate32.exe -i
return


The Locate author suggested that AutoHotkey is the problem since he can't reproduce this behavior without AutoHotkey - and this seems to be correct, when I just hit Win+r (to open Windows' execute box) and type
Code:
C:\Program Files\Locate\locate32.exe -i

there, it works just fine!

So... do I have to change the AHK code to make this work correctly?
_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 2214
Location: switzerland

PostPosted: Mon Mar 02, 2009 7:39 am    Post subject: Reply with quote

use fullpath
Code:
#Persistent
#f::
IfExist,%A_programfiles%\Locate\Locate32.exe
  run, %A_programfiles%\Locate\Locate32.exe -i
return
Back to top
View user's profile Send private message
brotherS



Joined: 01 Jun 2005
Posts: 174

PostPosted: Mon Mar 02, 2009 9:55 am    Post subject: Reply with quote

garry wrote:
use fullpath
Code:
#Persistent
#f::
IfExist,%A_programfiles%\Locate\Locate32.exe
  run, %A_programfiles%\Locate\Locate32.exe -i
return

I get an error when I try that:
Quote:

Error: This line does not contain a recognized action.


Edit:
I then tried
Code:
#Persistent
#f::
IfExist,%Programfiles%\Locate
  run, %Programfiles%\Locate\Locate32.exe -i
return

but that isn't solving the problem either.
_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
Jex



Joined: 01 Aug 2008
Posts: 101

PostPosted: Mon Mar 02, 2009 11:58 pm    Post subject: Reply with quote

Why not just use:

Code:
#Persistent
#f::
run, C:\Program Files\Locate\Locate32.exe -i
return



if that doesn't work, try putting quotes around it:
"C:\Program Files\Locate\Locate32.exe"
then:
"C:\Program Files\Locate\Locate32.exe -i"
_________________
Woot.

Please read forum etiquette
Back to top
View user's profile Send private message
brotherS



Joined: 01 Jun 2005
Posts: 174

PostPosted: Tue Mar 03, 2009 1:06 am    Post subject: Reply with quote

Jex wrote:
Why not just use:

Code:
#Persistent
#f::
run, C:\Program Files\Locate\Locate32.exe -i
return



if that doesn't work, try putting quotes around it:
"C:\Program Files\Locate\Locate32.exe"
then:
"C:\Program Files\Locate\Locate32.exe -i"

The extra check is to make sure the hotkey wouldn't work on another system where Locate is not installed.

I changed it to:
Code:

#Persistent
#f::
IfExist,%Programfiles%\Locate
  run, "C:\Program Files\Locate\Locate32.exe" -i
return

and while it *seemed* to work at first, it still isn't *always* causing the expected results (like using Windows' command line). Strange...
_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
brotherS



Joined: 01 Jun 2005
Posts: 174

PostPosted: Wed Mar 04, 2009 10:50 am    Post subject: Reply with quote

I tried to make it work with %comspec% but that also failed...

Anyone got more ideas how I could make this work? Or *is* this a bug?
_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
closed



Joined: 07 Feb 2008
Posts: 509

PostPosted: Wed Mar 04, 2009 2:09 pm    Post subject: Reply with quote

try adding workingdir

Quote:
The working directory for the launched item. Do not enclose the name in double quotes even if it contains spaces. If omitted, the script's own working directory (A_WorkingDir) will be used.





Quote:
Run, Target , WorkingDir



Very Happy
Back to top
View user's profile Send private message
brotherS



Joined: 01 Jun 2005
Posts: 174

PostPosted: Wed Mar 04, 2009 2:25 pm    Post subject: Reply with quote

Thanks for the suggestion.

Sadly, that also doesn't work. It still mostly just activates the Locate instance that has been launched most recently.
_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
tonne



Joined: 06 Jun 2006
Posts: 1651
Location: Denmark

PostPosted: Wed Mar 04, 2009 2:46 pm    Post subject: Reply with quote

Change locate as, tools|options|keyboard shortcuts:
Change or remove the shortcut for Win+f|Global (hook)|Open dialog.
_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2
Back to top
View user's profile Send private message
brotherS



Joined: 01 Jun 2005
Posts: 174

PostPosted: Wed Mar 04, 2009 3:17 pm    Post subject: Reply with quote

tonne wrote:
Change locate as, tools|options|keyboard shortcuts:
Change or remove the shortcut for Win+f|Global (hook)|Open dialog.

Aaaaaaaaaaaaaah... who would have thought of THAT... (I obviously didn't) Cool

Thanks a lot!
_________________
DonationCoder.com brings AHK to the newbies!
Fan of AutoHotkey? Consider an occasional donation to its developer, Chris Mallett.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group