Jump to content

Recommended Posts

Posted (edited)

Creating a Simple Script messageBox.

#NoTrayIcon
Opt("MustDeclareVars", 1)
;=====================MessageBox Builder=======================
Global Const $head_scriptname = "MsgBox"
Global $scriptname_create = "Hello.au3" ;Add change name of script to create here.
Dim $flag = 0 ;Add script button result.
Dim $title = "Sample" ;Add change script text on the title bar.
Dim $text = "Hello World!" ;Add change script text on the window.
Dim $timeout = 0 ;Add change script timeout popup.
;------------------------------------------ ;==>script create.
Dim $array[5] = [$flag, $title, $text, $timeout]
Dim $output = ""
Dim $i
For $i = 0 To UBound($array)-1
$output = $output&StringReplace('"'&$array[$i]&'"'&',', "/", @CRLF)
Next
_FileAppend($head_scriptname&"("&StringTrimRight($output, 1)&")", $scriptname_create) ;==>MsgBoxBuilder.
;========FileAppend Library Include========
Func _FileAppend($Text, $Filename)
    Local $Ret = FileWrite($Filename, $Text)
    If($Ret=0)Then Return SetError(1, 0, 0)
    Return $Ret
EndFunc ;==>FileAppend.
Edited by Laymanball

My Sample Script

Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html

                     VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html

Posted

Strange. If I use the Code Wizard to make an InputBox, the preview works. But running the program in SciTE it just comes up and quits. It doesn't ask for any input.

#Region --- CodeWizard generated code Start ---
;InputBox features: Title=Yes, Prompt=Yes, Default Text=Yes
If Not IsDeclared("sInputBoxAnswer") Then Local $sInputBoxAnswer
$sInputBoxAnswer = InputBox("TryInput","This won't even show","type something in"," ","-1","-1","-1","-1")
Select
Case @Error = 0 ;OK - The string returned is valid
 
Case @Error = 1 ;The Cancel button was pushed
 
Case @Error = 3 ;The InputBox failed to open
 
EndSelect
#EndRegion --- CodeWizard generated code End ---
Posted

Strange. If I use the Code Wizard to make an InputBox, the preview works. But running the program in SciTE it just comes up and quits. It doesn't ask for any input.

Left and Top should not be -1. Change it and it works.
Posted (edited)

Script Modify.

#NoTrayIcon
Opt("MustDeclareVars", 1)
;=====================MessageBox Builder=======================
_MessageBoxBuilder()
Func _MessageBoxBuilder()
Global Const $Headcommand = "MsgBox"
Global $Scriptname = "Hello.au3" ;Add change name of script to create here.
Dim $flag = 0 ;Add script button result.
Dim $title = '"Sample"' ;Add change script text on the title bar.
Dim $text = '"Hello World!"' ;Add change script text on the window.
Dim $timeout = 0 ;Add change script timeout popup.
Dim $hWnd = 0 ;no gui.
Local $tParam = ($flag&','&$title&','&$text&','&$timeout&','&$hWnd)
_FileAppend($HeadCommand&'('&$tParam&')', $Scriptname)
EndFunc ;==>MsgBoxBuilder.
;=========FileAppend Library Include=========
Func _FileAppend($sText, $sFilename)
    Local $Ret = FileWrite($sFilename, $sText)
    If($Ret=0)Then Return SetError(1, 0, 0)
    Return $Ret
EndFunc ;==>FileAppend.

Modify to GUI.

#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", 1)

Local $hWnd = GUICreate("MsgBox Builder", 251, 292, -1, -1)
GUICtrlCreateLabel("Flag:", 16, 16, 27, 17)
Local $Input1 = GUICtrlCreateInput("0", 48, 16, 185, 21)
GUICtrlCreateLabel("Title:", 16, 48, 27, 17)
Local $Input2 = GUICtrlCreateInput("Sample", 48, 48, 185, 21)
GUICtrlCreateLabel("Text:", 16, 112, 28, 17)
Local $Edit1 = GUICtrlCreateEdit("Hello World!", 48, 80, 185, 89)
GUICtrlCreateLabel("Timeout:", 0, 184, 45, 17)
Local $Input3 = GUICtrlCreateInput("0", 48, 184, 185, 21)
GUICtrlCreateLabel("hWnd:", 8, 216, 36, 17)
Local $Input4 = GUICtrlCreateInput("0", 48, 216, 185, 21)
Local $Button1 = GUICtrlCreateButton("Build", 80, 256, 75, 25, $WS_GROUP)
GUICtrlSetState(-1, $GUI_FOCUS)
GUISetState(@SW_SHOW)

While 1
    Local $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Global Const $Headcommand = "MsgBox"
            Dim $flag = GUICtrlRead($Input1)
            Dim $title = GUICtrlRead($Input2)
            Dim $text = GUICtrlRead($Edit1)
            Dim $timeout = GUICtrlRead($Input3)
            Dim $hWnd = GUICtrlRead($Input4)
            Local $tParam = ($flag&','&'"'&$title&'"'&','&'"'&$text&'"'&','&$timeout&','&$hWnd)
            Local $Scriptname = InputBox("Build", "Enter:Scriptname", "Hello.au3", "", 200, 100, 415, 305)
            If($flag="")And($title="")And($text="")And($Scriptname="")Then Exit
            Local $aret = _FileAppend($HeadCommand&'('&$tParam&')', $Scriptname)
            If $aret = 1 Then Exit
    EndSwitch
WEnd
;=========FileAppend Library Include=========
Func _FileAppend($sText, $sFilename)
    Local $Ret = FileWrite($sFilename, $sText)
    If($Ret=0)Then Return SetError(1, 0, 0)
    Return $Ret
EndFunc ;==>FileAppend.
Edited by Laymanball

My Sample Script

Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html

                     VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html

Posted

That's what's generated though. Must be a throw back to using -1 to signify default value instead of just leaving it blank.

Maybe -1 used to be the default value and it changed, those extra tools are always 1 (or 400 :graduated:) versions behind. Look at the CodeWizard file, it's at least a couple of years old. The Default keyword seem to work, so try that as the default location.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...