Pausing one script from another

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
vasili111
Posts: 747
Joined: 21 Jan 2014, 02:04
Location: Georgia

Pausing one script from another

08 Jun 2014, 07:36

I need to pause one script from another.
I have script tooltip.ahk and I need to pause it:

Code: Select all

a := 0
Loop, {
	a := a + 1
	ToolTip, %a%
}
According to FAQ http://www.autohotkey.com/docs/FAQ.htm#close I created another script pause.ahk

Code: Select all

PostMessage, 0x111, 65306,,, tooltip.ahk - AutoHotkey  ; Pause
I am launching tooltip.ahk and after pause.ahk but tooltip.ahk is not paused. Why tooltip.ahk is not paused when I run pause.ahk ?
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
RHCP
Posts: 202
Joined: 30 Sep 2013, 10:59

Re: Pausing one script from another

08 Jun 2014, 07:42

You need to turn on detectHiddenWindows.

Here is a function which can also suspend hotkeys.
http://www.autohotkey.com/board/topic/1 ... ntry634811
vasili111
Posts: 747
Joined: 21 Jan 2014, 02:04
Location: Georgia

Re: Pausing one script from another

08 Jun 2014, 07:50

I made:

Code: Select all

detectHiddenWindows, On
PostMessage, 0x111, 65306,,, tooltip.ahk - AutoHotkey  ; Pause.
and

Code: Select all

detectHiddenWindows, On
a := 0
Loop, {
	a := a + 1
	ToolTip, %a%
}
But when I launch pause.ahk the tooltip.ahk is not paused.
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
RHCP
Posts: 202
Joined: 30 Sep 2013, 10:59

Re: Pausing one script from another

08 Jun 2014, 07:54

You also need "SetTitleMatchMode, 2". I thought it might work without it, but i forgot the hidden script window title includes the full path of the script. You only need to place these commands in the script which is posting the message.
Note that this toggles the pause state, it doesn't explicitly pause it.
vasili111
Posts: 747
Joined: 21 Jan 2014, 02:04
Location: Georgia

Re: Pausing one script from another

08 Jun 2014, 08:00

RHCP wrote:You also need "SetTitleMatchMode, 2". I thought it might work without it, but i forgot the hidden script window title includes the full path of the script. You only need to place these commands in the script which is posting the message.
I made:

Code: Select all

SetTitleMatchMode, 2
detectHiddenWindows, On
PostMessage, 0x111, 65306,,, tooltip.ahk - AutoHotkey  ; Pause.
It does not pauses tooltip.ahk.
RHCP wrote: Note that this toggles the pause state, it doesn't explicitly pause it.
I dont understand. Can you please explain more? I need to actually pause tooltip.ahk .
Last edited by vasili111 on 08 Jun 2014, 08:08, edited 1 time in total.
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
RHCP
Posts: 202
Joined: 30 Sep 2013, 10:59

Re: Pausing one script from another

08 Jun 2014, 08:08

Well this works for me, but it's identical to what you have....
tooltip.ahk

Code: Select all

#NoEnv
#SingleInstance force

a := 0
Loop, {
    a := a + 1
    ToolTip, %a%
}

Another script.

Code: Select all

f1::
detectHiddenWindows, On
SetTitleMatchMode, 2
PostMessage, 0x111, 65306,,, tooltip.ahk - AutoHotkey  ; Pause.
return 
If i press f1 the script is paused. If i press it again, the script is unpaused. So it doesn't explicitly pause the script.
The function i linked will explicitly pause the script. Lexikos previously posted this example.
vasili111
Posts: 747
Joined: 21 Jan 2014, 02:04
Location: Georgia

Re: Pausing one script from another

08 Jun 2014, 08:18

Thank you it works, but one problem:
I am launching tooltip.ahk and after pause.ahk .When I am launching pause.ahk the tooltip.ahk begans to count again from 1 (begans to exacute from begginning). How can I prevent it?
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
User avatar
trismarck
Posts: 506
Joined: 30 Sep 2013, 01:48
Location: Poland

Re: Pausing one script from another

08 Jun 2014, 09:15

I guess what happens here is when Run Script button is pressed in Scite upon launching Pause.ahk when Tooltip.ahk is already running, is that Scite restarts _all_ currently running scripts, which Scite has explicitly launched earlier.
vasili111
Posts: 747
Joined: 21 Jan 2014, 02:04
Location: Georgia

Re: Pausing one script from another

08 Jun 2014, 10:15

trismarck wrote:I guess what happens here is when Run Script button is pressed in Scite upon launching Pause.ahk when Tooltip.ahk is already running, is that Scite restarts _all_ currently running scripts, which Scite has explicitly launched earlier.
Thank you for help. You are right. This is bug of SciTE4AutoHotkey. When I run by double clicking files they are working as intended.
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
vasili111
Posts: 747
Joined: 21 Jan 2014, 02:04
Location: Georgia

Re: Pausing one script from another

08 Jun 2014, 10:27

RHCP wrote:Well this works for me, but it's identical to what you have....
tooltip.ahk

Code: Select all

#NoEnv
#SingleInstance force

a := 0
Loop, {
    a := a + 1
    ToolTip, %a%
}

Another script.

Code: Select all

f1::
detectHiddenWindows, On
SetTitleMatchMode, 2
PostMessage, 0x111, 65306,,, tooltip.ahk - AutoHotkey  ; Pause.
return 
If i press f1 the script is paused. If i press it again, the script is unpaused. So it doesn't explicitly pause the script.
The function i linked will explicitly pause the script. Lexikos previously posted this example.
I checked example from http://www.autohotkey.com/board/topic/1 ... ntry634811 it pauses and suspends the script. But is the difference between "pause" and "explicitly pause" ?
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
RHCP
Posts: 202
Joined: 30 Sep 2013, 10:59

Re: Pausing one script from another

08 Jun 2014, 11:13

Code: Select all

PostMessage, 0x111, 65306,,, tooltip.ahk - AutoHotkey
That code toggles the pause state. It doesn't necessarily pause the script.
If you call it on a script which is already paused, it will unpause it.
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: Pausing one script from another

15 Jun 2014, 21:04

As a workaround for the SciTE problem, use Quick run from the Tools menu (Ctrl+Shift+F5) to launch scripts. You won't see the output of the script (even if there is any), but you also won't have any problem launching multiple scripts.

You may need to update SciTE4AutoHotkey if you don't already have that tool; or you could add the equivalent tool by editing your user properties.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ht55cd3 and 262 guests