Jump to content
Sign in to follow this  
majidemo

Combo Statements

Recommended Posts

majidemo

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:

#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 by majidemo

Share this post


Link to post
Share on other sites
water

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:

#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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
majidemo

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 by majidemo

Share this post


Link to post
Share on other sites
water

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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
majidemo

$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..

Share this post


Link to post
Share on other sites
water

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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
majidemo

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 :P thanks alot..

#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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.