Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 2nd October 2002, 02:27   #1
Borg Number One
Member
 
Join Date: Sep 2002
Posts: 62
Need "SendMessage"-Command Help

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?
Borg Number One is offline   Reply With Quote
Old 2nd October 2002, 12:01   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,338
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.

PHP Code:
Exec notepad.exe

findloop
:
    
Sleep 500
    FindWindow 
$"Notepad"
    
StrCmp $0 0 findloop

FindWindow 
$"Edit" "" $0

SendMessage 
$${WM_CHAR0x68 0x230001

MessageBox MB_OK 
"Click OK to close Notepad"

SendMessage $${WM_CLOSE0 0 
I didn't use WM_KEYDOWN and WM_KEYUP because:
Quote:
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 2nd October 2002, 22:25   #3
Borg Number One
Member
 
Join Date: Sep 2002
Posts: 62
Problems to run "Compile with bz2"

I put yours Into this:

PHP Code:
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 $PROGRAMFILESWinamp

Function .onInit

FunctionEnd

Section DoItAll
    Call CloseWinamp
SectionEnd

Function CloseWinamp
Exec $WINDIRNotepad
.exe

findloop
:
    
Sleep 500
    FindWindow 
$"Notepad"
    
StrCmp $0 0 findloop

FindWindow 
$"Edit" "" $0

SendMessage 
$${WM_CHAR0x68 0x230001

MessageBox MB_OK 
"Click OK to close Notepad"

SendMessage $${WM_CLOSE0 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"?
Borg Number One is offline   Reply With Quote
Old 2nd October 2002, 22:41   #4
Borg Number One
Member
 
Join Date: Sep 2002
Posts: 62
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?
Borg Number One is offline   Reply With Quote
Old 3rd October 2002, 02:00   #5
Borg Number One
Member
 
Join Date: Sep 2002
Posts: 62
Hey World try this

;"SendMessage $2 ${WM_CHAR} 0x006E 0x310001
" should close the editor "click no-button", but it does not work, why????
PHP Code:
FindWindow $"#3277" "Editor"
SendMessage $${WM_CHAR0x006E    0x310001


SendMessage 
$${WM_CLOSE0 0
Pop 
$0
FunctionEnd 
How can NSIS select "no" if Notepad ask me if I want to save changes?
Attached Files
File Type: wsz chars2.zip.wsz (656 Bytes, 242 views)
Borg Number One is offline   Reply With Quote
Old 3rd October 2002, 10:09   #6
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,338
Quote:
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.

Quote:
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump