Old 24th April 2019, 13:13   #1
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 65
Post How to link a label to open web page in unelevated process

Hi guys!

I am trying add label to left-bottom at morden.exe-105:

CONTROL "", 2019, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE, 50, 201, 45, 10

My install is elevated process.
But it is not working.

Code:

PHP Code:
Unicode true
!include "MUI2.nsh"

Page Custom Page1
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_LANGUAGE English

Var /GLOBAL Arial8_Normal_U
Var /GLOBAL LB_Link

Function Page1
    CreateFont $Arial8_Normal_U 
'Arial' '8.25' '400' /UNDERLINE

    nsDialogs
::Create 1044
    Pop $R0
    
${If} $R0 == error
        Abort
    
${EndIf}

    
GetDlgItem $LB_Link $HWNDPARENT 2019

    SendMessage $LB_Link 
${WM_SETFONT$Arial8_Normal_U 0
    SendMessage $LB_Link 
${WM_SETTEXT'STR:Text-to-google'

    
SetCtlColors $LB_Link FE0000 transpanrent

    GetFunctionAddress $R0 GO_HOMEPAGE
    nsDialogs
::OnClick $LB_Link $R0

    nsDialogs
::Show
FunctionEnd

Function GO_HOMEPAGE
    ShellExec 
'open' 'http://google.com'
FunctionEnd

Section

SectionEnd 

Last edited by meoit; 24th April 2019 at 14:29.
meoit is online now   Reply With Quote
Old 24th April 2019, 14:10   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,052
Have you tried adding a MessageBox to GO_HOMEPAGE to make sure it is called correctly?

nsDialogs::OnClick might only work for nsDialogs created controls and it might not work for static controls. Also, nsDialogs has a link control you can use but it only works in a custom page.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 25th April 2019, 00:06   #3
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 65
MessageBox to GO_HOMEPAGE

It it show nothing. Maybe GetFunctionAddress can not get.
meoit is online now   Reply With Quote
Old 25th April 2019, 14:46   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,052
Then you can't use nsDialogs onClick handling for non-nsDialogs controls. There is a ButtonEvent plug-in on the wiki but I don't know if it works on static controls.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 25th April 2019, 23:08   #5
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 65
Thank Anders.

I tried ButtonEvent plug-in on Win10 x64, Static Label
Result, not working (but Button, working fine).
meoit is online now   Reply With Quote
Old 26th April 2019, 00:58   #6
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 333
Quote:
Originally Posted by meoit View Post
Thank Anders.

I tried ButtonEvent plug-in on Win10 x64, Static Label
Result, not working (but Button, working fine).


hello
try this:

HTML Code:
Unicode true 

!include "MUI2.nsh"

Page Custom Page1 
!insertmacro MUI_PAGE_COMPONENTS 
!insertmacro MUI_PAGE_DIRECTORY 
!insertmacro MUI_LANGUAGE English 

Var Arial8_Normal_U 
Var Link_WebSite 

Function Page1 

nsDialogs::Create 1044 
Pop $R0 
${If} $R0 == error 
    Abort 
${EndIf} 

${NSD_CreateLink} 50 201 85 16 "Text-to-google"
Pop $Link_WebSite
;------------
CreateFont $Arial8_Normal_U 'Arial' '9.25' '400' /UNDERLINE 
SendMessage $Link_WebSite ${WM_SETFONT} $Arial8_Normal_U 0 
;------------
${NSD_OnClick} $Link_WebSite GO_HOMEPAGE

nsDialogs::Show 
FunctionEnd 

Function GO_HOMEPAGE 
	ExecShell "open" "http://google.com" SW_SHOWNORMAL
FunctionEnd 

Section 

SectionEnd  
r2du-soft is offline   Reply With Quote
Old 27th April 2019, 20:12   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,052
Try this new plug-in.

with this code

PHP Code:
Unicode True
RequestExecutionLevel User
XPStyle On 
SysLink
PESubsysVer 5.1 
SysLink is XP+
BrandingText ""
Name "WndEvent test"
Caption "$(^Name)"
SubCaption 4 " "
Section
SectionEnd
Page InstFiles 
"" OnInstFilesShow
!include nsDialogs.nsh


Function OnInstFilesShow
FindWindow 
$"#32770" "" $hWndParent
StrCpy 
$""
loopFindWindow $"" "" $$0
ShowWindow 
$0 0 Hide controls we don't care about
IntPtrCmpU 0 $0 "" loop loop

WndEvent::CreateWindow "SysLink" '
Hello <A HREF="http://example.com">World</A>' ${WS_CHILD}|${WS_VISIBLE} ${WS_EX_TRANSPARENT} 0u 0u 100u 12u "PAGE"
Var /Global syslink
Pop $syslink
GetFunctionAddress $1 SysLinkHandler
WndEvent::AddHandler "NOTIFY" "$syslink>PARENT" $1

WndEvent::CreateWindow "SysLink" '
<A HREF="http://example.net">Link2</A>' ${WS_CHILD}|${WS_VISIBLE} 0 65u 145u 100u 12u $hWndParent
Var /Global syslink2
Pop $syslink2
GetFunctionAddress $1 SysLinkHandler
WndEvent::AddHandler "NOTIFY" "$hWndParent" $1
FunctionEnd

!define /IfNDef NM_CLICK -2
!define /IfNDef NM_RETURN -4
Function SysLinkHandler
${If} $2 = ${NM_CLICK}
${OrIf} $2 = ${NM_RETURN}
    ${If} $syslink Z= $3
    ${OrIf} $syslink2 Z= $3
        ExecShell "" "http://example.com"
    ${EndIf}
${EndIf}
FunctionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 13th May 2019, 13:51   #8
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 65
Thanks Anders.

I see message:

Warning: This file type may contain malicious code. By executing it, your system may be compromised.

What can I do?.
meoit is online now   Reply With Quote
Old 13th May 2019, 14:31   #9
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,052
Quote:
Originally Posted by meoit View Post
I see message:

Warning: This file type may contain malicious code. By executing it, your system may be compromised.

What can I do?.
I assume you are talking about anti-virus? Upload to VirusTotal and you should see that it is mostly clean. Then uninstall that anti-virus application...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 16th May 2019, 12:00   #10
T.Slappy
Major Dude
 
T.Slappy's Avatar
 
Join Date: Jan 2006
Location: Slovakia
Posts: 526
Send a message via ICQ to T.Slappy
What about using the Linker plug-in? https://nsis.sourceforge.io/Linker_plug-in

It is designed exactly for this purpose and it is really easy to use...

Cool looking installer with custom design: www.graphical-installer.com
I offer NSIS scripting, C/C++/C#/Delphi programming: www.unsigned.sk
Develop NSIS projects in Visual Studio 2005-2019: www.visual-installer.com
or RAD Studio 2009, 2010, XE-10.3 Rio: www.rad-installer.com
T.Slappy is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast 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