hey all i need some nsis help.
I found this code on the nsis site and could u guys please explain it to me
thanks
!define APP_NAME find_close_terminate !define WND_CLASS "Notepad" !define WND_TITLE "Untitled - Notepad" !define TO_MS 2000 !define SYNC_TERM 0x00100001 !include WinMessages.nsh Name "${APP_NAME}" OutFile "${APP_NAME}.exe" LangString termMsg ${LANG_ENGLISH} "Installer cannot stop running ${WND_TITLE}.$\nDo you want to terminate process?" LangString stopMsg ${LANG_ENGLISH} "Stopping ${WND_TITLE} Application" !macro TerminateApp Push $0 ; window handle Push $1 Push $2 ; process handle DetailPrint "$(stopMsg)" FindWindow $0 '${WND_CLASS}' '' IntCmp $0 0 done System::Call 'user32.dll::GetWindowThreadProcessId(i r0, *i .r1) i .r2' System::Call 'kernel32.dll::OpenProcess(i ${SYNC_TERM}, i 0, i r1) i .r2' SendMessage $0 ${WM_CLOSE} 0 0 /TIMEOUT=${TO_MS} System::Call 'kernel32.dll::WaitForSingleObject(i r2, i ${TO_MS}) i .r1' IntCmp $1 0 close MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION "$(termMsg)" /SD IDYES IDYES terminate IDNO close System::Call 'kernel32.dll::CloseHandle(i r2) i .r1' Quit terminate: System::Call 'kernel32.dll::TerminateProcess(i r2, i 0) i .r1' close: System::Call 'kernel32.dll::CloseHandle(i r2) i .r1' done: Pop $2 Pop $1 Pop $0 !macroend Section "Dummy Section" SecDummy !insertmacro TerminateApp SectionEnd
any help would be great
half of it but it seems to be a cool App. Maybe wraithdu "The NSIS Explanaitor" can clarify
"What about Love?" - "Overrated. Biochemically no different than eating large quantities of chocolate." - Al Pacino in The Devils Advocate
yea it soon will be,
i am working on an app but i dont understand this code, i mean i know what it does but cant piece it apart. so i need some help
Please search before posting. ~Thanks
it is a script that checks if notepad is running, then closes it if it is...
Insert original signature here with Greasemonkey Script.
Techniques that would be handy in an eject script...
MC
can't wait for the autoejectscript thingy
Insert original signature here with Greasemonkey Script.
This is a macro that tries to close a process in a couple different ways.
First it searches the specified window CLASS, not title in this case, although a specific window title can be specified in the FindWindow command in addition to the class if you want/need to.
That search returns the window HWND (handle) if it exists, if not it exits (window wasn't found). Then it uses the window handle to get the process handle.
First it tries to close the process by sending the window the ${WM_CLOSE} window message (like clicking the X button in the corner of a window). It waits the specified timeout period, and if it fails asks if you want to terminate the app. If so, it tries to terminate the process directly (like using Task Manager to kill an app).
Check the bottom of this page for the other FindWindow options -
http://nsis.sourceforge.net/Find_and_Close_or_Terminate
see here is what i want to do:
create a app like eject script that uses gets all of the apps on the drive, then closes them, if it cannot then it will ask if you want to terminate them. After all of that is done i found an open source program that will eject the drive for you. And i want the whole app to be in the portableapps format.
last question, can i use autoit and still hav the app be considered in the portableapps format?
Please search before posting. ~Thanks
I should think so. There's nothing that demands launchers are written in NSIS.
By the way, there are process plugins for NSIS, and builtin commands in AutoIt3 for controling processes. You don't *have* to use that script above.
they mostly dealt with terminating the process not closing them. If i make a "ejectscript" like app i don't want people to lose any changes/stuff that the app does on close.
Edit: found one!!!
http://nsis.sourceforge.net/FCT_plug-in
question though:
also is there a way you could find a class name using nsis code?
Please search before posting. ~Thanks
I'm sure you can find the class from, say a window title or process name, but you'd need to use the System plugin and WinAPI calls I think. But I don't know how to do that