Jump to content

misioooo

Active Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by misioooo

  1. Hi! I am writing some GUI and i need to use images as buttons, but with text on them (text is from INI file). Part with button looks like this: $ankieta1 = GUICtrlCreateButton($txtAnk1, 100,350,765,164) GUICtrlSetFont(-1, 22, 800, -1, "Arial") ;GUICtrlSetColor(-1,0xffffff) $hImageBtn_1 = _GUIImageList_Create(765, 164) _GUIImageList_AddBitmap($hImageBtn_1, "c:\path\to\ankieta_clean.bmp") _GUICtrlButton_SetImageList($ankieta1, $hImageBtn_1, 4) GUICtrlSetOnEvent(-1, "On_Ankieta1") The problem - if i uncomment GUICtrlSetColor, color of text changes, but button is just plain gray (no image). How i can change text color not touching image on a button here?
  2. Looking at DriveMapAdd help file shouldnt it be like: $temp1 = DriveMapAdd("H:", "\\servername\Shared", 8, "servername\"&$user, $passwd) "domain"&$user = "domainusername" where username is a variable. Taken from example in help file: https://www.autoitscript.com/autoit3/docs/functions/DriveMapAdd.htm
  3. Thank you. Enum is awesome Why didnt i knew about it earlier? As for scrollbars... When i reach end of window (gui is full) scrollbar appears, but i can not scroll. Whatever, i will think of different solution - maybe separate GUI windows for every group or something.
  4. From GUISetAccelerators() help file: So yes, if you pass single value (not array) should un-set all accelerators. Or you can pass it arrai, but with modified entry for Enter: $cEnterPressed = GUICtrlCreateDummy() Global $aAccelKeys[1][2] = [["{ENTER}", $cEnterPressed]] GUISetAccelerators($aAccelKeys) if GUICtrlSetState($Button12,$GUI_FOCUS) then GUISetAccelerators(0) endif
  5. Try maybe using some variable in While statement and change it to 0 when u want to end the loop? #include <MsgBoxConstants.au3> Local $q_run = 1 Local $_button_id While $q_run sleep(3000) If MsgBox(1,"","Your code here...") = $IDOK Then ;if you press OK button... $q_run = 0 ;$run will be set to 0 and WHILE loop will end... EndIf WEnd MsgBox(0,"","Exiting - outside WHILE loop!")
  6. Looked at it - looks awesome, but of course... I have no idea what i am doing wrong. Looks like $aBet (being a result of _GUIScrollbars_Size) is not an array (so some error in ..._Size function). Before that point - $aBet is an array. Line 128: #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiScrollBars.au3> #include <StructureConstants.au3> #include <ScrollBarConstants.au3> #include <Array.au3> #include "GUIScrollbars_Size.au3" Opt("GUIResizeMode",$GUI_DOCKALL) #Region ### VAR/CONST DECLARATION ### Const $MANUFACTURER = 1 Const $MODEL = 2 Const $GROUP1 = 3 Const $GROUP2 = 4 Const $LAN = 5 Const $GSM = 6 Const $NONET = 7 Const $DISTANCE_S = 8 Const $DISTANCE_M = 9 Const $DISTANCE_L = 10 Const $PLAYER = 11 Const $EXTENDER = 12 Const $LICENSE = 13 Const $ADD_MON = 14 Const $GROUP = 15 Const $REM_MON = 16 Global $array2d_ControlID[2][17] $array2d_ControlID[0][0] = 1 ;because we start with 1 set of controls already created Local $_y_offset = 60 Local $_y_base_offset = 60 Global $player_list = "|Player 1|Player 2|Player 3|Player 4" Global $manufacturer_list = "|Samsung|LG|Iiyama|Philips|NEC" Global $samsung_list = "" Global $iiyama_list = "" Global $nec_list = "" Global $philips_list = "" Global $lg_list = "" ;*** USED FOR SCROLLBARS $iH_Aperture = 400 $iV_Aperture = 400 $iH_Scroll = 1000 $iV_Scroll = 1000 ;*** END OF SCROLLBARS VARS #EndRegion ### VAR/CONST DECLARATION ### #Region ### START Koda GUI section ### Form=d:\users\azpr196\documents\konfigurator ds autoit\form12.kxf ;*********** LABELS ***************** $hGUI = GUICreate("Form1", 1399, 682, 113, 102, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) $aBet = _GUIScrollbars_Size(0, 550, 300, 300) GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") _GUIScrollBars_Init($hGUI) _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, True) _GUIScrollBars_ShowScrollBar($hGUI, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aBet[2]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $aBet[3]) $Label1 = GUICtrlCreateLabel("Producent", 48, 88, 53, 17) $Label2 = GUICtrlCreateLabel("Model", 144, 88, 33, 17) $Label3 = GUICtrlCreateLabel("Grupa", 304, 88, 33, 17) $Label4 = GUICtrlCreateLabel("Ekstender", 712, 88, 52, 17) ;********** GENERAL OPTIONS ******** ;********** 1st MONITOR ************ $array2d_ControlID[1][$MANUFACTURER] = GUICtrlCreateCombo("", 48, 120, 81, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1,$manufacturer_list) $array2d_ControlID[1][$MODEL] = GUICtrlCreateCombo("", 144, 120, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $array2d_ControlID[1][$GROUP] = GUICtrlCreateInput("1", 304, 120, 41, 21) $array2d_ControlID[1][$GROUP1] = GUICtrlCreateGroup("Połączenie sieciowe", 360, 104, 153, 57) $array2d_ControlID[1][$LAN] = GUICtrlCreateRadio("LAN", 368, 128, 41, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[1][$GSM] = GUICtrlCreateRadio("GSM", 408, 128, 41, 17) $array2d_ControlID[1][$NONET] = GUICtrlCreateRadio("Brak", 456, 128, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[1][$GROUP2] = GUICtrlCreateGroup("Odległosć do poprzedniego", 520, 104, 169, 57) $array2d_ControlID[1][$DISTANCE_S] = GUICtrlCreateRadio("< 20m", 528, 128, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[1][$DISTANCE_M] = GUICtrlCreateRadio("20-50m", 576, 128, 57, 17) $array2d_ControlID[1][$DISTANCE_L] = GUICtrlCreateRadio("> 50m", 632, 128, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[1][$PLAYER] = GUICtrlCreateCombo("Player", 864, 120, 89, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1,$player_list) $array2d_ControlID[1][$EXTENDER] = GUICtrlCreateCombo("Extender", 704, 120, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[1][$LICENSE] = GUICtrlCreateCheckbox("Licencja", 968, 120, 65, 17) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[1][$ADD_MON] = GUICtrlCreateButton("Dodaj monitor", 1048, 104, 59, 57, $BS_BITMAP) GUICtrlSetImage(-1, "D:\Users\azpr196\Documents\Konfigurator DS autoit\image_add.bmp", -1) $array2d_ControlID[0][$ADD_MON]= $array2d_ControlID[1][$ADD_MON] GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ### INITIALIZE ### _GetNec() _GetSamsung() _GetLG() _GetIiyama() _GetPhilips() #EndRegion ### INITIALIZE ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_RESTORE _GUIScrollbars_Restore($hGUI, True, False) Case $array2d_ControlID[0][$ADD_MON] _AddMon() MsgBox(0,"","Monitors so far: "&$array2d_ControlID[0][0]) $aBet = _GUIScrollbars_Size(0, $_y_offset + $_y_base_offset, 300, 300) If IsArray($aBet) Then _ArrayDisplay($aBet) Else MsgBox(0,"","$aBet is NOT an array! Whats going on?!") EndIf _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aBet[2]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $aBet[3]) Case $array2d_ControlID[0][$REM_MON] _RemMon() Case $array2d_ControlID[1][$MANUFACTURER] $manufact = GUICtrlRead($array2d_ControlID[1][$MANUFACTURER]) Select Case $manufact = "Samsung" GUICtrlSetData($array2d_ControlID[1][$MODEL],$samsung_list) Case $manufact = "NEC" GUICtrlSetData($array2d_ControlID[1][$MODEL],$nec_list) Case $manufact = "Iiyama" GUICtrlSetData($array2d_ControlID[1][$MODEL],$iiyama_list) Case $manufact = "LG" GUICtrlSetData($array2d_ControlID[1][$MODEL],$lg_list) Case $manufact = "Philips" GUICtrlSetData($array2d_ControlID[1][$MODEL],$philips_list) EndSelect EndSwitch WEnd Func _RefreshAll() MsgBox(0,"","Refresh function here...") EndFunc Func _AddMon() Local $i $array2d_ControlID[0][0] += 1 $i = $array2d_ControlID[0][0] ReDim $array2d_ControlID[UBound($array2d_ControlID)+1][UBound($array2d_ControlID,2)] $array2d_ControlID[$i][$MANUFACTURER] = GUICtrlCreateCombo("", 48, 120+$_y_offset, 81, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1,$manufacturer_list) $array2d_ControlID[$i][$MODEL] = GUICtrlCreateCombo("", 144, 120+$_y_offset, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $array2d_ControlID[$i][$GROUP] = GUICtrlCreateInput("", 304, 120+$_y_offset, 41, 21) GUICtrlSetData(-1,GUICtrlRead($array2d_ControlID[$i-1][$GROUP])) $array2d_ControlID[$i][$GROUP1] = GUICtrlCreateGroup("Połączenie sieciowe", 360, 104+$_y_offset, 153, 57) $array2d_ControlID[$i][$LAN] = GUICtrlCreateRadio("LAN", 368, 128+$_y_offset, 41, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[$i][$GSM] = GUICtrlCreateRadio("GSM", 408, 128+$_y_offset, 41, 17) $array2d_ControlID[$i][$NONET] = GUICtrlCreateRadio("Brak", 456, 128+$_y_offset, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[$i][$GROUP2] = GUICtrlCreateGroup("Odległosć do poprzedniego", 520, 104+$_y_offset, 169, 57) $array2d_ControlID[$i][$DISTANCE_S] = GUICtrlCreateRadio("< 20m", 528, 128+$_y_offset, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[$i][$DISTANCE_M] = GUICtrlCreateRadio("20-50m", 576, 128+$_y_offset, 57, 17) $array2d_ControlID[$i][$DISTANCE_L] = GUICtrlCreateRadio("> 50m", 632, 128+$_y_offset, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[$i][$PLAYER] = GUICtrlCreateCombo("Player", 864, 120+$_y_offset, 89, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1,$player_list) If GUICtrlRead($array2d_ControlID[$i-1][$PLAYER]) <> "" Then GUICtrlSetData(-1,GUICtrlRead($array2d_ControlID[$i-1][$PLAYER])) $array2d_ControlID[$i][$EXTENDER] = GUICtrlCreateCombo("Extender", 704, 120+$_y_offset, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[$i][$LICENSE] = GUICtrlCreateCheckbox("Licencja", 968, 120+$_y_offset, 65, 17) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[$i][$ADD_MON] = GUICtrlCreateButton("Dodaj monitor", 1048, 104+$_y_offset, 59, 57, $BS_BITMAP) GUICtrlSetImage(-1, "D:\Users\azpr196\Documents\Konfigurator DS autoit\image_add.bmp", -1) GUICtrlSetState($array2d_ControlID[$i-1][$ADD_MON],$GUI_HIDE) $array2d_ControlID[$i][$REM_MON] = GUICtrlCreateButton("Usuń monitor", 1148, 104+$_y_offset, 80, 57, $BS_BITMAP) GUICtrlSetState($array2d_ControlID[$i-1][$REM_MON],$GUI_HIDE) $array2d_ControlID[0][$ADD_MON] = $array2d_ControlID[$i][$ADD_MON] $array2d_ControlID[0][$REM_MON] = $array2d_ControlID[$i][$REM_MON] $_y_offset += $_y_base_offset EndFunc Func _RemMon() If $array2d_ControlID[0][0] > 1 Then Local $i, $aa=1, $ctrl $array2d_ControlID[0][0] -= 1 $i = $array2d_ControlID[0][0] + 1 For $aa=1 To (UBound($array2d_ControlID,2)-1) Step 1 $ctrl = $array2d_ControlID[$i][$aa] GUICtrlDelete($ctrl) Next $i -= 1 $array2d_ControlID[0][$ADD_MON] = $array2d_ControlID[$i][$ADD_MON] $array2d_ControlID[0][$REM_MON] = $array2d_ControlID[$i][$REM_MON] GUICtrlSetState($array2d_ControlID[$i][$ADD_MON],$GUI_SHOW) GUICtrlSetState($array2d_ControlID[$i][$REM_MON],$GUI_SHOW) $_y_offset -= $_y_base_offset ReDim $array2d_ControlID[UBound($array2d_ControlID)-1][UBound($array2d_ControlID,2)] EndIf EndFunc Func _GetPhilips() Global $philips_array = _ParseCSV("philips.csv",";","Cant read from philips.csv file!",True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) If $philips_array = False Then Return 1 Global $philips_models_names[$philips_array[0][0]+1] $philips_models_names[0] = $philips_array[0][0] For $i = $philips_array[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $philips_models_names[$i] = $philips_array[$i][4] ;Next Next $philips_list = "|"&_ArrayToString($philips_models_names,"|",1) EndFunc Func _GetIiyama() Global $iiyama_array = _ParseCSV("yi.csv",";","Cant read from yi.csv file!",True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) If $iiyama_array = False Then Return 1 Global $yi_models_names[$iiyama_array[0][0]+1] $yi_models_names[0] = $iiyama_array[0][0] For $i = $iiyama_array[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $yi_models_names[$i] = $iiyama_array[$i][4] ;Next Next $iiyama_list = "|"&_ArrayToString($yi_models_names,"|",1) EndFunc Func _GetLG() Global $lg_models = _ParseCSV("LG.csv",";","Cant read from LG.csv file!",True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) Global $lg_models_names[$lg_models[0][0]+1] $lg_models_names[0] = $lg_models[0][0] For $i = $lg_models[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $lg_models_names[$i] = $lg_models[$i][4] ;Next Next $lg_list = "|"&_ArrayToString($lg_models_names,"|",1) EndFunc ;read Samsung data from CSV file Func _GetSamsung() Global $samsung_models = _ParseCSV("SAMSUNG.csv",";","Cant read from SAMSUNG.csv file!",True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) ;_ArrayDisplay($samsung_models) Global $samsung_models_names[$samsung_models[0][0]+1] $samsung_models_names[0] = $samsung_models[0][0] For $i = $samsung_models[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $samsung_models_names[$i] = $samsung_models[$i][4] ;Next Next $samsung_list = "|"&_ArrayToString($samsung_models_names,"|",1) EndFunc ;read NEC data from CSV file Func _GetNec() Global $nec_models = _ParseCSV("NEC.csv",";","Cant read from NEC.csv file!",True) ;get all NEC data into 2D array (0,0 and 0,1 holds number of columns/rows) ;_ArrayDisplay($samsung_models) Global $nec_models_names[$nec_models[0][0]+1] $nec_models_names[0] = $nec_models[0][0] For $i = $nec_models[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $nec_models_names[$i] = $nec_models[$i][4] ;Next Next $nec_list = "|"&_ArrayToString($nec_models_names,"|",1) EndFunc ;****************** CSV to Array (2D) Func _ParseCSV($f,$Dchar,$error,$skip) Local $array[500][500] Local $line = "" $i = 0 $file = FileOpen($f,0) If $file = -1 Then MsgBox(0, "Error", $error) Return False EndIf ;skip 1st line If $skip Then $line = FileReadLine($file) While 1 $i = $i + 1 Local $line = FileReadLine($file) If @error = -1 Then ExitLoop $row_array = StringSplit($line,$Dchar) If $i == 1 Then $row_size = UBound($row_array) If $row_size <> UBound($row_array) Then MsgBox(0, "Error", "Row: " & $i & " has different size ") $row_size = UBound($row_array) $array = _arrayAdd_2d($array,$i,$row_array,$row_size) WEnd FileClose($file) $array[0][0] = $i-1 ;stores number of lines $array[0][1] = $row_size -1 ; stores number of data in a row (data corresponding to index 0 is the number of data in a row actually that's way the -1) Return $array EndFunc Func _arrayAdd_2d($array,$inwhich,$row_array,$row_size) For $i=1 To $row_size -1 Step 1 $array[$inwhich][$i] = $row_array[$i] Next Return $array EndFunc ;***************************************************** Func _Scroll_Move_Corr($hWnd) Local $aCorr[2] $aCorr[0] = _GUIScrollBars_GetScrollInfoPos($hWnd, $SB_HORZ) * Int($iH_Scroll / _GUIScrollBars_GetScrollInfoMax($hWnd, $SB_HORZ)) $aCorr[1] = _GUIScrollBars_GetScrollInfoPos($hWnd, $SB_VERT) * Int($iV_Scroll / _GUIScrollBars_GetScrollInfoMax($hWnd, $SB_VERT)) Return $aCorr EndFunc Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_VSCROLL Func _Scrollbars_WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $xChar, $xPos Local $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $xChar = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Page = DllStructGetData($tSCROLLINFO, "nPage") $xPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $xPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_LINELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGELEFT DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGERIGHT DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_HSCROLL Any idea what i did wrong?
  7. Hi! I did some script: #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiScrollBars.au3> #include <StructureConstants.au3> Opt("GUIResizeMode",$GUI_DOCKALL) #Region ### VAR/CONST DECLARATION ### Const $MANUFACTURER = 1 Const $MODEL = 2 Const $GROUP1 = 3 Const $GROUP2 = 4 Const $LAN = 5 Const $GSM = 6 Const $NONET = 7 Const $DISTANCE_S = 8 Const $DISTANCE_M = 9 Const $DISTANCE_L = 10 Const $PLAYER = 11 Const $EXTENDER = 12 Const $LICENSE = 13 Const $ADD_MON = 14 Const $GROUP = 15 Global $array2d_ControlID[50][16] $array2d_ControlID[0][0] = 1 ;because we start with 1 set of controls already created Local $_y_offset = 60 Local $_y_base_offset = 60 #EndRegion ### VAR/CONST DECLARATION ### #Region ### START Koda GUI section ### Form=d:\users\azpr196\documents\konfigurator ds autoit\form12.kxf ;*********** LABELS ***************** $hGUI = GUICreate("Form1", 1399, 682, 113, 102, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) $Label1 = GUICtrlCreateLabel("Producent", 48, 88, 53, 17) $Label2 = GUICtrlCreateLabel("Model", 144, 88, 33, 17) $Label3 = GUICtrlCreateLabel("Grupa", 304, 88, 33, 17) $Label4 = GUICtrlCreateLabel("Ekstender", 712, 88, 52, 17) ;********** GENERAL OPTIONS ******** ;********** 1st MONITOR ************ $array2d_ControlID[1][$MANUFACTURER] = GUICtrlCreateCombo("Samsung", 48, 120, 81, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $array2d_ControlID[1][$MODEL] = GUICtrlCreateCombo("Model", 144, 120, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $array2d_ControlID[1][$GROUP] = GUICtrlCreateInput("1", 304, 120, 41, 21) $array2d_ControlID[1][$GROUP1] = GUICtrlCreateGroup("Połączenie sieciowe", 360, 104, 153, 57) $array2d_ControlID[1][$LAN] = GUICtrlCreateRadio("LAN", 368, 128, 41, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[1][$GSM] = GUICtrlCreateRadio("GSM", 408, 128, 41, 17) $array2d_ControlID[1][$NONET] = GUICtrlCreateRadio("Brak", 456, 128, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[1][$GROUP2] = GUICtrlCreateGroup("Odległosć do poprzedniego", 520, 104, 169, 57) $array2d_ControlID[1][$DISTANCE_S] = GUICtrlCreateRadio("< 20m", 528, 128, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[1][$DISTANCE_M] = GUICtrlCreateRadio("20-50m", 576, 128, 57, 17) $array2d_ControlID[1][$DISTANCE_L] = GUICtrlCreateRadio("> 50m", 632, 128, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[1][$PLAYER] = GUICtrlCreateCombo("Player", 864, 120, 89, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1,"|Player 1|Player 2|Player 3") $array2d_ControlID[1][$EXTENDER] = GUICtrlCreateCombo("Extender", 704, 120, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[1][$LICENSE] = GUICtrlCreateCheckbox("Licencja", 968, 120, 65, 17) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[1][$ADD_MON] = GUICtrlCreateButton("Dodaj monitor", 1048, 104, 59, 57, $BS_BITMAP) GUICtrlSetImage(-1, "D:\Users\azpr196\Documents\Konfigurator DS autoit\image_add.bmp", -1) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ### INITIALIZE ### _GUIScrollBars_Init($hGUI) #EndRegion ### INITIALIZE ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $array2d_ControlID[1][$ADD_MON] _AddMon() EndSwitch WEnd Func _RefreshAll() MsgBox(0,"","Refresh function here...") EndFunc Func _AddMon() Local $i $array2d_ControlID[0][0] += 1 $i = $array2d_ControlID[0][0] $array2d_ControlID[$i][$MANUFACTURER] = GUICtrlCreateCombo("Samsung", 48, 120+$_y_offset, 81, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $array2d_ControlID[$i][$MODEL] = GUICtrlCreateCombo("Model", 144, 120+$_y_offset, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $array2d_ControlID[$i][$GROUP] = GUICtrlCreateInput("", 304, 120+$_y_offset, 41, 21) GUICtrlSetData(-1,GUICtrlRead($array2d_ControlID[$i-1][$GROUP])) $array2d_ControlID[$i][$GROUP1] = GUICtrlCreateGroup("Połączenie sieciowe", 360, 104+$_y_offset, 153, 57) $array2d_ControlID[$i][$LAN] = GUICtrlCreateRadio("LAN", 368, 128+$_y_offset, 41, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[$i][$GSM] = GUICtrlCreateRadio("GSM", 408, 128+$_y_offset, 41, 17) $array2d_ControlID[$i][$NONET] = GUICtrlCreateRadio("Brak", 456, 128+$_y_offset, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[$i][$GROUP2] = GUICtrlCreateGroup("Odległosć do poprzedniego", 520, 104+$_y_offset, 169, 57) $array2d_ControlID[$i][$DISTANCE_S] = GUICtrlCreateRadio("< 20m", 528, 128+$_y_offset, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $array2d_ControlID[$i][$DISTANCE_M] = GUICtrlCreateRadio("20-50m", 576, 128+$_y_offset, 57, 17) $array2d_ControlID[$i][$DISTANCE_L] = GUICtrlCreateRadio("> 50m", 632, 128+$_y_offset, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $array2d_ControlID[$i][$PLAYER] = GUICtrlCreateCombo("Player", 864, 120+$_y_offset, 89, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1,"|Player 1|Player 2|Player 3") GUICtrlSetData(-1,GUICtrlRead($array2d_ControlID[$i-1][$PLAYER])) $array2d_ControlID[$i][$EXTENDER] = GUICtrlCreateCombo("Extender", 704, 120+$_y_offset, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[$i][$LICENSE] = GUICtrlCreateCheckbox("Licencja", 968, 120+$_y_offset, 65, 17) GUICtrlSetState(-1, $GUI_DISABLE) $array2d_ControlID[$i][$ADD_MON] = GUICtrlCreateButton("Dodaj monitor", 1048, 104+$_y_offset, 59, 57, $BS_BITMAP) GUICtrlSetImage(-1, "D:\Users\azpr196\Documents\Konfigurator DS autoit\image_add.bmp", -1) GUICtrlSetState($array2d_ControlID[$i-1][$ADD_MON],$GUI_HIDE) $array2d_ControlID[1][$ADD_MON] = $array2d_ControlID[$i][$ADD_MON] $_y_offset += $_y_base_offset EndFunc Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iClientMaxX = $__g_aSB_WindowInfo[$iIndex][1] $iCharX = $__g_aSB_WindowInfo[$iIndex][2] $iCharY = $__g_aSB_WindowInfo[$iIndex][3] $iMax = $__g_aSB_WindowInfo[$iIndex][7] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) ; Retrieve the dimensions of the client area. $iClientX = BitAND($lParam, 0x0000FFFF) $iClientY = BitShift($lParam, 16) $__g_aSB_WindowInfo[$iIndex][4] = $iClientX $__g_aSB_WindowInfo[$iIndex][5] = $iClientY ; Set the vertical scrolling range and page size DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", $iMax) DllStructSetData($tSCROLLINFO, "nPage", $iClientY / $iCharY) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ; Set the horizontal scrolling range and page size DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", 2 + $iClientMaxX / $iCharX) DllStructSetData($tSCROLLINFO, "nPage", $iClientX / $iCharX) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharX, $iPosX Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharX = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; ; Get all the horizontal scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosX = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosX $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $iMin, $iMax Switch $iScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_HSCROLL Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharY, $iPosY Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharY = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; Get all the vertial scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosY = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosY $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $iScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMin) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMax) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosY) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos)) $iPosY = $iPos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL Any tips how to do "scrolling" when i add more controls (using a button in GUI)?
  8. Ok. I managed to recode my script so it uses now GUIGetMsg(). And what i am thinking of... I can run throuh all array elements and copy needed ctrlID's to separate, 1D array (and i can run this every 1sec or something like that so new array will be up to date). Since i am using guigetmsg() is it possible to somehow code: Switch GUIGetMsg() Case $something ... Case ($val1 to $valN where N is size of array) ... EndSwitch Size of array can change any second (so number of control IDs can change). Maybe somehow i can use dummy control here?
  9. What you did is redefined what enter does... (using accelerators)... That kind of messing with keyboard input will mess ANY program in ANY language - it is just like you change keyboard layout in windows... It is changed for everything you do. So imo it is not AutoIt fault or constraint. It is strictly programmer error Enter is strictly tied to dummy control and looses its "overal, standard" behaviour. In general - if u need some shortcuts use shortcuts like mix of ctrl+something etc. Not enter, esc or any other single, commonly used key. Some time ago i did the same thing with ESC key and ctrl+x shortcut (default for "cut")...
  10. But using only keyboard to control Autoit-made GUI works out of the box! #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $button1, $button2, $label1 ;WE MUST CREATE GUI: GUICreate("MyGui",@DesktopWidth,@DesktopHeight) $button1 = GUICtrlCreateButton("Button 1",100,100,100,100) ;we create button 1, size 100x100 and starting position (top-left corner) 100/100 $button2 = GUICtrlCreateButton("Button 2",100+120,100,100,100) ; we create second button, to the right of first one $label1 = GUICtrlCreateLabel("This is some sample label, it is not a button",100,100+120,200,100) ;some label - control that shouldnt be accessible through {tab} GUISetState(@SW_SHOW) ;needed so GUI will be shown after script starts running While 1 Switch GUIGetMsg() ;we are polling for some feedback from user, if any control is clicked/changed etc... Case $GUI_EVENT_CLOSE ;close the gui when we press "close window" button ({esc} also works) Exit Case $button1 ;when we press button 1 - let it be by mouse or {tab}/{enter}... MsgBox(0,"","Button 1 pressed!") ;do something Case $button2 ;when we press button 2 - let it be by mouse or {tab}/{enter}... MsgBox(0,"","Button 2 pressed!") ;do something EndSwitch WEnd Try above code - it just works using {tab} and {enter} - no need to program anything special there! Just create controls, buttons etc.
  11. So in general - you want to be able to TAB through all the buttons and press them using Enter? - using GUI without a mouse? In taht case look at https://www.autoitscript.com/autoit3/docs/appendix/GUIStyles.htm There are some styles that allow/disallow of selecting given control using TAB key etc. {Enter} key works out-of-the box for me (i can {tab} through buttons in my GUI and pressing {enter} is the same as mouse click on selected button). GuiSetAccelerators is for creating keyboard shortcuts for GUI controls (including buttons), not for managing [enter] and [tab].
  12. Maybe try WinExists https://www.autoitscript.com/autoit3/docs/functions/WinExists.htm If WinExists("AutoIt Forums") Then WinActivate("AutoIt Forums") (DO SOMETHING) EndIf It did the trick for me - i am checking if certain window exists (in that case - window containing whole/part name of webpage), set this window as active and do the auto-magic. Of course it isnt running many scripts, just 1 script with different functions for different windows. During script execution (eg when your mouse moves etc) you should not touch any controls (mouse, keyboard...).
  13. I was using similar prog for creating some online tutorials... So not game automation Just automation - thats whatfor AutoIt is imo.
  14. lorenkinzel thank you, but thats not what i need... My script is a bit messy and quiet big so i will write general idea: Button1 = BUTTON_CREATE1 Button2 = BUTTON_CREATE2 OnPressButton1 = Function_that_creates_new_TAB OnPressButton2 = Function_that_creates_new_Controls_on_current_TAB (i also have buttons for removing last created controls on curently selected tab and for removing last added tab) Data is stored like this: $ALL_DATA [$tab_number_stores_rows_number][$row/control_set_number] (so $ALL_DATA[2][x] says that on TAB2 we have (VALUE_OF_DATA_ALL[2][0]) rows/added controls. Controls are stored in $controlIDs[14] (every press of a button 2 adds 15 controls) and is stored in proper $DATA_ALL[$tab_selected][$DATA_ALL[$tab_selected][0]+1] In case u want to look at the code: #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> Opt ("GUIOnEventMode",1) Opt ("GUICoordMode",1) #Region CONSTANTS Const $GUIWidth = 1500 Const $GUIHeight = 800 Const $GROUP_TAB = 0 Const $MANUFACTURER = 1 Const $MODEL = 2 Const $LAN = 3 Const $DISTANCE_LABEL = 11 Const $DISTANCE = 4 Const $EXTENDER_LABEL = 12 Const $EXTENDER = 5 Const $MANUFACTURER_LABEL = 6 Const $MODEL_LABEL = 7 Const $NET = 8 Const $GSM = 9 Const $NET_NONE = 10 #EndRegion CONSTANTS #Region VARIABLES Global $max_groups[20], $max_monitors = 0, $samsung_models_list Global $data_all[1][15] ;1st dim is group, 2nd dim is subgroup (that holds array of data for each subgroup) Global $ids [13] ;holds IDs and some data for each subgroup Global $groups_subgroups[2] = [0,0] Global $x_off = 170 Global $y_off = 20 Global $extenders_list = "|Kramer PT101Hxl|Kramer PT101HDCP|Kramer 602R/T|Kramer C-FODM/FODM|Kramer C-FOHM/FOHM|Kramer TP573/TP574|Inny" Global $server_list = "|Dell R210 II i3, 4GB, 2x1TB|OPTIMUS IRON R11041 E3-1220v3/8GB/2x500GB|Fujitsu PRIMERGY RX100S7 E3-1220 4GB 2x500GB|HP DL320e Gen8 E3-1220v|Inny|Brak (własny)" Global $player_list = "|OPS|MiniPC|IPC" #EndRegion VARIABLES #Region GUI $max_groups[0]=0 $gui_main = GUICreate("Konfigurator DS", $GUIWidth, $GUIHeight, -1, -1) ;Main menu on top $system_label = GUICtrlCreateLabel("Wybierz platformę",20,20,150) $system = GUICtrlCreateCombo("",20,20+$y_off) GUICtrlSetData(-1,"|(SaaS) Media4Display|Media4Display|(SaaS) Strong Signage|Strong Signage|MagicInfo Lite|MagicInfo Premium S|MagicInfo Premium I") $player_label = GUICtrlCreateLabel("Wybierz odtwarzacze",20+$x_off,20,150) $player = GUICtrlCreateCombo("",20+$x_off,20+$y_off) GUICtrlSetState(-1,$GUI_DISABLE) $server_label = GUICtrlCreateLabel("Wybierz serwer",20+2*$x_off,20,150) $server = GUICtrlCreateCombo("",20+2*$x_off,20+$y_off) GUICtrlSetState(-1,$GUI_DISABLE) GUICtrlSetData(-1,$server_list) $add_group = GUICtrlCreateButton("Dodaj grupę monitorów",1310,20,150) $add_monitor = GUICtrlCreateButton("Dodaj monitor",1310,40+$y_off,150) $rem_monitor = GUICtrlCreateButton("Usuń monitor",1150,40+$y_off,150) $rem_group = GUICtrlCreateButton("Usuń grupę monitorów",1150,20,150) $tabGroups = GUICtrlCreateTab(20,100,$GUIWidth-40,$GUIHeight-140) GUICtrlCreateTabItem("") ;EVENTS GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIClose") GUICtrlSetOnEvent($add_group,"_AddGroup") GUICtrlSetOnEvent($add_monitor,"_AddMonitor") GUICtrlSetOnEvent($rem_monitor,"_RemMonitor") GUICtrlSetOnEvent($rem_group,"_RemGroup") GUICtrlSetOnEvent($system,"_ChangeSystem") ;GUICtrlSetOnEvent($ids[$DISTANCE],"_ChangeDistance") ;END EVENTS GUISetState(@SW_SHOW) #EndRegion GUI ;$data_all[0][0] = $groups_subgroups ;Holds number of GROUPS and SUBGROUPS (always in element [0,0]) $data_all[0][0] = 0 ;group count #Region EVENTS Func _GUIClose() Exit EndFunc Func _ChangeDistance() ;Polling function ;ConsoleWrite("!> DEBUG - Inside _ChangeDistance function..."&@CRLF) Sleep(250) For $i=1 To $max_groups[0] Step 1 For $j=1 to $max_groups[$i] Step 1 $tmp = $data_all[$i][$j] ;ConsoleWrite("!>DEBUG - $data_all["&$i&"]["&$j&"] DISTANCE SELECTED: "&$tmp[$DISTANCE]&@CRLF) If GUICtrlRead($tmp[$DISTANCE]) = ">20" Then GUICtrlSetState($tmp[$EXTENDER],$GUI_ENABLE) ElseIf GUICtrlRead($tmp[$DISTANCE]) = "<20" Then GUICtrlSetState($tmp[$EXTENDER],$GUI_DISABLE) EndIf Next Next ;MsgBox($MB_SYSTEMMODAL,"","Control ID that triggered event: "&@GUI_CtrlId) EndFunc Func _ChangeSystem() Local $tmp Local $system_value = GUICtrlRead($system) If $system_value = "MagicInfo Lite" OR $system_value = "MagicInfo Premium S" Then GUICtrlSetData($player,"|MagicInfo") GUICtrlSetState($player,$GUI_DISABLE) For $i=1 To $max_groups[0] Step 1 For $j=1 to $max_groups[$i] Step 1 $tmp = $data_all[$i][$j] GUICtrlSetState($tmp[$MANUFACTURER],$GUI_DISABLE) Next Next Else For $i=1 To $max_groups[0] Step 1 For $j=1 to $max_groups[$i] Step 1 $tmp = $data_all[$i][$j] GUICtrlSetState($tmp[$MANUFACTURER],$GUI_ENABLE) Next Next MsgBox($MB_SYSTEMMODAL,"","$player state: "&GUICtrlGetState($player)) If GUICtrlGetState($player) = 144 Then GUICtrlSetData($player,$player_list) GUICtrlSetState($player,$GUI_ENABLE) EndIf EndIf If $system_value = "Media4Display" OR $system_value = "Strong Signage" OR $system_value = "MagicInfo Premium I" Then GUICtrlSetData($server,$server_list) GUICtrlSetState($server,$GUI_ENABLE) Else GUICtrlSetData($server,"") GUICtrlSetState($server,$GUI_DISABLE) EndIf EndFunc Func _AddGroup() $max_groups[0] += 1 $max_groups[$max_groups[0]] = 1 ReDim $data_all[UBound($data_all)+1][UBound($data_all,2)] $ids[$GROUP_TAB] = GUICtrlCreateTabItem("Grupa "&$max_groups[0]) $ids[$MANUFACTURER_LABEL] = GUICtrlCreateLabel("Producent",40,130,100) $ids[$MANUFACTURER] = GUICtrlCreateCombo("Samsung",40,150,100) If (GUICtrlRead($system)) = "MagicInfo Lite" OR (GUICtrlRead($system)) = "MagicInfo Premium S" Then GUICtrlSetState($ids[$MANUFACTURER],$GUI_DISABLE) EndIf $ids[$MODEL_LABEL] = GUICtrlCreateLabel("Model",150,130,150) $ids[$MODEL] = GUICtrlCreateCombo("",150,150,150) GUICtrlSetData(-1,$samsung_models_list) $ids[$NET] = GUICtrlCreateGroup("Podłączenie do sieci",260+50,130,150,40) $ids[$LAN] = GUICtrlCreateRadio("LAN",265+50,145) GUICtrlSetState(-1,$GUI_CHECKED) $ids[$GSM] = GUICtrlCreateRadio("GSM",315+50,145) $ids[$NET_NONE] = GUICtrlCreateRadio("Brak",365+50,145) GUICtrlCreateGroup("",-99,-99,1,1) ;end of radio buttons group $ids[$DISTANCE_LABEL] = GUICtrlCreateLabel("Odległość do poprzedniego monitora (m)",470,130) ;$ids[$DISTANCE] = GUICtrlCreateCombo("<20",540,150,50) ;GUICtrlSetData(-1,">20") $ids[$EXTENDER_LABEL] = GUICtrlCreateLabel("Wybierz extender",670,130) ;GUICtrlSetData(-1,$extenders_list) ;$ids[$EXTENDER] = GUICtrlCreateCombo("",670,150,150) ;_ArrayDisplay($ids) $ids[$DISTANCE] = $ids[$MANUFACTURER] $ids[$EXTENDER] = $ids[$MANUFACTURER] ;GUICtrlSetState(-1,$GUI_DISABLE) GUICtrlCreateTabItem("") $data_all[$max_groups[0]][1] = $ids EndFunc Func _RemGroup() If $max_groups[0] < 2 Then MsgBox($MB_SYSTEMMODAL,"Konfigurator DS","Nie mozesz usunąć jedynej grupy!") Return 1 EndIf Local $tmp = $data_all[UBound($data_all)-1][1] ;_ArrayDisplay($data_all[UBound($data_all)-1][1]) GUICtrlDelete($tmp[$GROUP_TAB]) ReDim $data_all[UBound($data_all)-1][UBound($data_all,2)] $max_groups[0] -= 1 $max_groups[$max_groups[0]] = 0 EndFunc Func _AddMonitor() ;$ids="" Local $group_no = GUICtrlRead($tabGroups)+1 Local $y_move = 45*$max_groups[$group_no] $max_groups[$group_no] += 1 GUISwitch($gui_main,GUICtrlRead($tabGroups,1)) $ids[$MANUFACTURER] = GUICtrlCreateCombo("Samsung",40,150+$y_move,100) If (GUICtrlRead($system)) = "MagicInfo Lite" OR (GUICtrlRead($system)) = "MagicInfo Premium S" Then GUICtrlSetState($ids[$MANUFACTURER],$GUI_DISABLE) EndIf $ids[$MODEL] = GUICtrlCreateCombo("",150,150+$y_move,150) $ids[$NET] = GUICtrlCreateGroup("Podłączenie do sieci",260+50,130+$y_move,150,40) $ids[$LAN] = GUICtrlCreateRadio("LAN",265+50,145+$y_move) GUICtrlSetState(-1,$GUI_CHECKED) $ids[$GSM] = GUICtrlCreateRadio("GSM",315+50,145+$y_move) $ids[$NET_NONE] = GUICtrlCreateRadio("Brak",365+50,145+$y_move) GUICtrlCreateGroup("",-99,-99,1,1) ;end of radio buttons group $ids[$DISTANCE] = GUICtrlCreateCombo("<20",540,150+$y_move,50) GUICtrlSetData(-1,">20") $ids[$EXTENDER] = GUICtrlCreateCombo("",670,150+$y_move,150) GUICtrlSetState(-1,$GUI_DISABLE) GUICtrlSetData(-1,$extenders_list) $ids[$GROUP_TAB] = $ids[$MANUFACTURER] $ids[$MANUFACTURER_LABEL] = $ids[$MANUFACTURER] $ids[$MODEL_LABEL] = $ids[$MANUFACTURER] $ids[$DISTANCE_LABEL] = $ids[$MANUFACTURER] $ids[$EXTENDER_LABEL] = $ids[$MANUFACTURER] ;MsgBox($MB_SYSTEMMODAL,"","Group no: "&$group_no&@CRLF&"Monitor to add: "&$max_groups[$group_no]&@CRLF&"UBounds data_all: "&UBound($data_all)&" x "&UBound($data_all,2)) $data_all[$group_no][$max_groups[$group_no]] = $ids $data_all[$group_no][0] += 1 ;_ArrayDisplay($ids) GUICtrlCreateTabItem("") ;***************************************************************** EndFunc Func _RemMonitor() Local $group_no = GUICtrlRead($tabGroups)+1 Local $mon_no = $max_groups[$group_no] If $mon_no < 2 Then MsgBox($MB_SYSTEMMODAL,"Konfigurator DS","Nie mozesz usunąć jedynego monitora z grupy!") Return 1 EndIf Local $tmp = $data_all[$group_no][$mon_no] ;_ArrayDisplay($tmp) For $i=0 To 12 Step 1 GUICtrlDelete($tmp[$i]) Next $max_groups[$group_no] -= 1 EndFunc #EndRegion EVENTS Func _InitOnce() Local $mon1[13] $max_groups[0] += 1 $max_groups[$max_groups[0]] += 1 $mon1[$GROUP_TAB] = GUICtrlCreateTabItem("Grupa 1") $mon1[$MANUFACTURER_LABEL] = GUICtrlCreateLabel("Producent",40,130,100) $mon1[$MANUFACTURER] = GUICtrlCreateCombo("Samsung",40,150,100) $mon1[$MODEL_LABEL] = GUICtrlCreateLabel("Model",150,130,150) $mon1[$MODEL] = GUICtrlCreateCombo("",150,150,150) $mon1[$NET] = GUICtrlCreateGroup("Podłączenie do sieci",260+50,130,150,40) $mon1[$LAN] = GUICtrlCreateRadio("LAN",265+50,145) GUICtrlSetState(-1,$GUI_CHECKED) $mon1[$GSM] = GUICtrlCreateRadio("GSM",315+50,145) $mon1[$NET_NONE] = GUICtrlCreateRadio("Brak",365+50,145) GUICtrlCreateGroup("",-99,-99,1,1) ;end of radio buttons group $mon1[$DISTANCE_LABEL] = GUICtrlCreateLabel("Odległość do poprzedniego monitora (m)",470,130) ;$mon1[$DISTANCE] = GUICtrlCreateCombo("<20",540,150,50) ;GUICtrlSetData(-1,">20") $mon1[$EXTENDER_LABEL] = GUICtrlCreateLabel("Wybierz extender",670,130) ;$mon1[$EXTENDER] = GUICtrlCreateCombo("",670,150,150) ;_ArrayDisplay($mon1) $ids[$DISTANCE] = $ids[$MANUFACTURER] $ids[$EXTENDER] = $ids[$MANUFACTURER] ReDim $data_all[UBound($data_all)+1][UBound($data_all,2)] $data_all[1][1]=$mon1 ;$tmp = $data_all[1][1] ;_ArrayDisplay($tmp) ;GUICtrlSetState(-1,$GUI_DISABLE) GUICtrlCreateTabItem("") EndFunc ;****************** CSV to Array (2D) Func _ParseCSV($f,$Dchar,$error,$skip) Local $array[500][500] Local $line = "" $i = 0 $file = FileOpen($f,0) If $file = -1 Then MsgBox(0, "Error", $error) Return False EndIf ;skip 1st line If $skip Then $line = FileReadLine($file) While 1 $i = $i + 1 Local $line = FileReadLine($file) If @error = -1 Then ExitLoop $row_array = StringSplit($line,$Dchar) If $i == 1 Then $row_size = UBound($row_array) If $row_size <> UBound($row_array) Then MsgBox(0, "Error", "Row: " & $i & " has different size ") $row_size = UBound($row_array) $array = _arrayAdd_2d($array,$i,$row_array,$row_size) WEnd FileClose($file) $array[0][0] = $i-1 ;stores number of lines $array[0][1] = $row_size -1 ; stores number of data in a row (data corresponding to index 0 is the number of data in a row actually that's way the -1) Return $array EndFunc Func _arrayAdd_2d($array,$inwhich,$row_array,$row_size) For $i=1 To $row_size -1 Step 1 $array[$inwhich][$i] = $row_array[$i] Next Return $array EndFunc ;***************************************************** _InitOnce() Global $samsung_models = _ParseCSV("SAMSUNG.csv",";","Cant read from SAMSUNG.csv file!",True) ;get all SAMSUNG data into 2D array (0,0 and 0,1 holds number of columns/rows) ;_ArrayDisplay($samsung_models) Global $samsung_models_names[$samsung_models[0][0]+1] $samsung_models_names[0] = $samsung_models[0][0] For $i = $samsung_models[0][0] To 1 Step -1 ;For $j = $samsung_models[0][1] To 1 Step -1 $samsung_models_names[$i] = $samsung_models[$i][4] ;Next Next Global $samsung_models_list = "|"&_ArrayToString($samsung_models_names,"|",1) ;MsgBox($MB_SYSTEMMODAL,"","Samsung models: "&_ArrayToString($samsung_models_names,"|",1)) ;_ArrayDisplay($samsung_models_names) While 1 Sleep(500) _ChangeDistance() WEnd GUIDelete() You may compile it and see how it works. What i need - is to fill combo boxes created inside tabs dynamically (2nd combo depends what was selected in 1st combo etc...)
  15. Hello! I have a GUI oriented script with a lot of combo boxes etc. From my GUI i can add new groups (tabs) and i can also add new subgroups into each tab. That works perfectly (thanks Melba one more time!) But lets get to the point. I am using OnEvent mode. How i can check if/what value has some control from inside any of all tabs? I store IDs of those controls in arrays being part of 2d array... Getting those ID's is not simple, but iof needed i can walk through all the arrays being inside main array and grab them into separate array or something. Is there a way to create "GUICtrlSetOnEvent" for control that was added from within the GUI? Or how to create some event with group of control ID's? Maybe i can use array instead of single ctrlID? Switching to GuiGetMsg will require too much time (for me...) so i prefere to use OnEvent mode.
  16. Ok. Got it working! Thank You.
  17. No database available. So far i managed to create some functions that add/remove groups and subgroups... I have a problem with getting ControlID's into array and putting this "id" array into main data array (looks like the main array is empty): Func _AddGroup() ;resizing array $groups_subgroups[0] = $groups_subgroups[0]+1 ;adds additional group (counter) $groups_subgroups[1] = $groups_subgroups[1]+1 ;adds additional subgroup (counter) ReDim $data_all[$groups_subgroups[0]][$groups_subgroups[1]] ;resizing main data array ConsoleWrite("DEBUG - $data_all dimensions: "&UBound($data_all)&" : "&UBound($data_all,2)&@CRLF) ;adding new tab and controls GUICtrlCreateTabItem("Grupa "&$groups_subgroups[0]) $ids[$MANUFACTURER_LABEL] = GUICtrlCreateLabel("Producent",40,130,100) $ids[$MANUFACTURER] = GUICtrlCreateCombo("Samsung",40,150,100) $ids[$MODEL_LABEL] = GUICtrlCreateLabel("Model",150,130,150) $ids[$MODEL] = GUICtrlCreateCombo("",150,150,150) $ids[$NET] = GUICtrlCreateGroup("Podłączenie do sieci",260+50,130,150,40) $ids[$LAN] = GUICtrlCreateRadio("LAN",265+50,145) GUICtrlSetState(-1,$GUI_CHECKED) $ids[$GSM] = GUICtrlCreateRadio("GSM",315+50,145) $ids[$NET_NONE] = GUICtrlCreateRadio("Brak",365+50,145) GUICtrlCreateGroup("",-99,-99,1,1) ;end of radio buttons group $ids[$DISTANCE_LABEL] = GUICtrlCreateLabel("Odległość do poprzedniego monitora (m)",470,130) $ids[$DISTANCE] = GUICtrlCreateInput("5",540,150,50) $ids[$EXTENDER_LABEL] = GUICtrlCreateLabel("Wybierz extender",670,130) $ids[$EXTENDER] = GUICtrlCreateCombo("",670,150,150) GUICtrlSetState(-1,$GUI_DISABLE) GUICtrlCreateTabItem("") $data_all[UBound($data_all)-1][0] = $ids ;copies control IDs to main array in just created, new group ConsoleWrite("@DEBUG: "&$data_all[UBound($data_all)-1][0]) EndFunc I fill $ids with controlIDs. At the end i want to put this ids array into $data_all[last element][0]. ConsoleWrite and _ArrayDisplays shows empty array :/ What am i doing wrong?
  18. Hello! What i want to do is: I have data that consists of: group number, sub-group number (many subgroups in each group), many variables in each subgroup (control IDs, data taken from combo boxes etc). I was struggling with 3d array to hold all this but... It isnt easy (at least for me) to track everything. My GUI allows to add/remove groups, subgroups etc. Is there a way to use some kind of object/structure for holding all the data? Something like: Object GROUP Object SUBGROUP1 data VAR1 data VAR2 data ctrlID1 data ctrlID2 ... Close SUBGROUP ... Object SUBGROUP n ... Close SUBGROUP n Close GROUP Which way would be best/easiest (in your opinion) to deal with that kind of data?
  19. Thank You Melba. I have no idea why i missed so obvious error... Probably i was counting from "0" ;P It is working now.
  20. I am doing ReDim of this 3D array (1st dimension) and it works... But cant get 2nd dim to redim. Hello! I have something like this: Dim $controls[1][1][1];1st dim holds group, 2nd dim holds no of monitors, 3rd dim holds IDs of all controls for monitor ... Func _AddMonitor() $i = GUICtrlRead($tabGroups,1) $tab_index = GUICtrlRead($tabGroups) GUISwitch($gui_main,$i) $monitors[$tab_index] = $monitors[$tab_index]+1 ;in this array is number of monitors for each group (group no is array index) $mon = $monitors[$tab_index] ReDim $controls[UBound($controls)][UBound($controls,1)+1][UBound($controls,2)] ;I JUST WANT TO INCREASE 2nd DIMENSION BOUNDS BY 1 MsgBox(0,"",$monitors[$tab_index]) $controls[$groups-1][$monitors[$tab_index]][$MANUFACTURER] = GUICtrlCreateCombo("",40,160+20+$y_offset) ;ERROR HERE DUE TO SUBSCRIPT OR OUT OF BOUNDS $controls[$groups-1][$monitors[$tab_index]][$MODEL] = GUICtrlCreateCombo("",40+120,160+20+$y_offset) EndFunc
  21. Hi! I want to do something like: #include <ScreenCapture.au3> #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") Global $running = 1 Func Quit() $running = 0 EndFunc HotKeySet("{ESC}","Quit") MsgBox(0, "Running screen-capper!", "All fine captain!", 5) While $running If _IsPressed("0D", $hDLL) Then Sleep(800) _ScreenCapture_Capture(@MyDocumentsDir & "\Tutorial_screens\Tutorial_Image_" & @MON & "_" & @MDAY & "_" & @HOUR & @MIN & @SEC & ".jpg") While _IsPressed("0D", $hDLL) Sleep(250) WEnd EndIf WEnd DllClose($hDLL) exit 0 It works as i want it to work (takes a screenshot whenever i press enter key. But maybe is there some better/less resource hungry approach to this? It should take a screenshot when i press enter, but mentioned Enter must also work "normally". I tried registering it as a hotkey, but then it didnt worked "normaly". And you may ask "Why Enter key?". Well, i want to do some tutorials with pictures and after some analysis above method will make my work much more natural and pleasurable.
  22. How stupid of me There is no particular reason. I did previously file writes and it worked fine. But how to writo to file from clipboard? And i cant do FileRead, i must use Copy (CTRL+c) or other means to get all data. Edited: ClipGet should do the trick i suppose...
  23. I hope this is not violating any rules Here is my sample code: HotKeySet("{F5}","f_start") HotKeySet("{F9}","f_stop") HotKeySet("{ESC}","f_exit") ;Variables Global $mouse_pos[2] Global $log_x = 660, $log_y = 820, $run = 0 Run("notepad.exe") Global $notepad = WinWait("[CLASS:Notepad]", "", 10) Func f_start() $run = 1 EndFunc Func f_stop() $run = 0 EndFunc Func f_exit() WinClose($notepad, "") exit 0 EndFunc WinSetState($notepad, "", @SW_MINIMIZE) Local $hHandle = ControlGetHandle($notepad, "", "Edit1") While 1 While $run = 1 $mouse_pos = MouseGetPos() MouseClick("left",$log_x,$log_y,1,0) Send("^a") Send("^c") MouseMove($mouse_pos[0], $mouse_pos[1],0) $debug = ControlSend($notepad,"","Edit1","^v") MsgBox(0,"Debug","Successfuly sent ctrl + v to notepad: "&$debug) $run = 0 WEnd WEnd In general: Copy works (i have copied text in clipboard). But i cant get it to paste into notepad window. I tried using $hHandle, "Edit1", "Edit 1" etc. Notepad window stays empty... What i am doing wrong? Btw $debug = 1, so it SHOULD work?
  24. Hi! Is there a easy (or hard) way to grab text from chat window @ tinychat.com website? "Rooms" there are in flash, text is selectable. So basically - how to get selectable, simple text from flash object in web browser?
  25. Hi! I would like to do some parser for online, flash games. Here is a pic of one of mentioned games: Legacy_pic_raid by misioooo, on Flickr In lower-left part there is a combat log. I want to get this text and parse it. This text is selectable (like any normal text on web page) so i suppose i wont need any OCR engone or whatever. How i can get this text to autoit variable? Automatically, without user action. Best regards, misioooo
×
×
  • Create New...