Jump to content

GuiCtrlRead


Recommended Posts

im having some problems using GuiCtrlRead

i studied the help fil a great bit to figure this out, now i only need the end part :P

i need the value that is selected in a combo box

i think i need to do this with GuiCtrlRead butwich value does it return?

i tought it was $comboboxname but it doesent work

Link to comment
Share on other sites

  • Moderators

im having some problems using GuiCtrlRead

i studied the help fil a great bit to figure this out, now i only need the end part :P

i need the value that is selected in a combo box

i think i need to do this with GuiCtrlRead butwich value does it return?

i tought it was $comboboxname but it doesent work

Do we guess on what it is your script is having problems with or do you want to post an example of it so we can help you? GUICtrlRead($ComboBox) will return the Control $ComboBox's text that is currently visible.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

but how can i call that variable thats currently visible?

i need it in a run command like: run($var) and $var is getting his value from the combobox :P

What part of post a working example are you not understanding? Just comment where you and what you want what to do.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

oh srry, misread it :$

combo box:

$combo_map = GUICtrlCreateCombo("Select Map", 8, 56, 137, 21, $CBS_DROPDOWNLIST)

adds a ini value to the combo box:

_GUICtrlComboAddString ($combo_map,$map1)

launch the game with teh combo box var:

$launchgame = "mm.exe +map " & $combo_map

this is what i had :P

Link to comment
Share on other sites

  • Moderators

Here this took me a couple of minutes, maybe it will give you an idea:

