majidemo Posted August 18, 2010 Posted August 18, 2010 (edited) im having problems with this one, i want to choose a certain value in the combo box (eg. Lublin Mongol Fortress) when i click generate it shows value of Lublin Mongol Fortress w/c is 02, but when i click generate it shows the same answer what ever choose from the combo boxes.. i believe its my IF statement, or something..its wrong.. please help..thanks ) this is my statement: If GUICtrlRead($packet) == "Death" Then $outpacket = "0A " If GUICtrlRead($packet) == "Storage 1" Then $outpacket = "1A " If GUICtrlRead($packet) == "Storage 2" Then $outpacket = "2A " If GUICtrlRead($map) == "Wroclaw Fortress" Then $outmap = "01" If GUICtrlRead($map) == "Lublin Mongol Fortress" Then $outmap = "02" If GUICtrlRead($map) == "Iron Dungeon" Then $outmap = "03" this is where i show the result: GUICtrlSetData($output, $outpacket & $server & $outmap, "") my full code: expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Opt('MustDeclareVars', 1) Local $msg, $msg, $btn, $generate, $var, $output, $outpacket, $map, $packet, $server, $s, $outmap GUICreate("534535345", 230, 240, -1, -1, -1, 0x00000018); WS_EX_ACCEPTFILES $output = GUICtrlCreateInput("", 10, 10, 210, 20) $generate = GUICtrlCreateButton("Generate", 10, 110, 60, 30) $btn = GUICtrlCreateButton("Close", 90, 110, 60, 30) $map = GUICtrlCreateCombo("", 10, 35, 210, 20) GUICtrlSetData(-1, "Wroclaw Fortress|Lublin Mongol Fortress|Iron Dungeon|Lava Canyon|Mist Iron Prison|Mist Ancient Ruin|Boggy Dungeon|Altai Gorge|Kharakorum|HangZhou|Ice Boggy Dungeon|Wroclaw Castle|Strike Back 1|Strike Back 2", "Wroclaw Fortress") $packet = GUICtrlCreateCombo("", 10, 60, 210, 20) GUICtrlSetData(-1, "Death|Storage 1|Storage 2", "Death") If GUICtrlRead($packet) == "Death" Then $outpacket = "0A " If GUICtrlRead($packet) == "Storage 1" Then $outpacket = "1A " If GUICtrlRead($packet) == "Storage 2" Then $outpacket = "2A " If GUICtrlRead($map) == "Wroclaw Fortress" Then $outmap = "01" If GUICtrlRead($map) == "Lublin Mongol Fortress" Then $outmap = "02" If GUICtrlRead($map) == "Iron Dungeon" Then $outmap = "03" $server = "00 " ;& $server & GUISetState() $msg = 0 While 1 $msg = GUIGetMsg() Switch $msg Case $btn, $GUI_EVENT_CLOSE ExitLoop Case $generate GUICtrlSetData($output, $outpacket & $server & $outmap, "") EndSwitch WEnd Edited August 18, 2010 by majidemo
water Posted August 18, 2010 Posted August 18, 2010 (edited) You have to insert a new "case" in your loop and handle the "GUICtrlRead" stuff there. And you have to initialize your variables to get the correct result if the user doesn't select anything and just presses the "generate" key. Something like: expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Opt('MustDeclareVars', 1) Local $msg, $msg, $btn, $generate, $var, $output, $outpacket, $map, $packet, $server, $s, $outmap GUICreate("534535345", 230, 240, -1, -1, -1, 0x00000018); WS_EX_ACCEPTFILES $output = GUICtrlCreateInput("", 10, 10, 210, 20) $generate = GUICtrlCreateButton("Generate", 10, 110, 60, 30) $btn = GUICtrlCreateButton("Close", 90, 110, 60, 30) $map = GUICtrlCreateCombo("", 10, 35, 210, 20) GUICtrlSetData(-1, "Wroclaw Fortress|Lublin Mongol Fortress|Iron Dungeon|Lava Canyon|Mist Iron Prison|Mist Ancient Ruin|Boggy Dungeon|Altai Gorge|Kharakorum|HangZhou|Ice Boggy Dungeon|Wroclaw Castle|Strike Back 1|Strike Back 2", "Wroclaw Fortress") $packet = GUICtrlCreateCombo("", 10, 60, 210, 20) GUICtrlSetData(-1, "Death|Storage 1|Storage 2", "Death") $server = "00 " $outpacket = "0A " $outmap = "01 " GUISetState() $msg = 0 While 1 $msg = GUIGetMsg() Switch $msg Case $btn, $GUI_EVENT_CLOSE ExitLoop Case $generate GUICtrlSetData($output, $outpacket & $server & $outmap, "") Case $map If GUICtrlRead($map) == "Wroclaw Fortress" Then $outmap = "01" If GUICtrlRead($map) == "Lublin Mongol Fortress" Then $outmap = "02" If GUICtrlRead($map) == "Iron Dungeon" Then $outmap = "03" Case $packet If GUICtrlRead($packet) == "Death" Then $outpacket = "0A " If GUICtrlRead($packet) == "Storage 1" Then $outpacket = "1A " If GUICtrlRead($packet) == "Storage 2" Then $outpacket = "2A " EndSwitch WEnd Edited August 18, 2010 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
majidemo Posted August 18, 2010 Author Posted August 18, 2010 (edited) whoa, thanks for the fast reply it really helped..hehe..im still tying to learn autoit.. anyways, is there any way of RANDOMIZING the results? like if i choose "Wroclaw Fortress" w/c is valued at 01, but when i click generate again, it randomizes it to a array i have defined like Wroclaw Fortress will randomize the following 01,02,03,04,05,06,07 and everytime i click generate it displays any of it thanks ahead.. something like this $string="a,b,c,d" $Array=StringSplit($string,",") $i=Random(0,UBound($Array)-1,1) MsgBox(0,"Random",$Array[$i]) w/o the msgbox thought cuz im trying it like this GUICtrlSetData($output, $outpacket & $server & $outmap & $encpacket & $Array[$i], "") though it doesnt work..Y_Y cuz it randomizes only at program start, not on every click on generate Edited August 18, 2010 by majidemo
water Posted August 18, 2010 Posted August 18, 2010 (edited) You could use the random function. $iResult = "0" & Random ( 1, 7, 1) This will create integer numbers between 1 and 7 and prepend a "0". Edited August 18, 2010 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
majidemo Posted August 18, 2010 Author Posted August 18, 2010 $iResult = "0" & Random ( 1, 7, 1) oh yeah thanks..anyways, is there a way of randomizing at every click? thanks where do i see the help file they are telling that contains the instructions? noobish me..
water Posted August 18, 2010 Posted August 18, 2010 (edited) To randomize on every click on "generate" you have to put the randomization code in the Case $generate But at the moment I'm not sure what you want to achieve. Now every "$map" has its own number ("Wroclaw Fortress" = "01", "Lublin Mongol Fortress" = "02", "Iron Dungeon" = "03"). Do you want to set a random number for every $map? Edited August 18, 2010 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
majidemo Posted August 18, 2010 Author Posted August 18, 2010 oowh this is really great.. thanks works perfectly.. i have to go now thanks alot.. heres my codes so far its actually not that random, cuz im defining it thanks alot.. expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Opt('MustDeclareVars', 1) Local $msg, $msg, $btn, $generate, $var, $output, $outpacket, $map, $packet, $server, $s, $outmap, $encpacket, $string, $i, $Array GUICreate("Packet Generator", 230, 240, -1, -1, -1, 0x00000018); WS_EX_ACCEPTFILES $output = GUICtrlCreateInput("", 10, 10, 210, 20) $generate = GUICtrlCreateButton("Generate", 10, 110, 60, 30) $btn = GUICtrlCreateButton("Close", 90, 110, 60, 30) $map = GUICtrlCreateCombo("", 10, 35, 210, 20) GUICtrlSetData(-1, "Wroclaw Fortress|Lublin Mongol Fortress|Iron Dungeon|Lava Canyon|Mist Iron Prison|Mist Ancient Ruin|Boggy Dungeon|Altai Gorge|Kharakorum|HangZhou|Ice Boggy Dungeon|Wroclaw Castle|Strike Back 1|Strike Back 2", "Wroclaw Fortress") $packet = GUICtrlCreateCombo("", 10, 60, 210, 20) GUICtrlSetData(-1, "Death|Storage 1|Storage 2", "Death") $server = "00 " $outpacket = "0A " $encpacket = "00 00 00 00" $outmap = "01 " GUISetState() $msg = 0 While 1 $msg = GUIGetMsg() Switch $msg Case $btn, $GUI_EVENT_CLOSE ExitLoop Case $generate $string=" 00 00 00 00, 00 00 00 01, 00 00 00 02, 00 00 00 03" $Array=StringSplit($string,",") $i=Random(1,UBound($Array)-1,1) GUICtrlSetData($output, $outpacket & $server & $outmap & $encpacket & $Array[$i], "") Case $map If GUICtrlRead($map) == "Wroclaw Fortress" Then $outmap = "01 " If GUICtrlRead($map) == "Lublin Mongol Fortress" Then $outmap = "02 " If GUICtrlRead($map) == "Iron Dungeon" Then $outmap = "03 " If GUICtrlRead($map) == "Lava Canyon" Then $outmap = "04 " If GUICtrlRead($map) == "Mist Iron Prison" Then $outmap = "05 " If GUICtrlRead($map) == "Mist Ancient Ruin" Then $outmap = "06 " If GUICtrlRead($map) == "Boggy Dungeon" Then $outmap = "07 " If GUICtrlRead($map) == "Altai Gorge" Then $outmap = "08 " If GUICtrlRead($map) == "Kharakorum" Then $outmap = "0A " If GUICtrlRead($map) == "HangZhou" Then $outmap = "01" If GUICtrlRead($map) == "Ice Boggy Dungeon" Then $outmap = "02 " If GUICtrlRead($map) == "Wroclaw Castle" Then $outmap = "03 " If GUICtrlRead($map) == "Strike Back 1" Then $outmap = "96 " If GUICtrlRead($map) == "Strike Back 2" Then $outmap = "97 " Case $packet If GUICtrlRead($packet) == "Death" Then $outpacket = "0A " If GUICtrlRead($packet) == "Death" Then $encpacket = "00 00 00 00" If GUICtrlRead($packet) == "Storage 1" Then $outpacket = "0A " If GUICtrlRead($packet) == "Storage 1" Then $encpacket = "00 00 00 01" If GUICtrlRead($packet) == "Storage 2" Then $outpacket = "0A " EndSwitch WEnd
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