Jump to content
Sign in to follow this  
NateF

Updating Input with a MsgBox line for copy/paste

Recommended Posts

NateF

Hi, I have been making alot of random scripts lately, none of which are really useful for anything but they help me to understand various things and I use them for reference quite often... anyways, one of the outline button options for one of my scripts is a popup msgbox generator that generates a code that I can just copy and paste (there are alot of message boxes in the script) but I am having trouble with the variable being displayed in the input, $codebox:

$code = "MsgBox(0, $title, $message)"
GUICtrlSetData($codebox, $code)

this displays:

"MsgBox(0, $title, $message)"  

rather than the data stored inside the variable. Yet, when I remove the quotation marks from the $code line, that actually brings the msgbox up(which I don't want) and returns a 1 to the codebox, rather than the MsgBox command.. Can I contain a variable inside a variable like this? I am not really sure how else to so this.. Does anybody have a possible workaround I could take a look at? I have searched around the forums but I came up empty.

 

 

 

this is the rest of the msgbox popup,

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
$Form2 = GUICreate("Form2", 418, 197, 195, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form2Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form2Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form2Restore")
$Button1 = GUICtrlCreateButton("Button1", 320, 16, 91, 33)
GUICtrlSetOnEvent(-1, "Button1Click")
$Group1 = GUICtrlCreateGroup("Title", 8, 8, 297, 49)
$titleinput = GUICtrlCreateInput("titleinput", 16, 24, 281, 21)
GUICtrlSetOnEvent(-1, "titleinputChange")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Message", 8, 56, 401, 105)
$messageinput = GUICtrlCreateEdit("", 16, 72, 385, 81)
GUICtrlSetData(-1, "messageinput")
GUICtrlSetOnEvent(-1, "messageinputChange")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$codebox = GUICtrlCreateInput("", 8, 168, 401, 21)
GUICtrlSetOnEvent(-1, "codeboxChange")
GUISetState(@SW_SHOW)
GUICtrlSetData($titleinput, "")
GUICtrlSetData($messageinput, "")
Global $title = "MsgBox trial"
Global $message = ""


While 1
    Sleep(100)
WEnd



Func Button1Click()
$code = "MsgBox(0, $title, $message)"
GUICtrlSetData($codebox, $code)
EndFunc



Func Form2Close()
exit
EndFunc



Func messageinputChange()
Global $message = GUICtrlRead($messageinput)
EndFunc



Func titleinputChange()
Global $title = GUICtrlRead($titleinput)
EndFunc
Edited by NateF

Share this post


Link to post
Share on other sites
NateF

hmm quote marks again..

$code = 'MsgBox(0, ' & '"' & $title & '"' & ', ' & '"' & $message & '"' & ')'

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×