Hello World🙂
Closing winamp with NSIS is no problem:
Function CloseWinamp
Push $0
loop:
FindWindow $0 "Winamp v1.x"
IntCmp $0 0 done
SendMessage $0 "000E" 0 0
SendMessage $0 "0002" 0 0
SendMessage $0 "0082" 0 0
;or thisone SendMessage $0 "16" 0 0
Sleep 100
Goto loop
done:
Pop $0
FunctionEnd
But I would like to build a little effect with MS-Editor
Editor should start and Letters should be inserted automatically.
I tried thisone without succes, Notepad starts and nothing else.
Function CloseWinamp
Exec $WINDIR\Notepad.exe
Push $0
loop:
FindWindow $0 "" "Unbenannt - Editor"
IntCmp $0 0 done
SendMessage $0 "0100" 48 230001
;P WM_KEYDOWN nVirtKey:'H' cRepeat:1 ScanCode:23 fExtended:0 fAltDown:0 fRepeat:0 fUp:0 [wParam:00000048 lParam:00230001]
00000514
SendMessage $0 "0102" 68 230001
;P WM_CHAR chCharCode:'h' (104) cRepeat:1 ScanCode:23 fExtended:0 fAltDown:0 fRepeat:0 fUp:0 [wParam:00000068 lParam:00230001]
00000514
SendMessage $0 "0101" 48 C0230001
;P WM_KEYUP nVirtKey:'H' cRepeat:1 ScanCode:23 fExtended:0 fAltDown:0 fRepeat:1 fUp:1 [wParam:00000048 lParam:C0230001]
; SendMessage $0 "000E" 0 0
; SendMessage $0 "0002" 0 0
; SendMessage $0 "0082" 0 0
; SendMessage $0 "16" 0 0
Sleep 100
Goto loop
done:
Pop $0
FunctionEnd
How Can I realize this special effect?
Need "SendMessage"-Command Help
6 posts
You got two problems in your code:
1) You send the messages to the notepad window it self and not to its text edit sub-window.
2) All of your hex numbers are written as normal numbers.
You can also use WinMessages.nsh to make the code more readable, using ${WM_CLOSE} instead of 16 (0x10) for example.
1) You send the messages to the notepad window it self and not to its text edit sub-window.
2) All of your hex numbers are written as normal numbers.
You can also use WinMessages.nsh to make the code more readable, using ${WM_CLOSE} instead of 16 (0x10) for example.
Exec notepad.exe
findloop:
Sleep 500
FindWindow $0 "Notepad"
StrCmp $0 0 findloop
FindWindow $1 "Edit" "" $0
SendMessage $1 ${WM_CHAR} 0x68 0x230001
MessageBox MB_OK "Click OK to close Notepad"
SendMessage $0 ${WM_CLOSE} 0 0 I didn't use WM_KEYDOWN and WM_KEYUP because:The WM_CHAR message is posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function. The WM_CHAR message contains the character code of the key that was pressed.
Problems to run "Compile with bz2"
I put yours Into this:
I get following errormessage:
2 warnings:
unknown variable "{WM_CHAR}" detected, ignoring
unknown variable "{WM_CLOSE}" detected, ignoring
After running the exe only editor starts, withoutany typed char and without closing editor.
Could you test it please?
What do you mean with unknown file:"WinMessages.nsh"?
I put yours Into this:
OutFile "Print text to editor.exe"
Name "Print text to editor"
;Caption "CD input Plug-in Changer Built by Borg_No.One"
SilentInstall "silent"
ShowInstDetails "hide"
DirShow "hide"
;InstallDir $PROGRAMFILES\Winamp
Function .onInit
FunctionEnd
Section DoItAll
Call CloseWinamp
SectionEnd
Function CloseWinamp
Exec $WINDIR\Notepad.exe
findloop:
Sleep 500
FindWindow $0 "Notepad"
StrCmp $0 0 findloop
FindWindow $1 "Edit" "" $0
SendMessage $1 ${WM_CHAR} 0x68 0x230001
MessageBox MB_OK "Click OK to close Notepad"
SendMessage $0 ${WM_CLOSE} 0 0
Pop $0
FunctionEnd And if I want to compile the whole with "Compile with Nsis/ Nsis+Bzip2,I get following errormessage:
2 warnings:
unknown variable "{WM_CHAR}" detected, ignoring
unknown variable "{WM_CLOSE}" detected, ignoring
After running the exe only editor starts, withoutany typed char and without closing editor.
Could you test it please?
What do you mean with unknown file:"WinMessages.nsh"?
I know what you mean with Winmessages.nsh
Hi
I put the content of winmessages into my nsi script file and it works great. Why does not the NSIS-compiler use Winmessages automatically?
Why are "Winmessages.nsh" and all other nsh files not mentioned in any documentation?
Hi
I put the content of winmessages into my nsi script file and it works great. Why does not the NSIS-compiler use Winmessages automatically?
Why are "Winmessages.nsh" and all other nsh files not mentioned in any documentation?
Hey World try this
;"SendMessage $2 ${WM_CHAR} 0x006E 0x310001
" should close the editor "click no-button", but it does not work, why????
;"SendMessage $2 ${WM_CHAR} 0x006E 0x310001
" should close the editor "click no-button", but it does not work, why????
FindWindow $2 "#3277" "Editor"
SendMessage $2 ${WM_CHAR} 0x006E 0x310001
SendMessage $0 ${WM_CLOSE} 0 0
Pop $0
FunctionEnd How can NSIS select "no" if Notepad ask me if I want to save changes?You can also use WinMessages.nsh to make the code more readable, using ${WM_CLOSE} instead of 16 (0x10) for example.Using it means including it like you did in your last code. NSIS doesn't automatically includes this file becuase not all users use it. Like you have probably noticed, you got those warnings because you didn't include it.
How can NSIS select "no" if Notepad ask me if I want to save changes?You can't. SendMessage will wait until notepad finishes processing it, and this will only happen when the user will click something. You can if you want use the latest CVS version and use SendMessage /TIMEOUT=1.
I have edited some of your posts because they were huge, please post only the relevant parts of your scripts or output instead of all of it at once. If you want to include a big script attach it.