Mapping F2 to Autohotkey script

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Captain
Junior Member
Junior Member
Posts: 25
Joined: 2005-11-23, 09:28 UTC
Location: Cape Town, South Africa

Mapping F2 to Autohotkey script

Post by *Captain »

Hi

I have searched the FAQ and the English forums but have not found any information on how to actually map a hotkey to an autohotkey script. I want to use the F2 key to call a script which will take as parameters two highlighted files and compare them using a third party compare tool. I have the following script (downloaded from the TC wiki):

~F2::
if WinActive( "ahk_class TFileCompForm" )
{
ControlGetText sFile1, TEdit1
ControlGetText sFile2, TEdit2
Run "c:\Program Files\Beyond Compare 2\BC2.exe" "%sFile2%" "%sFile1%"
; Run "c:\Program Files\WinMerge\WinMerge.exe" "%sFile2%" "%sFile1%"
Return
}
Return

How do I actually call this script?

thanks for your help.
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

It is called from the internal Compare window if you press F2 there. As you can read in the wiki: "This script will launch my favorite diff program from within the internal compare window, taking the two files as parameters."
I switched to Linux, bye and thanks for all the fish!
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

I want to use the F2 key to call a script which will take as parameters two highlighted files and compare them using a third party compare tool.
For that you can use the Start menu in TC:
Start / Change Start menu / &Add Item... / Parameters: %P%N %T%M
Assigning this to F2... hmmm, I dont know, maybe with an AutoHotkey script ;-)
Last edited by SanskritFritz on 2005-12-13, 08:20 UTC, edited 1 time in total.
I switched to Linux, bye and thanks for all the fish!
User avatar
gbo
Senior Member
Senior Member
Posts: 329
Joined: 2005-03-31, 19:58 UTC
Location: Lausanne (Switzerland)

Post by *gbo »

Have a look here

2gbo
This is exactly the place the script in Captains post is from Wink
Sorry my mistake next time I will drink a coffee before answering a post :?

BTW I like the above script I find it very convenient.
Last edited by gbo on 2005-12-13, 09:20 UTC, edited 1 time in total.
Gil
Licence #17346

90% of coding is debugging. The other 10% is writing bugs.
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

2gbo
This is exactly the place the script in Captains post is from ;-)
I switched to Linux, bye and thanks for all the fish!
User avatar
majkinetor
Senior Member
Senior Member
Posts: 369
Joined: 2005-11-20, 10:36 UTC
Location: Belgrade, Serbia
Contact:

Post by *majkinetor »

I am new to AutoHotkey, but as I can see in this script, it will work only if File Compare is opened and TC is active. Then, it will take those 2 files alrady opened and transfer operation to custom compare tool.

This script is of no use for you.
I am preaty busy right now, but I can give you quick workarounds:

U need some other AH script that will do this:
* U select on both panels files you want
* Script takes filename under the cursor and other file name. Maybe it has to simulate <TAB> before getting second f name
* Call your app with files

It can be done via batch even simpler, and you don't need AH script running all the time, just use some interface method of TC to make it easy avaiable (start menu, hotkeys, buttons ...)

open start menu and add batch script
Command: compare.bat
Parameters: %P%N %T%M

Compare.bat should look like this:
YOURAPP %1 %2 (or "%1" "%2" if previous doesn't work always)

Now assign F2 to call your menu item, select your files and role.

[edit]
set cm_userMenu to F2 hotkey in Configuration->Misc. Make sure you selected menu in which compare.bat resides.
User avatar
Captain
Junior Member
Junior Member
Posts: 25
Joined: 2005-11-23, 09:28 UTC
Location: Cape Town, South Africa

Post by *Captain »

Thanks for your replies! It would be nice if we could configure which compare utility to use - maybe Mr Ghisler would consider adding such functionality to the next version of TC. One of the drawbacks with the internal compare is that one cannot edit the compared files. I am sure this has come up before in this forum so please don't shoot me down if it has. Not sure if AHK is the way to go - perhaps the .bat file is.

ciao
User avatar
frenky
Senior Member
Senior Member
Posts: 250
Joined: 2005-07-30, 19:36 UTC

Post by *frenky »

It would be nice if we could configure which compare utility to use
If I remember correctly this will be implemented in v7.
Ambiguity succeeds where honesty dares not venture.
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

Yes, we very much hope so!
If I remember correctly this will be implemented in v7.
I switched to Linux, bye and thanks for all the fish!
User avatar
majkinetor
Senior Member
Senior Member
Posts: 369
Joined: 2005-11-20, 10:36 UTC
Location: Belgrade, Serbia
Contact:

Post by *majkinetor »

TC should be Totaly Configurable peace of software.

This kind of feature is MUST for every-minute-program, like TC, like Opera, like MP3 Player, etc. You don't start those programs in default if you are not a robot and have your taste for things. I've changed everything at my computer to meet my habits. The application that is started once a week, doesn't have to be like that.

So, I am appeling to Mr. Ghsiler to avoid mind traps like "this setting will be missed by nobody" or "hardcode THIS to THAT" because somebody will ask for it one day and we will have infinite discusion again and again. It's important to handle this kind of thing on initial design, since after job is done all extensions to it can and usualy present a problem.
User avatar
ado
Senior Member
Senior Member
Posts: 445
Joined: 2003-02-18, 13:22 UTC
Location: Slovakia, Pezinok

Post by *ado »

majkinetor wrote:The application that is started once a week, doesn't have to be like that.
I am starting TC only once a week - just after I reboot PC - as the first application :lol:

ado
User avatar
majkinetor
Senior Member
Senior Member
Posts: 369
Joined: 2005-11-20, 10:36 UTC
Location: Belgrade, Serbia
Contact:

Post by *majkinetor »

@ado
I'll rephrase.

The applicatin that is ACTIVATED once a week, doesn't need to be like that. :)
We are not doing this just for the money.
We are doing it for sh*t load of money.
 
 
r-moth.com
r-moth.deviantart.com
Post Reply