AlmarM Posted October 8, 2007 Share Posted October 8, 2007 Hi, I got a question.. I've made this Example script: #include <GUIConstants.au3> $GUI = GUICreate("Example GUI", 210, 450, -1, -1) GUISetState(@SW_SHOW) $Example_List = GUICtrlCreateCombo("Example List", 5, 390) GUICtrlSetData(-1, "1|2|3|4|5|6|etc.", "Example List") $Other_Button = GUICtrlCreateButton("Other", 5, 415, 201, 30) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Other_Button $Example_Input = InputBox("Example Other", "Example Text") If @error = 1 Then MsgBox(0, "Example", "Example Text") EndIf EndSelect WEnd But what I wanne know is, that if the user has used the Combo List that GUICtrlRead() reads the combo. And if the user uses the Other Button and filled in the InputBox() that GUICtrlRead() the InputBox() reads... Someone knows how ?? Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 8, 2007 Share Posted October 8, 2007 (edited) Like this? #include <GUIConstants.au3> $GUI = GUICreate("Example GUI", 210, 450, -1, -1) GUISetState(@SW_SHOW) $Example_List = GUICtrlCreateCombo("Example List", 5, 390) GUICtrlSetData(-1, "1|2|3|4|5|6|etc.", "Example List") $Other_Button = GUICtrlCreateButton("Other", 5, 415, 201, 30) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Other_Button $Example_Input = InputBox("Example Other", "Example Text") If @error = 1 Then MsgBox(0, "Example", "Example Text") EndIf Case $Example_List MsgBox(0, "", GUICtrlRead($Example_List)) EndSwitch WEnd Edited October 8, 2007 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
AlmarM Posted October 8, 2007 Author Share Posted October 8, 2007 (edited) Ehm.. Almost. Its hard to explain what I realy want... Later in my script I want to use WinSetState() And what window the WinSetState need to "Set" that will be readed by the GUICtrlRead() For Example: I wanne take number 12... But that isnt in the Combo... So i will use the Other Button and i will fill in the 12 into the InputBox() I press Ok and I want that WinSetState() knows i did 12... Cant explain more.. Too hard ;D) Edited October 8, 2007 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 8, 2007 Share Posted October 8, 2007 You lost me. From what I can understand, you're asking how to use GUICtrlRead() to store an item into a variable? Instead of using a button, have an "Other" value in your ComboBox and if the script matches the string "Other" from a GUICtrlRead, then pop up the InputBox. More like this? (WARNING: Using Mousewheel in this combo box can be a bad idea) #include <GUIConstants.au3> $GUI = GUICreate("Example GUI", 210, 450, -1, -1) GUISetState(@SW_SHOW) $Example_List = GUICtrlCreateCombo("Example List", 5, 390) GUICtrlSetData(-1, "1|2|3|4|5|6|Other", "Example List") $Other_Button = GUICtrlCreateButton("Other", 5, 415, 201, 30) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Other_Button $Example_Input = InputBox("Example Other", "Example Text") If @error = 1 Then MsgBox(0, "Example", "Example Text") EndIf Case $Example_List $Temp = _TestFunc(GUICtrlRead($Example_List)) MsgBox(0,"",$Temp) EndSwitch WEnd Func _TestFunc($s_x) Switch $s_x Case "Other" $s_x = InputBox("Example Other", "Example Text") Return $s_x Case Else Return $s_x EndSwitch EndFunc Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
AlmarM Posted October 8, 2007 Author Share Posted October 8, 2007 You know what... Its too hard to explain... I will do it on another way ^^ Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
DW1 Posted October 8, 2007 Share Posted October 8, 2007 do you want the input data to populate into the combo box? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
aslani Posted October 8, 2007 Share Posted October 8, 2007 A ComboBox is both an InputBox and a List. So if your user dont want the choices in the ComboBox, they can type it in...then you don't have to make your script read either or, instead, don't set a default in the choices. [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
AlmarM Posted October 8, 2007 Author Share Posted October 8, 2007 I now got this: #include <GUIConstants.au3> $GUI = GUICreate("Game Minimizer", 210, 450, -1, -1) GUISetState(@SW_SHOW) GUICtrlCreateLabel("Game Minimizer is a small program that will" & @CRLF & "allow you to minimize all games you want." & @CRLF & @CRLF & "To close right-click on it's icon in the " & @CRLF & "system tray and choose 'Exit'" & @CRLF & @CRLF & "Most Games:" , 5, 10) GUICtrlCreateLabel("Enemy Territory" & @CRLF & "World of Warcraft" & @CRLF & "2Moons" & @CRLF & "And a lot more..." & @CRLF & @CRLF & "What I need to typ at Game??" & @CRLF & "Thats easy. Just put the name of the game" & @CRLF & "when its started. Then look at the new tab" & @CRLF & "at bottom of your screen, and look for the" & @CRLF & "game name." & @CRLF & @CRLF & "Home = Maximize" & @CRLF & "End = Minimize", 5, 110) GUICtrlCreateLabel("Game:", 6, 370) $Run = GUICtrlCreateButton("Run", 6, 420, 200) $Game = GUICtrlCreateInput("", 6, 390, 200) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Run $Read = GUICtrlRead($Game) HotKeySet("{HOME}", "Show") HotKeySet("{END}", "Hide") EndSelect WEnd Func Show() WinSetState($Read, "", @SW_SHOW) EndFunc Func Hide() WinSetState($Read, "", @SW_HIDE) EndFunc But if I test it with for exampel AutoIT Help It wont work... Someone knows ? Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 8, 2007 Share Posted October 8, 2007 It doesn't work because ... well, the name of the window isn't matching up. Try setting Opt("WinTitleMatchMode", 4) [or 2, depends on what you want]. The client windows of the game(s) you list may not be the normal, intuitive name.For example: MapleStory's main client window may be named "MSWrld-v432", but you'd never know that since you can't see the titlebar. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
smashly Posted October 8, 2007 Share Posted October 8, 2007 Hi, WinList() may help you to find the titles/handles of your windows.expandcollapse popup#include <GUIConstants.au3> Global $List[1][2], $Button[6] $GUI = GUICreate("", 330, 55, -1, -1, -1, $WS_EX_TOPMOST) $ComboBox = GUICtrlCreateCombo("Select a window title from the list", 5, 5, 320, 20, $CBS_DROPDOWNLIST) SetComboData($ComboBox) $SBN = StringSplit("Activate|Minimize|Maximize|Restore|Close", "|") $bX = 5 For $i = 1 To 5 $Button[$i] = GUICtrlCreateButton($SBN[$i], $bX, 30, 60, 20) $bX += 65 Next GUISetState(@SW_SHOW, $GUI) AdlibEnable("ChkNewWin", 250) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Button[1] If GUICtrlRead($ComboBox) <> "Select a window title from the list" Then _ WinActivate($List[StringLeft(GUICtrlRead($ComboBox), StringInStr(GUICtrlRead($ComboBox), ")") -1)][1], "") Case $Button[2] If GUICtrlRead($ComboBox) <> "Select a window title from the list" Then _ WinSetState($List[StringLeft(GUICtrlRead($ComboBox), StringInStr(GUICtrlRead($ComboBox), ")") -1)][1], "", @SW_MINIMIZE) Case $Button[3] If GUICtrlRead($ComboBox) <> "Select a window title from the list" Then _ WinSetState($List[StringLeft(GUICtrlRead($ComboBox), StringInStr(GUICtrlRead($ComboBox), ")") -1)][1], "", @SW_MAXIMIZE) Case $Button[4] If GUICtrlRead($ComboBox) <> "Select a window title from the list" Then _ WinSetState($List[StringLeft(GUICtrlRead($ComboBox), StringInStr(GUICtrlRead($ComboBox), ")") -1)][1], "", @SW_RESTORE) Case $Button[5] If GUICtrlRead($ComboBox) <> "Select a window title from the list" Then _ WinClose($List[StringLeft(GUICtrlRead($ComboBox), StringInStr(GUICtrlRead($ComboBox), ")") -1)][1], "") EndSwitch WEnd Func ChkNewWin() Dim $WL = WinList() Local $j = 0 For $i = 1 To $WL[0][0] If $WL[$i][0] <> "" AND IsVisible($WL[$i][1]) And $WL[$i][0] <> "Program Manager" And $WL[$i][1] <> $GUI Then $j += 1 Next If $List[0][0] <> $j Then SetComboData($ComboBox) EndFunc Func SetComboData($cID) GUICtrlSetData($cID, "") GUICtrlSetData($cID, "Select a window title from the list", "Select a window title from the list") Dim $WL = WinList(), $List[1][2] Local $j = 0 For $i = 1 To $WL[0][0] If $WL[$i][0] <> "" AND IsVisible($WL[$i][1]) And $WL[$i][0] <> "Program Manager" And $WL[$i][1] <> $GUI Then $j += 1 ReDim $List[$j + 1][2] $List[0][0] = $j $List[$j][0] = $WL[$i][0] $List[$j][1] = $WL[$i][1] GUICtrlSetData($cID, $j & ") " & $List[$j][0]) EndIf Next WinSetTitle($GUI, "", "WinList - Visable Window Titles: " & $List[0][0]) EndFunc Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc Cheers 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