Posts: 7
Threads: 2
Joined: Jun 2021
Hello to all, I'm not a programmer and I will really apreciate someone to help me to transform the script done in QM to LA, QM was really easy and now with this change I'm learning!
When I please the hotkey, if Totalcmd is not running, it will start TC, if TC is running and active it will send it to the tray, if TC is in the tray, it will active
/////////////////////////
On Keypress Ctrl+Alt+s adds tray icon and stays running. If Total Commander if not running runs and exits.
Sub-function TrayProc is called on mouse events.
str location="E:\D\totalcmd\TOTALCMD64.EXE";; chnage to program location if not the same
int w=win("Total Commander" "TTOTAL_CMD")
if(!w)
run location
ret
int h=hid(w)
if(!h)
hid w
Tray t.AddIcon(location "Show Total Commander" 0 &sub.TrayProc);;change first arguement to pc location if not the same
MessageLoop
wait -1
else
act w
EndThread +getopt(itemid)
#sub TrayProc v
function Tray&tray msg
sel msg
case WM_LBUTTONUP
sel GetMod
case 0 ;;left click on icon
act w
shutdown -7
case 2 ;;control +left click on icon
act w
shutdown -7
Posts: 12,191
Threads: 144
Joined: Dec 2002
// script "Totalcmd tray icon.cs"
/// On Keypress Ctrl+Alt+s adds tray icon and stays running. If Total Commander if not running runs and exits.
/*/ ifRunning run; /*/
var w = wnd.find(@"*Notepad++", "Notepad++", flags: WFlags.HiddenToo);
if (w.Is0) {
run.it(@"C:\Program Files\Notepad++\notepad++.exe");
} else if (w.IsVisible) {
script.trayIcon(0,
init: t => {
t.Icon = icon.ofWindow(w);
t.Tooltip = "Show Total Commander";
t.Click += e => { timer.after(30, _ => w.Activate()); };
}
);
w.Show(false);
try { w.WaitFor(0, w => w.IsVisible); } catch { }
} else {
w.Activate();
}
To assign a trigger use menu
TT > New trigger.
Posts: 7
Threads: 2
Joined: Jun 2021
Thanks for the help, I did a modification and it worked
The part that is not clear to me when I create the trigger,
/// On Keypress Ctrl+Alt+s adds tray icon and stays running. If Total Commander if not running runs and exits.
/*/ ifRunning run; /*/
var w = wnd.find(@"*Total*", "*Total*", flags: WFlags.HiddenToo);
if (w.Is0) {
run.it(@"e:\D\totalcmd\TOTALCMD64.EXE");
} else if (w.IsVisible) {
script.trayIcon(0,
init: t => {
t.Icon = icon.ofWindow(w);
t.Tooltip = "Show Total Commander";
t.Click += e => { timer.after(30, _ => w.Activate()); };
}
);
w.Show(false);
try { w.WaitFor(0, w => w.IsVisible); } catch { }
} else {
w.Activate();
}
wnd.fin;
When I create a trigger this below appears but I can not make it work... in QM was much easier
using Au.Triggers;
partial class Program {
[Triggers]
void HotkeyTriggers() {
var hk = Triggers.Hotkey;
//Add hotkey triggers here.
//To add triggers can be used triggerSnippet or menu TT > New trigger.
//To add trigger scopes (window, program) can be used Ctrl+Shift+Q.
//Click the Run button to apply changes after editing.
//More info in Cookbook.
hk["Ctrl+Shift+T"] = o => Triggers.ShowTriggersListWindow();
hk["Ctrl+Alt+M"] = o => { print.it(o); };
hk["Ctrl+Alt+M"] = o => { print.it(o); };
hk.Last.EnabledAlways = true;
hk.Last.EnabledAlways = true;
if (!true) { //examples. To enable and test it, replace (!true) with (true) and run this script.
hk["Ctrl+Alt+K"] = o => print.it("trigger action example 1", o.Trigger); //it means: when I press Ctrl+Alt+K, execute trigger action print.it(...)
hk["Ctrl+Shift+F11"] = o => { //multiple statements
var w1 = wnd.active;
if (w1.Name.Like("* - Notepad")) keys.sendt("trigger action example 2\r\n");
else print.it("trigger action example 2");
};
hk["Ctrl+Shift+1"] = o => TriggerActionExample(); //call other function. To find it quickly, click the function name here and press F12.
hk["Ctrl+Shift+2"] = o => TriggerActionExample2(o.Window); //the function can be in any class or partial file of this project
hk["Ctrl+Shift+3"] = o => script.run("Script example1.cs"); //run script in separate process
hk["Ctrl+Shift+4", TKFlags.LeftMod | TKFlags.KeyModUp] = o => print.it("trigger with flags");
//triggers that work only with some windows (when the window is active)
Triggers.Of.Window("*Chrome", "Chrome_WidgetWin_1");
hk["Ctrl+F5"] = o => print.it("trigger action example 5", o.Trigger, o.Window);
//hk[""] = o => { };
// ...
Triggers.Of.Window(of: "notepad.exe"); //all windows of notepad.exe process
hk["Ctrl+F5"] = o => print.it("trigger action example 6", o.Trigger, o.Window);
//hk[""] = o => { };
// ...
// ...
Triggers.Of.AllWindows();
//disable or remap keys
//hk["CapsLock"] = o => { }; //just disable. Does not disable Ctrl+CapsLock etc.
//hk["?+Ins"] = o => keys.more.sendKey(KKey.Apps); //remap key. Also Ctrl+Ins etc. To remap keys, use keys.more.sendKey or keys.sendL, not keys.send.
//disable/enable triggers
hk["Ctrl+Alt+Win+D"] = o => ActionTriggers.DisabledEverywhere ^= true;
hk.Last.EnabledAlways = true;
}
}
void TriggerActionExample() {
print.it("trigger action example 3");
}
}