FCT plug-in: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
fct::fct [/NOUNLOAD] WINDOW_CLASS WINDOW_TITLE [/ASYNC] [/PART] [/TIMEOUT=xxx] [/END] | fct::fct [/NOUNLOAD] WINDOW_CLASS WINDOW_TITLE [/ASYNC] [/PART] [/TIMEOUT=xxx] [/END] | ||
</highlight-nsis> | </highlight-nsis> | ||
: Searchs for all windows with predefined 'class' and 'title' (or it's part). Use "" if class or title are not defined. In | : Searchs for all windows with predefined 'class' and 'title' (or it's part). Use "" if class or title are not defined. In async mode plug-in returns running thread handle, in the sync one - still alive applications count (i.e. how many application not exited after WM_CLOSE and were not terminated using TerminateProcess() ). I.e. 0 is OK. Use 'wait' with handle as parameter to get final result for this thread. | ||
; ASYNC | ; ASYNC | ||
: Not waits for process exit. Use 'wait' call if you want to get result | : Not waits for process exit. Use 'wait' call if you want to get result | ||
Line 31: | Line 31: | ||
Sync execution: | Sync execution: | ||
<highlight-nsis> | <highlight-nsis> | ||
fct::fct '${WND_CLASS}' '${WND_TITLE}' /timeout=2000 /part '/question=$(termMsg)' | |||
Pop $0 | |||
MessageBox MB_OK "Terminated count=$0" | |||
</highlight-nsis> | </highlight-nsis> | ||
Async execution: | Async execution: | ||
<highlight-nsis> | <highlight-nsis> | ||
fct::fct /nounload '${WND_CLASS}' '${WND_TITLE}' /async /timeout=2000 /part '/question=$(termMsg)' | |||
; | ; You can place some code here. We skipped Pop and Push for hThread - it just sits in the stack. | ||
fct::wait | |||
Pop $0 | |||
MessageBox MB_OK "Terminated count=$0" | |||
</highlight-nsis> | </highlight-nsis> | ||
[[Category:Plugins]] | [[Category:Plugins]] |
Revision as of 20:10, 19 November 2005
Author: Takhir (talk, contrib) |
Links
Download:
Fct.zip (8 KB)
Description
Plug-in terminates application in 2 steps - first send WM_CLOSE to it's main window, then (if still alive) terminates application. Has sync/async (background) modes, async is good for slowly exiting applications and multithreading. 2 kB only in zip, so if you need system calls for correct process termination only, this may replace System plug-in with less size and simple script code. Final package size decreases too (4 kB).
Syntax
"fct" DLL function
fct::fct [/NOUNLOAD] WINDOW_CLASS WINDOW_TITLE [/ASYNC] [/PART] [/TIMEOUT=xxx] [/END]
- Searchs for all windows with predefined 'class' and 'title' (or it's part). Use "" if class or title are not defined. In async mode plug-in returns running thread handle, in the sync one - still alive applications count (i.e. how many application not exited after WM_CLOSE and were not terminated using TerminateProcess() ). I.e. 0 is OK. Use 'wait' with handle as parameter to get final result for this thread.
- ASYNC
- Not waits for process exit. Use 'wait' call if you want to get result
- TIMEOUT
- timeout for SendMessage() and WaitForSingleObject(). Default is 1000 (ms).
- PART
- WINDOW_TITLE is only a part of window title (caption)
"wait" DLL function
ExecDos::wait handle
- Waits for process exit.
- handle
- Control thread handle returned by 'fct' call in the /ASYNC mode.
Example
Sync execution:
fct::fct '${WND_CLASS}' '${WND_TITLE}' /timeout=2000 /part '/question=$(termMsg)' Pop $0 MessageBox MB_OK "Terminated count=$0"
Async execution:
fct::fct /nounload '${WND_CLASS}' '${WND_TITLE}' /async /timeout=2000 /part '/question=$(termMsg)' ; You can place some code here. We skipped Pop and Push for hThread - it just sits in the stack. fct::wait Pop $0 MessageBox MB_OK "Terminated count=$0"