Old 29th January 2018, 11:36   #1
Coby
Junior Member
 
Join Date: Feb 2016
Posts: 48
How can I run a file?

I use an HTML file in NSIS how can I execute a file when I click on a link or a button.

PHP Code:
# Details

Name "Html Test"
OutFile "Html Test.exe"
InstallDir "$TEMP"

# Compress 

SetCompressor /SOLID /FINAL lzma

# RUN

RequestExecutionLevel user

# HIDE # SHOW

ShowInstDetails hide
ShowInstDetails nevershow
XPStyle on

# INCLUDES

!include "MUI2.nsh"
!include "WinCore.nsh"
!include "nsDialogs.nsh"
!include "LogicLib.nsh"
!include "WinMessages.nsh"
!include "FileFunc.nsh"

# Icon & Stye

BrandingText /TRIMRIGHT " "

# Page

!define MUI_CUSTOMFUNCTION_GUIINIT "onGuiInit"
Page Custom "WelcomePageShow"
Page instfiles ""

# ENGLISH

!insertmacro MUI_LANGUAGE "English"

# onInit

Function .onInit
  CreateDirectory 
"$EXEDIR"
  
FileOpen $"$EXEDIR\Index.html" w
  FileWrite 
$"<html>"
  
FileWriteByte $"10"
  
FileWriteByte $"13"
  
FileWrite $'<body link="#0C6E97">'
  
FileWriteByte $"10"
  
FileWriteByte $"13"
  
FileWrite $'<a href="">Click My Link</a>'
  
FileWriteByte $"10"
  
FileWriteByte $"13"
  
FileWrite $"</body>"
  
FileWriteByte $"10"
  
FileWriteByte $"13"
  
FileWrite $"</html>"
  
FileClose $0
FunctionEnd

Function "onGuiInit"
  
# System::Call user32::SetWindowLong(i$HWNDPARENT,i-16, 0x9480084C) i.R0
  
GetDlgItem $R0 $HWNDPARENT 1034
  ShowWindow $R0 
${SW_HIDE}
  
GetDlgItem $R0 $HWNDPARENT 1035
  ShowWindow $R0 
${SW_HIDE}
  
GetDlgItem $R0 $HWNDPARENT 1036
  ShowWindow $R0 
${SW_HIDE}
  
GetDlgItem $R0 $HWNDPARENT 1037
  ShowWindow $R0 
${SW_HIDE}
  
GetDlgItem $R0 $HWNDPARENT 1038
  ShowWindow $R0 
${SW_HIDE}
  
GetDlgItem $R0 $HWNDPARENT 1039
  ShowWindow $R0 
${SW_HIDE}
  
GetDlgItem $R0 $HWNDPARENT 1256
  ShowWindow $R0 
${SW_HIDE}
  
GetDlgItem $R0 $HWNDPARENT 1028
  ShowWindow $R0 
${SW_HIDE}

  
System::Call user32::GetSystemMetrics(i0)i.r1
  System
::Call user32::GetSystemMetrics(i1)i.r2
  IntOp 
$$646
  IntOp 
$$2
  IntOp 
$$401
  IntOp 
$$2
  System
::Call user32::MoveWindow(i$HWNDPARENT,i$1,i$2,i646,i401,1)
  
SetCtlColors $HWNDPARENT "0x666666" "0xFFFFFF"
FunctionEnd

# WELCOME 

Function "WelcomePageShow"

  
# ...:: variables ::... #
 
  
var /GLOBAL DIALOG
  
var /GLOBAL RTF_TOOLBOX

  GetDlgItem 
$0 $HWNDPARENT 1
  ShowWindow 
$${SW_HIDE}
  
GetDlgItem $0 $HWNDPARENT 2
  ShowWindow 
$${SW_HIDE}
  
GetDlgItem $0 $HWNDPARENT 3
  ShowWindow 
$${SW_HIDE}
  
GetDlgItem $0 $HWNDPARENT 1990
  ShowWindow 
$${SW_HIDE}
  
GetDlgItem $0 $HWNDPARENT 1991
  ShowWindow 
$${SW_HIDE}
  
GetDlgItem $0 $HWNDPARENT 1992
  ShowWindow 
$${SW_HIDE}

  
System::Call "user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 646,i 401,i 0x16)"
  
nsDialogs::Create /NOUNLOAD 1044
  Pop $DIALOG
  
${If} $DIALOG == error
   Abort
  
${EndIf}
  
System::Call "user32::MoveWindow(i$DIALOG,i0,i0,i 646,i 401,i0)"

  
SetCtlColors $DIALOG "0x666666" "0xFFFFFF"

  
SendMessage $HWNDPARENT ${WM_SETTEXT"STR:$(^Name)"

  
# Toolbox #

  
System::Call `kernel32::GetModuleHandle(i 0) i.R3`
  
System::Call 'User32::CreateWindowEx(i0,t"STATIC",i0,i0x50020100,i10,i0,i656,i400,i$Dialog,i1130,i0,i0)i.R1'
  
Strcpy $RTF_TOOLBOX $R1
  WebCtrl
::ShowWebInCtrl $RTF_TOOLBOX "$EXEDIR\index.html"
  
System::Call "user32::SetDlgItemText(i$HWNDPARENT,i1,ts)" "ÎŇ˝ÓĘÜ(&I)"

  
nsDialogs::Show

FunctionEnd

Section 

SectionEnd

Function .OnGuiEnd
FunctionEnd 
Coby is offline   Reply With Quote
Old 29th January 2018, 11:49   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,926
What have you tried so far?

Also, how is colors and hidden controls related to this? I have told you so many times, post MINIMAL examples.

IntOp $PostCount $PostCount + 1
Anders 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