Mapping F2 to Autohotkey script
Moderators: white, Hacker, petermad, Stefan2
Mapping F2 to Autohotkey script
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.
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.
- SanskritFritz
- Power Member
- Posts: 3693
- Joined: 2003-07-24, 09:25 UTC
- Location: Budapest, Hungary
- SanskritFritz
- Power Member
- Posts: 3693
- Joined: 2003-07-24, 09:25 UTC
- Location: Budapest, Hungary
For that you can use the Start menu in TC: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.
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!
Have a look here
BTW I like the above script I find it very convenient.
Sorry my mistake next time I will drink a coffee before answering a post2gbo
This is exactly the place the script in Captains post is from Wink
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.
Licence #17346
90% of coding is debugging. The other 10% is writing bugs.
- SanskritFritz
- Power Member
- Posts: 3693
- Joined: 2003-07-24, 09:25 UTC
- Location: Budapest, Hungary
- majkinetor
- Senior Member
- Posts: 369
- Joined: 2005-11-20, 10:36 UTC
- Location: Belgrade, Serbia
- Contact:
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.
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.
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
ciao
- SanskritFritz
- Power Member
- Posts: 3693
- Joined: 2003-07-24, 09:25 UTC
- Location: Budapest, Hungary
- majkinetor
- Senior Member
- Posts: 369
- Joined: 2005-11-20, 10:36 UTC
- Location: Belgrade, Serbia
- Contact:
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.
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.
- majkinetor
- Senior Member
- Posts: 369
- Joined: 2005-11-20, 10:36 UTC
- Location: Belgrade, Serbia
- Contact: