找回密码
 加入
搜索
查看: 11136|回复: 14

[AU3基础] 怎么在msgbox中添加超链接

 火.. [复制链接]
发表于 2012-8-25 12:00:15 | 显示全部楼层 |阅读模式
本帖最后由 虎虎虎 于 2012-9-8 20:27 编辑

如题:
如果想实现msgbox中添加超链接,除了自制GUI,还有没有其他方法,主要是想实现类似msgbox返回值及相关提示。

我在别的论坛,看到NSIS源码不知能否参考一下。
; 定义 ResHacker 的路径,请自行修改
 !define ResHacker "${NSISDIR}\Resource Hacker\ResHacker.exe"
 !define exehead "$%TEMP%\exehead.tmp"
 !packhdr "${exehead}" '"${ResHacker}" -add "${exehead}","${exehead}",Dlg.res,,,'
 
 !include "MUI2.nsh"
 
 !insertmacro MUI_PAGE_INSTFILES
 !insertmacro MUI_LANGUAGE "SimpChinese"
 
 OutFile "SysLink_MsgBox.exe"
 Name "${__FILE__}"
 
 !define NM_CLICK                -2
 !define NM_RETURN               -4
 !define SC_CLOSE                        0xF060
 
 Section Test
 Call DialogBox
 SectionEnd
 
 Function DialogBox
         System::Store "s"
         System::Get "(i.r1, i.r2, i.r3, i.r4)iss"
         Pop $0
         System::Call Kernel32::GetModuleHandle(i)i.s
         System::Call User32::DialogBoxParam(is,i112,i$HWNDPARENT,kr0,i0)
         Call DialogBoxCallback
         System::Free $0
         System::Store "l"
 FunctionEnd
 
 Function DialogBoxCallback
 ${Do}
         Pop $5
         StrCpy $5 $5 8
         ${IfThen} $5 != "callback" ${|} ${ExitDo} ${|}
         ${If} $2 = ${WM_INITDIALOG}
             Var /GLOBAL hLink
             GetDlgItem $hLink $1 1203
             System::Call Shell32::ExtractIcon(i,t"user32.dll",i4)i.R0
             GetDlgItem $5 $1 1201
             SendMessage $5 ${STM_SETIMAGE} ${IMAGE_ICON} $R0
             System::Call User32::SetWindowText(ir1,ts) "自定义 MessageBox"
             System::Call User32::SetDlgItemText(ir1,i1202,ts) "Hello World!"
                 System::Call winmm::PlaySound(i0x2A53,i,i0x110001)
         ${ElseIf} $2 = ${WM_COMMAND}
                 ${If} $3 = 1
                         System::Call User32::EndDialog(ir1,ir3)
                 ${EndIf}
         ${ElseIf} $2 = ${WM_SYSCOMMAND}
             ${If} $3 = ${SC_CLOSE}
                         System::Call User32::EndDialog(ir1,ir3)
             ${EndIf}
         ${ElseIf} $2 = ${WM_NOTIFY}
             System::Call "*$4(i.r5,i,i.r6)"
             ${If} $6 = ${NM_CLICK}
             ${OrIf} $6 = ${NM_RETURN}
                     ${If} $5 = $hLink
                                 System::Call Shell32::ShellExecute(i,t"open",t"http://www.dreams8.com",i,i,i${SW_SHOW})
                         ${EndIf}
             ${EndIf}
         ${EndIf}
         System::Call "$0" 0
 ${Loop}
         System::Call User32::DestroyIcon(iR0)
 FunctionEnd
发表于 2012-8-25 12:09:17 | 显示全部楼层
新的autoit3udf里有一套syslink函数,大概可以,但实际上还是一个新界面
发表于 2012-8-25 16:24:54 | 显示全部楼层
再整个窗口吧...
发表于 2012-8-25 16:33:52 | 显示全部楼层
好像有UDF 在官方去找找
 楼主| 发表于 2012-8-25 16:39:45 | 显示全部楼层
回复 4# chinafla

不是不想查,是因为我对英文不感冒。。
发表于 2012-8-25 18:19:01 | 显示全部楼层
回复 4# chinafla


    UDF还是通用自绘一个新窗口来实现的,而楼主要在msgbox来整,那个也难帮他了