$MainGUI = GUICreate('MyGui', 200, 100)
$ComboBox = GUICtrlCreateCombo('', 10, 10, 180, 150, 0x0003)
GUICtrlSetData($ComboBox, @SystemDir & '\notepad.exe|' & @SystemDir & '\calc.exe')
$Button = GUICtrlCreateButton('Run', 75, 35, 50, 30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case - 3
            Exit
        Case $Button
            If GUICtrlRead($ComboBox) <> '' Then _
                Run('"' & GUICtrlRead($ComboBox) & '"')
    EndSwitch
WEnd

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

amanda089's example looks right... Just make sure that mm.exe is in the same directory as the script or you us the full path to it's location. And use quotes around $var in case there are spaces in the path.

Edit:

I better itterate:

Run('mm.exe +map "' & $var & '"')
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

i tried this:

$launchgame = $launchgame = "mm.exe +map " & GUICtrlRead($combo_map)

Case $msg = $button_launch ;launch button presserd
    Run($launchgame)

EDIT: oops posted to late, i didnt saw amandas answer, going to try that now :P

and mm.exe was allways in the same dir, it was required :nuke:

Edited by Dark_Raver
Link to comment
Share on other sites

  • Moderators

Your syntax is incorrect:

(Look at $launchgame = $launchgame = ) Anything seem weird there?

Case $msg = $button_launch ;launch button presserd
   $launchgame = "mm.exe +map '" & GUICtrlRead($combo_map) & "'"
    Run($launchgame)
Think about the layer there... you want it to read $launchgame only when you press launch... so put it after Case $msg = $button (and you don't need to put $launchgame = $launchgame = ... SciTe should have shown that as an error. Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

i tried it and it didnt worked :P

i tried using a bat file that looks like this:

"mm.exe" +map mm_smallbox

and that worked :s

heres my full (probably crappy)script maybe there is something wrong with it:

;includes and start options
#include <GUIConstants.au3>
#include <GuiCombo.au3>

;Gui Options
$Form1 = GUICreate("Launcher", 153, 218, 288, 145, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
GUISetBkColor(0x000000)

;checks for mm.exe
If FileExists("mm.exe") Then
Else
    MsgBox(0,"Error", "mm.exe is NOT found, please move the launcher to the Dark Messiah root folder")
    Exit
EndIf

;checks for .bat files, if yes -> delete them
If FileExists("*.bat") Then
    MsgBox(0,"Test","BAT Files found, these will be removed. Please backup them now if your planning on using them")
    FileDelete("*.bat")
EndIf

;(re)write ini file with current maps (if necesary)
IF FileExists("dr_cmaps.ini") Then
Else
IniWrite("dr_cmaps.ini","maps","map1","mm_smallbox")
IniWrite("dr_cmaps.ini","maps","map2","mm_bigbox")
IniWrite("dr_cmaps.ini","maps","map3","mm_tower")
IniWrite("dr_cmaps.ini","maps","map4","mm_thearena_beta1")
IniWrite("dr_cmaps.ini","maps","map5","")
IniWrite("dr_cmaps.ini","maps","map6","")
IniWrite("dr_cmaps.ini","maps","map7","")
IniWrite("dr_cmaps.ini","maps","map8","")
IniWrite("dr_cmaps.ini","maps","map9","")
IniWrite("dr_cmaps.ini","maps","map10","")
IniWrite("dr_cmaps.ini","appinfo","Lversion","1.0")
IniWrite("dr_cmaps.ini","appinfo","Mversion","1.4")
EndIf

;read ini entries
$map1 = IniRead("dr_cmaps.ini","maps","map1","no map entry found")
$map2 = IniRead("dr_cmaps.ini","maps","map2","no map entry found")
$map3 = IniRead("dr_cmaps.ini","maps","map3","no map entry found")
$map4 = IniRead("dr_cmaps.ini","maps","map4","no map entry found")
$map5 = IniRead("dr_cmaps.ini","maps","map5","no map entry found")
$map6 = IniRead("dr_cmaps.ini","maps","map6","no map entry found")
$map7 = IniRead("dr_cmaps.ini","maps","map7","no map entry found")
$map8 = IniRead("dr_cmaps.ini","maps","map8","no map entry found")
$map9 = IniRead("dr_cmaps.ini","maps","map9","no map entry found")
$map10 = IniRead("dr_cmaps.ini","maps","map10","no map entry found")

TrayTip("DRMiniMOD Launcher","DRMiniMOD Launcher Version:1.0 - Mod Version: 1.4",25)

;Variables
$button_launch = GUICtrlCreateButton("Launch", 8, 88, 137, 41, 0)
$button_exit = GUICtrlCreateButton("Exit", 8, 168, 137, 25, 0)
$combo_map = GUICtrlCreateCombo("Select Map", 8, 56, 137, 21, $CBS_DROPDOWNLIST)
$button_editcfg = GUICtrlCreateButton("Edit Custom.cfg", 8, 136, 137, 25, 0)
$check_cheats = GUICtrlCreateCheckbox("check_cheats", 8, 8, 17, 17)
$check_customcfg = GUICtrlCreateCheckbox("check_customcfg", 8, 32, 17, 17)
$file_menu = GUICtrlCreateMenu ("File")
$file_exit = GUICtrlCreateMenuitem ("Exit", $file_menu)
$help_menu = GUICtrlCreateMenu ("Help")
$help_about = GUICtrlCreateMenuitem ("About", $help_menu)
$help_links = GuiCtrlCreateMenu ("Links", $help_menu)
$links_oblivion = GUICtrlCreateMenuitem ("Oblivion Clan", $help_links)
$links_oblforum = GUICtrlCreateMenuitem ("Oblivion Clan Forums", $help_links)
$links_mmubiforum = GUICtrlCreateMenuitem ("Ubisoft's Dark Messiah Forums", $help_links)

;GUI Controlls
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlCreateLabel("Disable Cheats", 24, 8, 75, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlCreateLabel("Enable Custom.cfg", 24, 32, 93, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
GUISetState(@SW_SHOW)

;add maps to the combo box
_GUICtrlComboAddString ($combo_map,$map1)
_GUICtrlComboAddString ($combo_map,$map2)
_GUICtrlComboAddString ($combo_map,$map3)
_GUICtrlComboAddString ($combo_map,$map4)
_GUICtrlComboAddString ($combo_map,$map5)
_GUICtrlComboAddString ($combo_map,$map6)
_GUICtrlComboAddString ($combo_map,$map7)
_GUICtrlComboAddString ($combo_map,$map8)
_GUICtrlComboAddString ($combo_map,$map9)
_GUICtrlComboAddString ($combo_map,$map10)

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $button_exit ;Exit button Pressed
        ExitLoop
    Case $msg = $file_exit ;exit in the file menu
        ExitLoop
    Case $msg = $button_launch ;launch button presserd
        $launchgame = "mm.exe +map '" & GUICtrlRead($combo_map) & "'"
        Run($launchgame)
    Case $msg = $button_editcfg
        RunWait(@COMSPEC & " /c Start mm/cfg/custom.cfg") ;edit the custom cfg
    Case $msg = $links_oblivion
        RunWait(@COMSPEC & " /c Start http://clanoblivion.com") ;open up browser
    Case $msg = $links_oblforum
        RunWait(@COMSPEC & " /c Start http://clanoblivion.com/forums") ;open up browser
    Case $msg = $links_mmubiforum
        RunWait(@COMSPEC & " /c Start http://forums.ubi.com/eve/forums/a/frm/f/808101043") ;open up browser
    EndSelect
WEnd
Link to comment
Share on other sites

  • Moderators

I asked this before, is mm.exe in the same directory you are running your script from?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

yes its is

i wrote something to check it:

;checks for mm.exe

If FileExists("mm.exe") Then

Else

MsgBox(0,"Error", "mm.exe is NOT found, please move the launcher to the Dark Messiah root folder")

Exit

EndIf

i was amazed it worked :P

it works halfly, it launches the game but goes to the main menu (sign of no +map behind it or a wrong option)

Edited by Dark_Raver
Link to comment
Share on other sites

  • Moderators

And you're positive that +map is the right switch?

Also, you would make your life alot easier if you started using arrays..

Example:

This

;read ini entries
$map1 = IniRead("dr_cmaps.ini","maps","map1","no map entry found")
$map2 = IniRead("dr_cmaps.ini","maps","map2","no map entry found")
$map3 = IniRead("dr_cmaps.ini","maps","map3","no map entry found")
$map4 = IniRead("dr_cmaps.ini","maps","map4","no map entry found")
$map5 = IniRead("dr_cmaps.ini","maps","map5","no map entry found")
$map6 = IniRead("dr_cmaps.ini","maps","map6","no map entry found")
$map7 = IniRead("dr_cmaps.ini","maps","map7","no map entry found")
$map8 = IniRead("dr_cmaps.ini","maps","map8","no map entry found")
$map9 = IniRead("dr_cmaps.ini","maps","map9","no map entry found")
$map10 = IniRead("dr_cmaps.ini","maps","map10","no map entry found")oÝ÷ Ø*.Ð^jëh×6;read ini entries
Dim $map[11]
For $iCC = 1 To 10
    $map[$iCC] = IniRead("dr_cmaps.ini","maps","map" & $iCC,"no map entry found")
NextoÝ÷ Ø    ÝN¬jëh×6;add maps to the combo box
_GUICtrlComboAddString ($combo_map,$map1)
_GUICtrlComboAddString ($combo_map,$map2)
_GUICtrlComboAddString ($combo_map,$map3)
_GUICtrlComboAddString ($combo_map,$map4)
_GUICtrlComboAddString ($combo_map,$map5)
_GUICtrlComboAddString ($combo_map,$map6)
_GUICtrlComboAddString ($combo_map,$map7)
_GUICtrlComboAddString ($combo_map,$map8)
_GUICtrlComboAddString ($combo_map,$map9)
_GUICtrlComboAddString ($combo_map,$map10)oÝ÷ Ø*.ÖÞjëh×6;add maps to the combo box
For $iCC = 1 To 10
_GUICtrlComboAddString ($combo_map,$map[$iCC])
Next

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Try this

$launchgame = @ScriptDir & '\mm.exe +map ' & GUICtrlRead($combo_map)
        Run(@ComSpec & ' /c "' & $launchgame & '"', '', @SW_HIDE)oÝ÷ ØGb´êÌk&Þz÷§jëh×6$launchgame = '"' & @ScriptDir & '\mm.exe ' & '"' & '+map ' & GUICtrlRead($combo_map)
        Run(@ComSpec & ' /c ' & $launchgame, '', @SW_HIDE)oÝ÷ ØêÚºÚ"µÍÌÍÛ][ÚØ[YHH ÌÎNÉ][ÝÉÌÎNÈ    [ÈØÜ [È ÌÎNÉÌLÛ[K^H    ÌÎNÈ [È ÌÎNÉ][ÝÉÌÎNÈ    [È ÌÎNÊÛX  ÌÎNÈ [ÈÕRPÝXY
    ÌÍØÛÛX×ÛX
B[  ÌÍÛ][ÚØ[YJoÝ÷ ØGb·c«1¬yëÞ«­¢+ØÀÌØí±Õ¹¡µô¥±ÑM¡½ÉÑ9µ¡MÉ¥ÁѥȵÀìÌäìÀäÈíµ´¹áÌä줵ÀìÌäì­µÀÌäìµÀìU%
ÑɱI ÀÌØí½µ½}µÀ¤)IÕ¸¡
½µMÁµÀìÌäì½ÌäìµÀìÀÌØí±Õ¹¡µ°ÌäìÌäì°M]}!%¤oÝ÷ ØêÚºÚ"µÍÌÍÛ][ÚØ[YHH[]ÚÜ[YJØÜ [È ÌÎNÉÌLÛ[K^IÌÎNÊH    [È ÌÎNÈ
ÛX ÌÎNÈ [ÈÕRPÝXY
    ÌÍØÛÛX×ÛX
B[  ÌÍÛ][ÚØ[YJ

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

:) the last one did the job :P

thnx smoke :D

now how to figure out the checkbox thing :nuke:

but first me tries alone xD

Thank God, I almost feel like doing the Jig for you!!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...