electrogen Posted March 17, 2009 Share Posted March 17, 2009 Hi i have been using AutoIT for about a week and it seems easier to use than other methods. The problem i have is this, I have made a GUI via "GuiCreate" and various menu's via "GuiCtrlCreateMenu" CODEGuiCreate("My Package", 1000, 800) and CODEGuiCtrlCreateMenu("File") Firstly i need to know how i can use the minimize/maximize button on the top right of the GUI. Also i need to know how to occupy the "File" menu to include (GuiCtrlCreateMenuItem) Everytime i do it when the script is run I have errors. Also i have created several tabs via "GuiCtrlCreateTab" and tab items and would like the content of these tabs to be scrolled. How do i do this? Link to comment Share on other sites More sharing options...
foster74 Posted March 17, 2009 Share Posted March 17, 2009 The help file has tons of examples, but here's an example for you. #include <GUIConstantsEx.au3> $gui = GuiCreate("My Package", 1000, 800) GUISetState() $Menu = GuiCtrlCreateMenu("File") $item1 = GUICtrlCreateMenuItem('Item1', $Menu) $item2 = GUICtrlCreateMenuItem('Item2', $Menu) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE $answer = msgbox(262148, "Exit", "Are you sure you want to exit?") If $answer = 6 Then Exit Case $msg = $item1 MsgBox(0, "Item 1", "Item one has been selected.") Case $msg = $item2 MsgBox(0, "Item 2", "Item one has been selected.") EndSelect WEnd Link to comment Share on other sites More sharing options...
BrettF Posted March 17, 2009 Share Posted March 17, 2009 Welcome to the forums! What do you mean by occupy the file menu? Here is a script showing how I have shoved a child GUI on tab 3. I think it may be able to be done better, but I like this method... You should be able to see how to tailor it to your needs, if not post your attempts, and we'll see about fixing it expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <StructureConstants.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> $buffer = False $hGUI = GUICreate("GUI Test", 800, 600) $hTabs = GUICtrlCreateTab(10, 10, 780, 580) $hTabPage1 = GUICtrlCreateTabItem("Tab 1") $hTabPage2 = GUICtrlCreateTabItem("Tab 2") $hTabPage3 = GUICtrlCreateTabItem("Tab 3") $hTabPage4 = GUICtrlCreateTabItem("Tab 4") $hGUI2 = GUICreate("", 745, 520, 25, 80, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150);,$LVS_SORTDESCENDING) $button = GUICtrlCreateButton("Value?", 75, 170, 70, 20) For $x = 1 To 30 GUICtrlCreateListViewItem("item" & $x & "|col2|col3", $listview) Next GUISetBkColor(0x000000, $hGUI2) GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") GUISwitch($hGUI) GUISetState(@SW_SHOW, $hGUI) _GUIScrollBars_Init($hGUI2) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case GUICtrlRead($hTabs, 1) = $hTabPage3 If Not $buffer Then $buffer = True GUISetState(@SW_SHOW, $hGUI2) GUISwitch($hGUI) EndIf Case GUICtrlRead($hTabs, 1) = $hTabPage1 Or $hTabPage2 Or $hTabPage3 If $buffer Then $buffer = False GUISetState(@SW_HIDE, $hGUI2) GUISwitch($hGUI) EndIf EndSelect WEnd ;=============== ; Internal Functions. DO NOT MODIFY, 9 times out of 10, it probably won't work as you expect if you don't know what you're doing. ;=============== Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam Local $index = -1, $yChar, $xChar, $xClientMax, $xClient, $yClient, $ivMax For $x = 0 To UBound($aSB_WindowInfo) - 1 If $aSB_WindowInfo[$x][0] = $hWnd Then $index = $x $xClientMax = $aSB_WindowInfo[$index][1] $xChar = $aSB_WindowInfo[$index][2] $yChar = $aSB_WindowInfo[$index][3] $ivMax = $aSB_WindowInfo[$index][7] ExitLoop EndIf Next If $index = -1 Then Return 0 Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO) ; Retrieve the dimensions of the client area. $xClient = BitAND($lParam, 0x0000FFFF) $yClient = BitShift($lParam, 16) $aSB_WindowInfo[$index][4] = $xClient $aSB_WindowInfo[$index][5] = $yClient ; Set the vertical scrolling range and page size DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE)) DllStructSetData($tSCROLLINFO, "nMin", 0) DllStructSetData($tSCROLLINFO, "nMax", $ivMax) DllStructSetData($tSCROLLINFO, "nPage", $yClient / $yChar) _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 + $xClientMax / $xChar) DllStructSetData($tSCROLLINFO, "nPage", $xClient / $xChar) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $index = -1, $xChar, $xPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($aSB_WindowInfo) - 1 If $aSB_WindowInfo[$x][0] = $hWnd Then $index = $x $xChar = $aSB_WindowInfo[$index][2] ExitLoop EndIf Next If $index = -1 Then Return 0 ;~; Get all the horizontal scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $xPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $xPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $Min, $Max Switch $nScrollCode Case $SB_LINELEFT; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINERIGHT; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGELEFT; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGERIGHT; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) 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 $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_HSCROLL Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $index = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($aSB_WindowInfo) - 1 If $aSB_WindowInfo[$x][0] = $hWnd Then $index = $x $yChar = $aSB_WindowInfo[$index][3] ExitLoop EndIf Next If $index = -1 Then Return 0 ; Get all the vertial scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) 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 $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL What do you wish to achieve when you click minimize or maximize? If you wish to run a normal function when they are pressed, they can be "hooked" using $GUI_EVENT_MINIMIZE, $GUI_EVENT_MAXIMIZE in you message loop (treat them as you do with $GUI_EVENT_CLOSE). Its also a good idea to post your code or a replica rather than snippets, because those 2 lines you provided show me nothing to what you are doing exactly- no one here can fix problems like this without seeing some code closely related to the problem... In response to these errors, can you please post the output from SciTE? If you are not using download the full version ASAP. Link is in my sig. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
electrogen Posted March 17, 2009 Author Share Posted March 17, 2009 What do you wish to achieve when you click minimize or maximize? If you wish to run a normal function when they are pressed, they can be "hooked" using $GUI_EVENT_MINIMIZE, $GUI_EVENT_MAXIMIZE in you message loop (treat them as you do with $GUI_EVENT_CLOSE). Its also a good idea to post your code or a replica rather than snippets, because those 2 lines you provided show me nothing to what you are doing exactly- no one here can fix problems like this without seeing some code closely related to the problem... In response to these errors, can you please post the output from SciTE? If you are not using download the full version ASAP. Link is in my sig. Cheers, Brett Link to comment Share on other sites More sharing options...
BrettF Posted March 17, 2009 Share Posted March 17, 2009 Learn to search first in the future.http://www.autoitscript.com/forum/index.php?showtopic=85783Cheers,Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
electrogen Posted March 17, 2009 Author Share Posted March 17, 2009 Learn to search first in the future.I know how to search, this is not what i wanted the one i want is when the button in the middle gets pressed it makes the GUI smaller or bigger. i want to enable this button.I would search this but i dont know what it is called Link to comment Share on other sites More sharing options...
BrettF Posted March 17, 2009 Share Posted March 17, 2009 Still could have found it if you looked hard enough IMO.Now do you want to be able to resize the window (with that middle button) or you want to minimize the window to the tray with the maximize button.If you answered yes to resizing:Take a look at GUICtrlSetResizing in the helpfile for an example on handling the controls.Take a look at this for "enabling it"#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate ("Hi", 500, 400, Default, Default, BitOR ($WS_SIZEBOX, $WS_SYSMENU, $WS_MAXIMIZEBOX)) GUISetState () While 1 $nMSg = GUIGetMsg () Switch $nMSg Case $GUI_EVENT_CLOSE Exit EndSwitch WEndRead the helpfile for more info on the styles for GUICreate.If you answered yes to wanting to minimize the window to the tray with the maximize button:Take a look at this example:http://www.autoitscript.com/forum/index.ph...mp;#entry239968Take note how $GUI_EVENT_MINIMIZE was used, and remember what I said earlier about hooking it (do it instead for$GUI_EVENT_MAXIMIZE). Also you still have not posted what the errors were?Cheers,Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
electrogen Posted March 17, 2009 Author Share Posted March 17, 2009 Still could have found it if you looked hard enough IMO. Now do you want to be able to resize the window (with that middle button) or you want to minimize the window to the tray with the maximize button. If you answered yes to resizing: Take a look at GUICtrlSetResizing in the helpfile for an example on handling the controls. Take a look at this for "enabling it" #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate ("Hi", 500, 400, Default, Default, BitOR ($WS_SIZEBOX, $WS_SYSMENU, $WS_MAXIMIZEBOX)) GUISetState () While 1 $nMSg = GUIGetMsg () Switch $nMSg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Read the helpfile for more info on the styles for GUICreate. If you answered yes to wanting to minimize the window to the tray with the maximize button: Take a look at this example: http://www.autoitscript.com/forum/index.ph...mp;#entry239968 Take note how $GUI_EVENT_MINIMIZE was used, and remember what I said earlier about hooking it (do it instead for$GUI_EVENT_MAXIMIZE). Also you still have not posted what the errors were? Cheers, Brett The errors were about veriables not being declared But it is fine now as the info you and Foster74 have resolved it. Thanks 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