发表于 2012-8-25 21:14:53 | 显示全部楼层
小问题,不纠结,自己搞一个
发表于 2012-8-26 23:17:59 | 显示全部楼层
回复 9# zhao_ming

那个只是添加倒计时而已,跟楼主的问题好像关系不是很大吧??没看到有超链接,硬要使用msgbox()实现估计没法,用个GUI来代替可以~~
发表于 2012-8-27 11:19:05 | 显示全部楼层
回复 1# 虎虎虎


    还是自制GUI最灵活,想怎么布局都可以。
   下面这个是我以前做的,稍加修改放上来供参考:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

Local Const $web_troubleshooting = "http://msdn.microsoft.com/en-us/library/aa394603.aspx"
Local Const $web_download = "http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7684"
Local $hErrInfo, $website1, $website2, $Button

Opt("TrayMenuMode", 1)
Opt("GUIOnEventMode",1)
ShowWMIDialog()


Func ShowWMIDialog()
        ;http://www.autoitx.com/forum.php ... F%F2%2B%C1%B4%BD%D3
        $hErrInfo = GUICreate("WMI Troubleshooting", 500, 150, -1, -1, BitOR($WS_POPUPWINDOW, $WS_CAPTION), $WS_EX_TOPMOST, WinGetHandle("[CLASS:Progman]"))
        GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit" )
        GUICtrlCreateIcon(@AutoItExe, -1, 11, 11)
        GUICtrlCreateLabel("Connection not detected due to WMI problem of your computer!", 59, 11, 480, -1)
        GUICtrlSetFont (-1,10, 800, 0, "Arial") ; bold
        GUICtrlCreateLabel("You may consider WMI troubleshooting:", 59, 40, -1, -1)
        $website1 = GUICtrlCreateLabel ($web_troubleshooting, 59, 58, -1, -1)
        GuiCtrlSetFont($website1, 8.5, -1, 4) ; underlined
        GuiCtrlSetColor($website1, 0x0000ff)
        GuiCtrlSetCursor($website1, 0)
        GUICtrlSetOnEvent(-1, "OnClick")
        GUICtrlCreateLabel(@CRLF, 59, 74, -1, -1)        ; Blank line
        GUICtrlCreateLabel("and specifically try WMI Diagnosis Utility and check output:", 60, 76, -1, -1)
        $website2 = GUICtrlCreateLabel ($web_download, 59, 90, -1, -1)
        GuiCtrlSetFont($website2, 8.5, -1, 4) ; underlined
        GuiCtrlSetColor($website2, 0x0000ff)
        GuiCtrlSetCursor($website2, 0)
        GUICtrlSetOnEvent(-1, "OnClick")
        $Button = GUICtrlCreateButton ("OK", 200, 120, 75, 23, BitOR($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON))
        GUICtrlSetState (-1, $GUI_FOCUS)
        GUICtrlSetOnEvent(-1, "OnClick")
        GUISetState()
        While 1
                Sleep(100)
        WEnd
EndFunc

Func OnClick()
        Switch @GUI_CtrlId
                Case $website1
                        Run(@ComSpec & " /c " & 'start ' & $web_troubleshooting, "", @SW_HIDE)
                Case $website2
                        Run(@ComSpec & " /c " & 'start ' & $web_download, "", @SW_HIDE)
                Case $Button
                        Exit
        EndSwitch        
EndFunc

Func _Exit()
        Exit
EndFunc
 楼主| 发表于 2012-8-27 13:28:19 | 显示全部楼层
楼上代码,是不错,可是如何实现返回值及系统声音啊!就像自带的一样。
发表于 2012-8-27 21:22:18 | 显示全部楼层
显示你的自定义GUI前播放系统声音:
SoundPlay(@WindowsDir & "\Media\Windows XP Ding.wav")
  
返回值,自己通过函数返回值实现就行,点不同的按钮返回不同的值,值都可以自定义。亲,不难啦~
发表于 2012-8-27 21:39:40 | 显示全部楼层
不会帮你顶
发表于 2012-8-30 09:56:31 | 显示全部楼层
哦哦。。。。酱紫啊。好
发表于 2012-9-4 15:34:51 | 显示全部楼层
好,不错
 楼主| 发表于 2012-9-8 21:30:43 | 显示全部楼层
我在别处看到“NSIS“实现的方法,代码在一楼。那位高手看看。。能否转成AU3的。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 13:00 , Processed in 0.084422 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表