one part disables working of another part which is not wanted

Get help with using AutoHotkey and its commands and hotkeys
Gevali
Posts: 16
Joined: 01 Jan 2016, 20:27

one part disables working of another part which is not wanted

20 Jun 2018, 09:49

Hallo, I wanna Pause another script, it is sometimes going mad. For this I use the following.

Code: Select all

#IfWinActive ahk_exe firefox.exe
PRINTSCREEN::
{
	; Send a Pause command to another script.
	DetectHiddenWindows, On
	WM_COMMAND := 0x111
	ID_FILE_PAUSE := 65403
	PostMessage, WM_COMMAND, ID_FILE_PAUSE,,, [PATH]\Script.ahk ahk_class AutoHotkey
	DetectHiddenWindows, Off
}
return
But when this is active the following isnt working anymore. When I put the above part below the above part it not working but the second part.

Code: Select all

SetTitleMatchMode RegEx

:::)::[UTF-SMILEY]
How can I get both parts in the same script working?
Gevali
Posts: 16
Joined: 01 Jan 2016, 20:27

Re: one part disables working of another part which is not wanted

23 Jun 2018, 03:18

No, its the path to the script. And it works like that. Found that in the net for controlling other AHK Skripts. [PATH] is cleaned for the the board here.
User avatar
evilC
Posts: 4354
Joined: 27 Feb 2014, 12:30

Re: one part disables working of another part which is not wanted

23 Jun 2018, 06:59

Unless the title of the window literally contains the path, then the only way that a WinTitle parameter will properly match a window given a path to a file, is using ahk_exe, and that needs to point to an EXE file, not an AHK file.
Gevali
Posts: 16
Joined: 01 Jan 2016, 20:27

Re: one part disables working of another part which is not wanted

23 Jun 2018, 09:04

But it refers to ahk_class AutoHotkey. And as I said, it works. Else how to control an AHK script from outside?
It didnt work from inside during it executes a function.

EDIT: The last sentence is not fully correct. It does not work during it executes a function to use a Hotkey combination of more than one key. If I use one key, it works. Interesting. Solves my problem, but did not answer my question :)
User avatar
evilC
Posts: 4354
Joined: 27 Feb 2014, 12:30

Re: one part disables working of another part which is not wanted

23 Jun 2018, 11:53

If you specify multiple attributes like you have (title text and class), then BOTH must match any given window (except for ahk_group, which widens the set)
So if the title is incorrect, the class will not make a given window match.
See the Multiple Criteria section.
I have never really had a need for one script to control another, but without more info on your use-case, it's hard to advise
User avatar
jeeswg
Posts: 5287
Joined: 19 Dec 2016, 01:58
Location: UK

Re: one part disables working of another part which is not wanted

23 Jun 2018, 15:18

If you are using SetTitleMatchMode with RegEx, you might have to escape some characters: e.g. use \Q and \E. See:
simplest way to make a RegEx needle literal? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=30420
swagfag
Posts: 1381
Joined: 11 Jan 2017, 17:59

Re: one part disables working of another part which is not wanted

23 Jun 2018, 16:26

while the dot in ahk_exe firefox.exe won't match just a literal dot, i dont see how that could be the cause of the issue here.

OP, it would help if u could post the 2 full scripts, the one thats working and the one that isnt, cuz "when I put the above part below the above part it not working but the second part." didn't exactly make it any clearer. in fact, id argue the opposite
lexikos
Posts: 6205
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: one part disables working of another part which is not wanted

23 Jun 2018, 22:30

Given "But when this is active the following isnt working anymore." (and ignoring the very confusing sentence "When I put the above part below the above part it not working but the second part."), I would guess that the full script is this:

Code: Select all

#IfWinActive ahk_exe firefox.exe
PRINTSCREEN::
{
	; Send a Pause command to another script.
	DetectHiddenWindows, On
	WM_COMMAND := 0x111
	ID_FILE_PAUSE := 65403
	PostMessage, WM_COMMAND, ID_FILE_PAUSE,,, [PATH]\Script.ahk ahk_class AutoHotkey
	DetectHiddenWindows, Off
}
return

SetTitleMatchMode RegEx

:::)::[UTF-SMILEY]
SetTitleMatchMode RegEx will never be executed and will therefore have no effect. See the top of the script.

However, I see no reason to use SetTitleMatchMode RegEx in either part of this script. It would have no effect on the hotstring, and would cause the opposite of what you said: when the second part is placed above the first part, the PostMessage call would fail. This is because when you use the RegEx mode, literal slashes must be escaped. For example, PATH\\Script.ahk (double each slash) or \QPATH\Script.ahk\E (surround the full path with \Q and \E).

RegEx is also case-sensitive by default, meaning you must use exactly the same case for the path as is shown in the window's title. You can prefix the regex with i) to make it case-insensitive, but it is probably better to override the default mode within the hotkey (below PRINTSCREEN:: but above PostMessage): SetTitleMatchMode 1 (or 2).
Unless the title of the window literally contains the path [...]
Yes, all windows of class "AutoHotkey" by default have a title beginning with the full path of the script. You can see it when you select "Open" from the tray menu or use a command such as ListLines.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Mipha, swagfag, TheYllib and 123 guests