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.
Reply
#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.
Reply
#3
Function ThreadPauseResume
Code:
Select All      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
Reply
#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!
Reply
#5
Quote:You said here that a new version will have pause/resume. when will that be?
Not soon.

--------

Macro rep loop macro
Code:
Select All      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:
Select All      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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)