I have had some trouble with creating a vertical scroll in a GUI. Not in the normal sense, though.
What I am trying to do in a newer project - an auto-clicking program- is to have the user be able to add new events by clicking on a button, but then when the GUI had no more space left for more events, then to have a vertical scroll be put in.
I have tried a bunch of things, and have left my latest attempt in the code at lines 39 - 41.
Any ideas? Or is there a totally different method for this that I seem to have overlooked?
Here is the source:
#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiScrollBars.au3> #include <ScrollBarConstants.au3> #region ### START Koda GUI section ### Form= $form1 = GUICreate("Auto Clicker", 545, 600, 196, 169) $neweventbutton = GUICtrlCreateButton("New Event", 144, 16, 75, 25) $eventtypecombo = GUICtrlCreateCombo("Left Click", 8, 64, 113, 25) GUICtrlSetData($eventtypecombo, "Right Click|WinWaitActive|Run...") $runtimesinput = GUICtrlCreateInput("1", 432, 64, 49, 21) $Label2 = GUICtrlCreateLabel("Run", 408, 64, 24, 17) ;I do this a lot to make things easier - labeling the ID of some controls. $winwaitactiveinput = GUICtrlCreateInput("Untitled - Notepad", 120, 64, 97, 21) ;7 <--The id of that control is 7 GUICtrlSetState($winwaitactiveinput, $GUI_HIDE) $Label3 = GUICtrlCreateLabel("Randomize position by", 8, 112, 110, 17) ; 8 $randompixelinput = GUICtrlCreateInput("0", 120, 112, 25, 21) ;9 $Label4 = GUICtrlCreateLabel("pixels.", 152, 112, 33, 17) ;10 $Label5 = GUICtrlCreateLabel("After", 256, 112, 31, 17) $waittime1input = GUICtrlCreateInput("1000", 288, 112, 73, 21) $Label6 = GUICtrlCreateLabel("to", 368, 112, 13, 17) $waittime2input = GUICtrlCreateInput("2000", 384, 112, 73, 21) $Label7 = GUICtrlCreateLabel("miliseconds.", 464, 112, 61, 17) $Label8 = GUICtrlCreateLabel("times.", 480, 64, 31, 17) $Label1 = GUICtrlCreateLabel("x", 240, 64, 9, 17) ;17 $xcoordinput = GUICtrlCreateInput("0", 248, 64, 25, 21) ;18 $Label9 = GUICtrlCreateLabel("y", 288, 64, 9, 17) ;19 $ycoordinput = GUICtrlCreateInput("0", 296, 64, 25, 21) ;20 $findcoordbutton = GUICtrlCreateButton("Find...", 320, 64, 43, 17) ;21 GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### Global $numberOfEvents = 1 $eventTypeComboData1 = GUICtrlRead(4) While 1 If $numberOfEvents = 5 Then GUISetStyle(BitOR(Default, $WS_VSCROLL)) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $neweventbutton addnewevent() EndSwitch For $tempCounter = 0 To ($numberOfEvents - 1) Step 1 Switch $nMsg Case 21 + ($tempCounter * 18) findMouseCoordinates($nMsg) Case 4 + ($tempCounter * 18) $eventTypeComboData2 = GUICtrlRead(4 + ($tempCounter * 18)) If $eventTypeComboData1 <> $eventTypeComboData2 Then Switch $eventTypeComboData2 Case "Left Click" GUICtrlSetState(7 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(8 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(9 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(10 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(17 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(18 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(19 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(20 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(21 + ($tempCounter * 18), $GUI_SHOW) Case "Right Click" GUICtrlSetState(7 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(8 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(9 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(10 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(17 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(18 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(19 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(20 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(21 + ($tempCounter * 18), $GUI_SHOW) Case "WinWaitActive" GUICtrlSetState(7 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(8 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(9 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(10 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(17 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(18 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(19 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(20 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(21 + ($tempCounter * 18), $GUI_HIDE) Case "Run..." GUICtrlSetState(7 + ($tempCounter * 18), $GUI_SHOW) GUICtrlSetState(8 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(9 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(10 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(17 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(18 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(19 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(20 + ($tempCounter * 18), $GUI_HIDE) GUICtrlSetState(21 + ($tempCounter * 18), $GUI_HIDE) EndSwitch $eventTypeComboData1 = $eventTypeComboData2 EndIf EndSwitch Next Sleep(25) WEnd Func findMouseCoordinates($buttonId) Local $mouseposition = MouseGetPos() ToolTip($mouseposition[0] & ", " & $mouseposition[1], $mouseposition[0] + 12, $mouseposition[1] + 12, Default, Default, 4) While 1 Local $mouseposition2 = MouseGetPos() If $mouseposition[0] <> $mouseposition2[0] Or $mouseposition[1] <> $mouseposition2[1] Then $mouseposition[0] = $mouseposition2[0] $mouseposition[1] = $mouseposition2[1] ToolTip("") ToolTip($mouseposition2[0] & ", " & $mouseposition2[1], $mouseposition2[0] + 12, $mouseposition2[1] + 12, Default, Default, 4) EndIf Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $buttonId ToolTip("") ExitLoop EndSwitch Sleep(25) WEnd EndFunc ;==>findMouseCoordinates Func addnewevent() GUICtrlCreateCombo("Left Click", 8, 64 + ($numberOfEvents * 150), 113, 25) ;3 GUICtrlSetData(-1, "Right Click|WinWaitActive|Run...") ;not a new ctrl GUICtrlCreateInput("1", 432, 64 + ($numberOfEvents * 150), 49, 21) ;4 GUICtrlCreateLabel("Run", 408, 64 + ($numberOfEvents * 150), 24, 17) ;5 GUICtrlCreateInput("Untitled - Notepad", 120, 64 + ($numberOfEvents * 150), 97, 21) ;6 GUICtrlSetState(-1, $GUI_HIDE) ;not a new ctrl GUICtrlCreateLabel("Randomize position by", 8, 112 + ($numberOfEvents * 150), 110, 17) GUICtrlCreateInput("0", 120, 112 + ($numberOfEvents * 150), 25, 21) ;8 GUICtrlCreateLabel("pixels.", 152, 112 + ($numberOfEvents * 150), 33, 17) GUICtrlCreateLabel("Every", 256, 112 + ($numberOfEvents * 150), 31, 17) ;10 GUICtrlCreateInput("1000", 288, 112 + ($numberOfEvents * 150), 73, 21) GUICtrlCreateLabel("to", 368, 112 + ($numberOfEvents * 150), 13, 17) ;12 GUICtrlCreateInput("2000", 384, 112 + ($numberOfEvents * 150), 73, 21) GUICtrlCreateLabel("miliseconds.", 464, 112 + ($numberOfEvents * 150), 61, 17) ;14 GUICtrlCreateLabel("times.", 480, 64 + ($numberOfEvents * 150), 31, 17) GUICtrlCreateLabel("x", 240, 64 + ($numberOfEvents * 150), 9, 17) ;16 GUICtrlCreateInput("0", 248, 64 + ($numberOfEvents * 150), 25, 21) GUICtrlCreateLabel("y", 288, 64 + ($numberOfEvents * 150), 9, 17) ;18 GUICtrlCreateInput("0", 296, 64 + ($numberOfEvents * 150), 25, 21) GUICtrlCreateButton("Find...", 320, 64 + ($numberOfEvents * 150), 43, 17) ;20 ;18 controls are being created. $numberOfEvents = $numberOfEvents + 1 EndFunc ;==>addnewevent
Thanks,
~mischieftoo




