Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Window Name and Exe's for Conditionals #150

Closed
rajlego opened this issue Nov 7, 2020 · 2 comments
Closed

Use Window Name and Exe's for Conditionals #150

rajlego opened this issue Nov 7, 2020 · 2 comments

Comments

@rajlego
Copy link

rajlego commented Nov 7, 2020

image
With AHK, you can make conditionals based on:
-ahk_class: name of window
-ahk_exe: the exe that the app is running from
-ahk_pid: the process ID
Currently (from what I understand) talon can use window titles but for certain applications those are dynamic. For me personally, I hope to be able to use ahk_class and ahk_exe both:
-I need to differentiate between different windows from the same exe
-I have multiple exes for the same application (I have one instance of SuperMemo open for use with plan/tasklists while I have a separate one for incremental reading)
Being able to seperate those out is very valuable.

If useful for reference, this is the current ahk script I am using. If more info is needed, happy to provide.

@lunixbochs
Copy link

lunixbochs commented Nov 7, 2020

I've done some work on this, which will land in the beta soon:

In a .talon file match section, win.class: TPlanDlg corresponds to ahk_class TPlanDlg.
In Python, win.cls will correspond to ahk_class on the Window object (You can't use the name class as a normal property in Python, hence the inconsistency)

I can trivially add app.pid: 1234 matching in .talon files, but PIDs are dynamic so that doesn't make much sense to hardcode in a file. I can think of some other ways to work with specific instances of apps from talon files, so if a need arises let me know and I'll work with you on it.

From your code:


if !WinExist("ahk_exe sm18j.exe") {
	run "C:\supermemo-collection\Journal.lnk"
}

In knausj, I think you can do this as something like:

not user.running: sm18j
-
voice command: user.system_command("C:\supermemo-collection\Journal.lnk")

I should probably make a default talonscript command that is the equivalent of "open this file in the default manner", so you could e.g. open("C:\supermemo-collection\Journal.lnk")


else if WinActive("ahk_class TMsgDialog") {
	Send y
}

This would just be:

win.class: TMsgDialog
-
voice command: key(y)

else if WinActive("ahk_class TPlanDlg") {
	Send {ESC}
}

is just

win.class: TPlanDlg
-
voice command: key(esc)

else if WinActive("ahk_class TTaskManager") {
	Send {ESC}
	WinActivate ahk_exe sm18j.exe
	Send ^p
	Send {PGDN}
}

is

win.class: TTaskManager
-
voice command:
    key(esc)    
    # WinActivate ahk_exe sm18j.exe
    # I don't have a perfect answer for window focusing yet, it might look like:
    # win.focus("sm18j.exe")
    key(ctrl-p pagedown)

else if !WinActive("ahk_class TPlanDlg") {
	WinActivate ahk_exe sm18j.exe
	Send ^p
	Send {PGDN}
}

is something like this:

not win.class: TPlanDlg
-
voice command:
    # this win.focus() action doesn't exist yet, please file an issue if you want something like this :)
    win.focus("sm18j.exe")
    key(ctrl-p pagedown)

@lunixbochs
Copy link

closing this issue because all of this is in the current early access beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants