Old 5th March 2019, 07:44   #1
KnightRiderX
Junior Member
 
Join Date: Oct 2018
Posts: 6
Unhappy System Plug-in SetConsoleCursorPosition

Hello everyone.

I need to set console cursor position; I've read about NSIS System Plug-in, tried different cases but I still have no luck with passing COORD structure to function. I'm seeking for a help, thank you.

Test Example:

code:

; get console handle - everything is fine at that part; console attached and works
System::Call "kernel32::AttachConsole(i -1)i .r0"
StrCmp $0 0 end
System::Call "kernel32::GetStdHandle(i -11)i .r0"

; the problem is below
; create struct
System::Call "*(i 2, i 3) p.s"
Pop $8
System::Call "kernel32::SetConsoleCursorPosition(i r0, p r8)" ; first param works, but not second
System::Free $8



What is wrong there?

Regards, KR
KnightRiderX is offline   Reply With Quote
Old 5th March 2019, 08:24   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,097
COORD is not a pointer to a struct, it is two 16-bit numbers packed into a int32 so just use a plain "i" parameter. I believe one of our .nsh files has a MAKELONG macro you can use to build the packed number.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 5th March 2019, 12:58   #3
KnightRiderX
Junior Member
 
Join Date: Oct 2018
Posts: 6
Thank you. MAKELONG fixed my issue.
KnightRiderX is offline   Reply With Quote
Old 5th March 2019, 16:31   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,097
If the position is known at compile time you can also give it as a direct parameter.

Quote:
!include WinCore.nsh
Section
System::Call "kernel32::AttachConsole(i -1)i .r0"
StrCmp $0 0 end
System::Call "kernel32::GetStdHandle(i -11)p .r0"

${MAKELONG} $1 $2 2 3
System::Call "kernel32::SetConsoleCursorPosition(p r0, i r1)" ; From MAKELONG
IntFmt $1 "%#.8x" $1
DetailPrint $1

Sleep 2222

System::Call "kernel32::SetConsoleCursorPosition(p r0, i 0x00050003)" ; Packing as hex INT32 directly
SectionEnd
Not sure why you think you need to move the cursor though. Writing to stdout will never be perfect because NSIS is really a GUI app.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 11th March 2019, 18:06   #5
Nutzzz
Member
 
Join Date: May 2007
Location: Orange County, CA, U.S.A.
Posts: 58
Quote:
Originally Posted by Anders View Post
Writing to stdout will never be perfect because NSIS is really a GUI app.
I know you know this, Anders, but for KnightRiderX's edification, you can do a custom build of NSIS, adding the parameter "NSIS_CONFIG_LOG_STDOUT=yes" to your scons command.
Nutzzz is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
call, console, cursor, plugin, system

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