James Posted May 2, 2007 Share Posted May 2, 2007 (edited) Hey,I'm working on an AutoIt script which is like Sloganizer.net (i542)Basically, I'm not sure on how to declare the possible answers and then randomly pick one. Once I have learnt, I will understand it, which means I won't ask for help on the matter again, in fact I can help on them Here is what I have so far,#include <GUIConstants.au3> $sGui = GUICreate("Sloganizer.Net :: Secure_ICT AutoIt Version", 554, 338, -1, -1) GUISetBkColor(0xFFFFFF) $Pic1 = GUICtrlCreatePic("logo.jpg", 0, 16, 553, 81, BitOR($SS_NOTIFY,$WS_GROUP)) $Text = GUICtrlCreateInput("Text", 72, 112, 385, 21) $sloganize = GUICtrlCreateButton("Sloganize", 152, 144, 217, 25, 0) $FinalText = GUICtrlCreateLabel("", 72, 192, 4, 4) GUICtrlSetFont(-1, 36, 800, 0, "Arial") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) Global $Answer $Answer[0] = "<< " & $Text & " will be for you what you want it to be.>>" $Answer[1] = "<< " & $Text & ", in touch with tomorrow.>>" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $sloganize SloganizeTxt() EndSwitch WEnd Func SloganizeTxt() $SloganizeNow = GuiCtrlRead($Text) $Random = Random($Answer) GUICtrlSetData($Random) EndFuncThe image is attached below. Thankyou for helping in advance,Secure Edited May 2, 2007 by Secure_ICT Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
flyingboz Posted May 2, 2007 Share Posted May 2, 2007 Basically, I'm not sure on how to declare the possible answers and then randomly pick one. One method would be to declare an array containing the possible answers, then use Random with the integer flag to pick an array element. Untested: $max_num_slogans=50 Dim $a[$max_num_slogans] + 1 $a[1] = 'foo' $a[2] = 'bar' ;etc $i = Rand(1,$max_num_slogans,1) consolewrite($a[$i]) Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
madmikep Posted May 2, 2007 Share Posted May 2, 2007 (edited) Hey, I'm working on an AutoIt script which is like Sloganizer.net (i542) Basically, I'm not sure on how to declare the possible answers and then randomly pick one. Once I have learnt, I will understand it, which means I won't ask for help on the matter again, in fact I can help on them Here is what I have so far, #include <GUIConstants.au3> $sGui = GUICreate("Sloganizer.Net :: Secure_ICT AutoIt Version", 554, 338, -1, -1) GUISetBkColor(0xFFFFFF) $Pic1 = GUICtrlCreatePic("logo.jpg", 0, 16, 553, 81, BitOR($SS_NOTIFY,$WS_GROUP)) $Text = GUICtrlCreateInput("Text", 72, 112, 385, 21) $sloganize = GUICtrlCreateButton("Sloganize", 152, 144, 217, 25, 0) $FinalText = GUICtrlCreateLabel("", 72, 192, 4, 4) GUICtrlSetFont(-1, 36, 800, 0, "Arial") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) Global $Answer $Answer[0] = "<< " & $Text & " will be for you what you want it to be.>>" $Answer[1] = "<< " & $Text & ", in touch with tomorrow.>>" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $sloganize SloganizeTxt() EndSwitch WEnd Func SloganizeTxt() $SloganizeNow = GuiCtrlRead($Text) $Random = Random($Answer) GUICtrlSetData($Random) EndFunc The image is attached below. Thankyou for helping in advance, Secure Not sure what you are looking for but I some what fixed your script NO Errors CODE#include <GUIConstants.au3> Dim $Answer[3] $sGui = GUICreate("Sloganizer.Net :: Secure_ICT AutoIt Version", 554, 338, -1, -1) GUISetBkColor(0xFFFFFF) $Pic1 = GUICtrlCreatePic("logo.jpg", 0, 16, 553, 81, BitOR($SS_NOTIFY,$WS_GROUP)) $Text = GUICtrlCreateInput("Text", 72, 112, 385, 21) $sloganize = GUICtrlCreateButton("Sloganize", 152, 144, 217, 25, 0) $FinalText = GUICtrlCreateLabel("", 72, 192, 4, 4) GUICtrlSetFont(-1, 36, 800, 0, "Arial") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) Global $Answer $Answer[1] = "<< " & $Text & " will be for you what you want it to be.>>" $Answer[2] = "<< " & $Text & ", in touch with tomorrow.>>" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $sloganize EndSwitch WEnd Func SloganizeTxt() $SloganizeNow = GuiCtrlRead($Text) $Random = Random($Answer) GUICtrlSetData($sGui ,$Random) EndFunc Added: Dim $Answer[3] Changed $Answer[1] = "<< " & $Text & " will be for you what you want it to be.>>" $Answer[2] = "<< " & $Text & ", in touch with tomorrow.>>" Fixed GUICtrlSetData($sGui ,$Random) Edited May 2, 2007 by madmikep Link to comment Share on other sites More sharing options...
Zedna Posted May 2, 2007 Share Posted May 2, 2007 (edited) Mine version:#include <GUIConstants.au3> $sGui = GUICreate("Sloganizer.Net :: Secure_ICT AutoIt Version", 554, 400, -1, -1) GUISetBkColor(0xFFFFFF) $Pic1 = GUICtrlCreatePic("logo.jpg", 0, 16, 553, 81, BitOR($SS_NOTIFY,$WS_GROUP)) $Text = GUICtrlCreateInput("Text", 72, 112, 385, 21) $sloganize = GUICtrlCreateButton("Sloganize", 152, 144, 217, 25, 0) $FinalText = GUICtrlCreateLabel("", 72, 192, 400, 200) GUICtrlSetFont(-1, 36, 800, 0, "Arial") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) Global $Answer[3] $Answer[0] = "%1 will be for you what you want it to be." $Answer[1] = "%1, in touch with tomorrow." $Answer[2] = "Forever with %1 :-)" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $sloganize SloganizeTxt() EndSwitch WEnd Func SloganizeTxt() $SloganizeNow = GuiCtrlRead($Text) $Random = Random(0,UBound($Answer)-1,1) $result = $Answer[$Random] $result = StringReplace($result,'%1', $SloganizeNow) GUICtrlSetData($FinalText, "<< " & $result & " >>") EndFuncEDIT: Slogans can be saved in TXT file (each slogan at one line) and read by _FileReadToArray() Edited May 2, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
James Posted May 2, 2007 Author Share Posted May 2, 2007 (edited) Zedna you rule! Thanks mate! Its obvious now that I look but I don't understand the %1's? I get what that %1 means but thwy is that used and not a $? I get it now, I missed the StringReplace! lol Edited May 2, 2007 by Secure_ICT Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now