Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pause and resume macro
#1
pause and restart macro from the point it was paused at.. is that possible. I just found a way to stop the macro and restart from the start.
#2
It is not possible to pause a thread (running macro) from outside in a safe way. A thread only can pause itself, ie wait for an event.
There are Windows API functions SuspendThread and ResumeThread, but sometimes they can be dangerous, for example QM cannot correctly end a suspended thread.
#3
Function ThreadPauseResume
Code:
Copy      Help
;/
function $threadName flags ;;flags: 0 pause, 1 resume

;Pauses (suspends) or resumes a QM thread.

;threadName - <help #IDP_THREADS>thread</help> name.
;;;This function pauses/resumes all threads of threadName.
;;;If "", pauses/resumes all macro threads (except self), but not function, menu etc threads.

;REMARKS
;Call this function from another thread.
;You must always resume paused threads. QM does not know about paused threads and cannot end them correctly.
;If you pause a thread several times (when it is already paused), you must resume it the same number of times (or more, it is safe). It will remain paused if you resume it just once.

;EXAMPLE
;ThreadPauseResume "Function293" 0
;mes "resume"
;ThreadPauseResume "Function293" 1


int h i n m=empty(threadName)
n=EnumQmThreads(0 0 0 threadName); if(!n) ret
ARRAY(QMTHREAD) a.create(n)
EnumQmThreads &a[0] n 0 threadName
for i 0 a.len
,if(a[i].threadid=GetCurrentThreadId) continue
,if m
,,QMITEM q; qmitem(a[i].qmitemid 0 q)
,,if(q.itype) continue
,h=a[i].threadhandle
,if(flags&1) ResumeThread h
,else SuspendThread h
#4
You said here that a new version will have pause/resume. when will that be?
  • viewtopic.php?t=7142

And also, for the meantime. how exactly do i insert this to my rep/loop macro, making scroll lock as a hotkey?
scroll lock on = pause
scroll lock off = resume

Thx!
#5
Quote:You said here that a new version will have pause/resume. when will that be?
Not soon.

--------

Macro rep loop macro
Code:
Copy      Help
int i
for i 0 100
,1
,out i

Function PauseResumeRepLoopMacro
Trigger J 0x1     Help - how to add the trigger to the macro
Code:
Copy      Help
int scrollLocked=ifk(J 1)
OnScreenDisplay iif(scrollLocked "Pause" "Resume")
ThreadPauseResume "rep loop macro" iif(scrollLocked 0 1)
The trigger is Scroll Lock, and "Eat" is unchecked.
#6
I was thinking about this today and here's my thoughts... is there a way to set a trigger Hotkey at the beginning of a long macro so that anytime it is pressed while a macro is running it will execute a function.  For example... 

Let's say I've got a long macro running and I want to pause it for a moment by pressing the F12 key.  When I do, it executes a function that just pops a msg box on the screen saying Macro Paused, Click OK to continue.  As long as that msg box is on the screen, the entire macro is effectively paused.  When the OK button is pressed on that msg box it will exit the function and return to where it left off.  Does that make sense?


Forum Jump:


Users browsing this thread: 2 Guest(s)