NSIS如何通过在文本框中插入连字符或添加文本框来复制和粘贴文本,以fieldnum分隔
NSIS How to copy and paste text by inserting hyphens or adding text boxes in a text box, separated by fieldnum
使用 NSIS 文本框 UI 方便用户向程序传递参数时出现问题。
在C#Winform中可以实现,但不熟悉在NSIS中如何使用
我想通过以下两种方式之一获得帮助。
1.一:
I want to create a single Text box and separate the text I want to paste into a Text box with hyphens.
示例:
(1) The value you want to put into the text box : 12341234123412341234(
Total 19 ~ 20 digits)
(2) Copy 12341234123412341234(
Total 19 ~ 20 digits)
(3) Insert to Text box
1234-1234-1234-1234-1234 (
Autocomplete hyphenation in 4-digit units)
(4)
Actual parameter value: 12341234123412341234
Visible values in UI: 1234-1234-1234-1234-1234
图片说明:
Assuming the cmd input window ...
Text Box to show in real UI
2。两个
(1) Copy 12341234123412341234
(2) Paste in first box of Text box
4 digits autocomplete
NSIS Text Box sample
目前我的代码正在尝试方法 2。
我的代码:
Function Test
!insertmacro MUI_INSTALLOPTIONS_READ [=10=] "pageInputLicenseInfo.ini" "Settings" "State"
${If} [=10=] == 9 # btton
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "pageInputLicenseInfo.ini" "Field 1" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "pageInputLicenseInfo.ini" "Field 2" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R2 "pageInputLicenseInfo.ini" "Field 3" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R3 "pageInputLicenseInfo.ini" "Field 4" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R4 "pageInputLicenseInfo.ini" "Field 5" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R5 "pageInputLicenseInfo.ini" "Field 6" "State"
nsExec::ExecToStack '$INSTDIR\ParamterTestConsole.exe ${PRODUCT_NAME} $R0 $R1$R2$R3$R4$R5'
Pop ; Exit code
Pop ; console OUTPUT
Blah blah..........
FunctionEnd
NSIS INI 文件:
; Ini file generated by the HM NIS Edit IO designer.
[Settings]
NumFields=14
Title=test
[Field 1]
Type=Text
Text=1
Left=29
Right=275
Top=46
Bottom=57
[Field 2]
Type=Text
Text=123
Left=30
Right=60
Top=67
Bottom=78
MaxLen=4
[Field 3]
Type=Text
Text=123
Left=74
Right=103
Top=67
Bottom=78
MaxLen=4
[Field 4]
Type=Text
Text=123
Left=121
Right=149
Top=67
Bottom=78
MaxLen=4
[Field 5]
Type=Text
Text=123
Left=164
Right=193
Top=67
Bottom=78
MaxLen=4
[Field 6]
Type=Text
Text=123
Left=206
Right=236
Top=67
Bottom=78
[Field 7]
Type=Label
Text=IP
Left=1
Right=15
Top=48
Bottom=56
[Field 8]
Type=Label
Text=Key
Left=1
Right=20
Top=70
Bottom=78
[Field 9]
Type=Button
Text=enter
Flags=NOTIFY
Left=225
Right=275
Top=92
Bottom=105
[Field 10]
Type=Label
Text=※
Enter four digits.
Left=0
Right=152
Top=26
Bottom=43
[Field 11]
Type=Label
Text=-
Left=154
Right=160
Top=68
Bottom=80
[Field 12]
Type=Label
Text=-
Left=199
Right=205
Top=68
Bottom=76
[Field 13]
Type=Label
Text=-
Left=110
Right=116
Top=68
Bottom=76
[Field 14]
Type=Label
Text=-
Left=64
Right=70
Top=68
Bottom=76
PassDialog plug-in 有一个串行对话框,当一个编辑字段被填充时,它会自动移动到下一个编辑字段。我不认为它支持粘贴,但你也许可以要求作者添加此功能。
我认为 InstallOptions 不支持编辑框上的通知回调,但 nsDialogs 支持,您可以用它创建经典的串行输入对话框:
Var Serial
!include LogicLib.nsh
!include WinMessages.nsh
!include nsDialogs.nsh
Page Custom MyDialogCreate MyDialogLeave
Page InstFiles
Function onSerialEditChange
Pop $R0
SendMessage $R0 ${EM_GETLIMITTEXT} 0 0 $R1
SendMessage $R0 ${WM_GETTEXTLENGTH} 0 0 $R2
${If} $R2 >= $R1
SendMessage $hWndParent ${WM_NEXTDLGCTL} 0 0 ; Tab to next
${ElseIf} $R2 = 0
SendMessage $hWndParent ${WM_NEXTDLGCTL} 1 0 ; Tab to previous
${EndIf}
FunctionEnd
Function MyDialogCreate
nsDialogs::Create 1018
Pop [=10=]
!macro CreateSerialEdit x var limit
${NSD_CreateText} ${x} 10u 30u 12u ""
Pop ${var}
${NSD_OnChange} ${var} onSerialEditChange
${NSD_Edit_SetTextLimit} ${var} ${limit}
${NSD_AddStyle} ${var} ${ES_NUMBER} ; Limit to numbers
!macroend
!insertmacro CreateSerialEdit 10u 4
!insertmacro CreateSerialEdit 50u 4
!insertmacro CreateSerialEdit 90u 4
SendMessage $hWndParent ${WM_NEXTDLGCTL} 1
nsDialogs::Show
FunctionEnd
Function MyDialogLeave
StrCpy $Serial ""
${NSD_GetText} [=10=]
StrCpy $Serial "$Serial[=10=]"
${NSD_GetText} [=10=]
StrCpy $Serial "$Serial[=10=]"
${NSD_GetText} [=10=]
StrCpy $Serial "$Serial[=10=]"
StrLen [=10=] $Serial
${If} [=10=] < 12
MessageBox mb_iconstop "Enter a valid serial!"
Abort
${EndIf}
FunctionEnd
Section
MessageBox mb_ok Serial=$Serial
SectionEnd
如果您绝对需要具有您所描述的确切行为,那么您需要创建一个自定义 plug-in 子类编辑框...
使用 NSIS 文本框 UI 方便用户向程序传递参数时出现问题。
在C#Winform中可以实现,但不熟悉在NSIS中如何使用
我想通过以下两种方式之一获得帮助。
1.一:
I want to create a single Text box and separate the text I want to paste into a Text box with hyphens.
示例:
(1) The value you want to put into the text box : 12341234123412341234( Total 19 ~ 20 digits)
(2) Copy 12341234123412341234( Total 19 ~ 20 digits)
(3) Insert to Text box 1234-1234-1234-1234-1234 ( Autocomplete hyphenation in 4-digit units)
(4) Actual parameter value: 12341234123412341234
Visible values in UI: 1234-1234-1234-1234-1234
图片说明:
Assuming the cmd input window ...
Text Box to show in real UI
2。两个
(1) Copy 12341234123412341234
(2) Paste in first box of Text box
4 digits autocomplete
NSIS Text Box sample
目前我的代码正在尝试方法 2。
我的代码:
Function Test
!insertmacro MUI_INSTALLOPTIONS_READ [=10=] "pageInputLicenseInfo.ini" "Settings" "State"
${If} [=10=] == 9 # btton
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "pageInputLicenseInfo.ini" "Field 1" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "pageInputLicenseInfo.ini" "Field 2" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R2 "pageInputLicenseInfo.ini" "Field 3" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R3 "pageInputLicenseInfo.ini" "Field 4" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R4 "pageInputLicenseInfo.ini" "Field 5" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R5 "pageInputLicenseInfo.ini" "Field 6" "State"
nsExec::ExecToStack '$INSTDIR\ParamterTestConsole.exe ${PRODUCT_NAME} $R0 $R1$R2$R3$R4$R5'
Pop ; Exit code
Pop ; console OUTPUT
Blah blah..........
FunctionEnd
NSIS INI 文件:
; Ini file generated by the HM NIS Edit IO designer.
[Settings]
NumFields=14
Title=test
[Field 1]
Type=Text
Text=1
Left=29
Right=275
Top=46
Bottom=57
[Field 2]
Type=Text
Text=123
Left=30
Right=60
Top=67
Bottom=78
MaxLen=4
[Field 3]
Type=Text
Text=123
Left=74
Right=103
Top=67
Bottom=78
MaxLen=4
[Field 4]
Type=Text
Text=123
Left=121
Right=149
Top=67
Bottom=78
MaxLen=4
[Field 5]
Type=Text
Text=123
Left=164
Right=193
Top=67
Bottom=78
MaxLen=4
[Field 6]
Type=Text
Text=123
Left=206
Right=236
Top=67
Bottom=78
[Field 7]
Type=Label
Text=IP
Left=1
Right=15
Top=48
Bottom=56
[Field 8]
Type=Label
Text=Key
Left=1
Right=20
Top=70
Bottom=78
[Field 9]
Type=Button
Text=enter
Flags=NOTIFY
Left=225
Right=275
Top=92
Bottom=105
[Field 10]
Type=Label
Text=※
Enter four digits.
Left=0
Right=152
Top=26
Bottom=43
[Field 11]
Type=Label
Text=-
Left=154
Right=160
Top=68
Bottom=80
[Field 12]
Type=Label
Text=-
Left=199
Right=205
Top=68
Bottom=76
[Field 13]
Type=Label
Text=-
Left=110
Right=116
Top=68
Bottom=76
[Field 14]
Type=Label
Text=-
Left=64
Right=70
Top=68
Bottom=76
PassDialog plug-in 有一个串行对话框,当一个编辑字段被填充时,它会自动移动到下一个编辑字段。我不认为它支持粘贴,但你也许可以要求作者添加此功能。
我认为 InstallOptions 不支持编辑框上的通知回调,但 nsDialogs 支持,您可以用它创建经典的串行输入对话框:
Var Serial
!include LogicLib.nsh
!include WinMessages.nsh
!include nsDialogs.nsh
Page Custom MyDialogCreate MyDialogLeave
Page InstFiles
Function onSerialEditChange
Pop $R0
SendMessage $R0 ${EM_GETLIMITTEXT} 0 0 $R1
SendMessage $R0 ${WM_GETTEXTLENGTH} 0 0 $R2
${If} $R2 >= $R1
SendMessage $hWndParent ${WM_NEXTDLGCTL} 0 0 ; Tab to next
${ElseIf} $R2 = 0
SendMessage $hWndParent ${WM_NEXTDLGCTL} 1 0 ; Tab to previous
${EndIf}
FunctionEnd
Function MyDialogCreate
nsDialogs::Create 1018
Pop [=10=]
!macro CreateSerialEdit x var limit
${NSD_CreateText} ${x} 10u 30u 12u ""
Pop ${var}
${NSD_OnChange} ${var} onSerialEditChange
${NSD_Edit_SetTextLimit} ${var} ${limit}
${NSD_AddStyle} ${var} ${ES_NUMBER} ; Limit to numbers
!macroend
!insertmacro CreateSerialEdit 10u 4
!insertmacro CreateSerialEdit 50u 4
!insertmacro CreateSerialEdit 90u 4
SendMessage $hWndParent ${WM_NEXTDLGCTL} 1
nsDialogs::Show
FunctionEnd
Function MyDialogLeave
StrCpy $Serial ""
${NSD_GetText} [=10=]
StrCpy $Serial "$Serial[=10=]"
${NSD_GetText} [=10=]
StrCpy $Serial "$Serial[=10=]"
${NSD_GetText} [=10=]
StrCpy $Serial "$Serial[=10=]"
StrLen [=10=] $Serial
${If} [=10=] < 12
MessageBox mb_iconstop "Enter a valid serial!"
Abort
${EndIf}
FunctionEnd
Section
MessageBox mb_ok Serial=$Serial
SectionEnd
如果您绝对需要具有您所描述的确切行为,那么您需要创建一个自定义 plug-in 子类编辑框...