TalesFromTheScript Posted July 1, 2023 Share Posted July 1, 2023 (edited) I have been asking Chat GPT for hours on end today and nothing it has suggested works so I have to ask here! I am creating a button in the gui with this: $Backupbutton1 = GUICtrlCreateButton ("Basic Backup", 5,40,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton1, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) Further down the script, here's the code I am using to run a bat file if that button is left-clicked: Case $msg = $backupbutton1 Run("----\Basic Backup.bat") All of that works perfectly. Now I just want to be able to also right-click that same button to run a help file "Basic Backup.rtf" that will be in the same "----" folder as the bat file, so it's easy to open the help file (right-click) or run the bat file (left-click, which it already does). I have had so many non-working suggestions I probably can't even list them all but here's some, all of which make it so clicking the "Basic Backup" button does nothing with either the left or right mouse buttons. I am putting this in place of the 2 lines of code above: Switch $msg Case $backupbutton1 If _IsPressed("02") Then ; Check if right mouse button is pressed ShellExecute("----\Basic Backup.rtf") Else Run("----\Basic Backup.bat") EndIf EndSwitch Switch $msg Case $Backupbutton1 If _WinAPI_GetKeyState($VK_RBUTTON) < 0 Then ; Check if right mouse button is pressed ShellExecute("----\Basic Backup.rtf") Else Run("----\Basic Backup.bat") EndIf EndSwitch While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Backupbutton1 If _IsPressed("02") Then ; Check if right mouse button is pressed ShellExecute("----\Basic Backup.rtf") Else Run("----\Basic Backup.bat") EndIf EndSelect WEnd There are many many more examples I have tried. Too many to list. Whenever I had to include things like "Misc.au3" in the includes, they were. I have no idea what code would work. It sounds so simple yet I have been trying for hours, half a day by now probably, to do it. Edited July 1, 2023 by TalesFromTheScript Link to comment Share on other sites More sharing options...
TheXman Posted July 1, 2023 Share Posted July 1, 2023 (edited) 37 minutes ago, TalesFromTheScript said: Now I just want to be able to also right-click that same button to run a help file "Basic Backup.rtf" The generally accepted behavior for a right-click in Windows applications is to bring up a context menu. If that is what you are trying to do, then check out the example script for GUICtrlCreateContextMenu() in the help file. It creates a context menu for a button. Edited July 1, 2023 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Andreik Posted July 1, 2023 Share Posted July 1, 2023 This is a workaround: #include <GUIConstantsEx.au3> $hMain = GUICreate('Example') $cButton = GUICtrlCreateButton('Click me', 100, 100, 150, 30) GUISetState(@SW_SHOW, $hMain) While True $aMsg = GUIGetMsg(1) Switch $aMsg[0] Case -3 Exit Case $cButton MsgBox(0, 'Yayyy', 'You left clicked me!') Case $GUI_EVENT_SECONDARYDOWN If ButtonClicked($hMain, $cButton, $aMsg) Then MsgBox(0, 'Yayyy', 'You right clicked me!') EndSwitch WEnd Func ButtonClicked($hWin, $cButton, $aMsg) Local $aPos = ControlGetPos($hWin, '', $cButton) If $aMsg[3] > $aPos[0] And $aMsg[3] < $aPos[0] + $aPos[2] Then If $aMsg[4] > $aPos[1] And $aMsg[4] < $aPos[1] + $aPos[3] Then Return True EndIf EndIf Return False EndFunc pixelsearch 1 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
TalesFromTheScript Posted July 1, 2023 Author Share Posted July 1, 2023 Thanks Andreik but I can't get it working. Using this to create the button: $Backupbutton1 = GUICtrlCreateButton ("Basic Backup", 5,40,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton1, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) Then this further down for running the files, but clicking left or right, the button does nothing: While True $aMsg = GUIGetMsg(1) Switch $aMsg[0] Case -3 Exit Case $Backupbutton1 Run("----\Basic Backup.bat") Case $GUI_EVENT_SECONDARYDOWN If ButtonClicked($hGUI, $Backupbutton1, $aMsg) Then Run("----\Basic Backup.rtf") EndSwitch WEnd Func ButtonClicked($hWin, $Backupbutton1, $aMsg) Local $aPos = ControlGetPos($hWin, '', $Backupbutton1) If $aMsg[3] > $aPos[0] And $aMsg[3] < $aPos[0] + $aPos[2] Then If $aMsg[4] > $aPos[1] And $aMsg[4] < $aPos[1] + $aPos[3] Then Return True EndIf EndIf Return False EndFunc I'm either going to just give up on it or find some way to make it open the rtf file if left click is held down for 500ms or more, not that I have any idea how to do that (and I spent ages asking Chat GPT to no avail). Link to comment Share on other sites More sharing options...
Solution Andreik Posted July 1, 2023 Solution Share Posted July 1, 2023 You must be more specific about what is not working. I don't see any problem. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
TalesFromTheScript Posted July 1, 2023 Author Share Posted July 1, 2023 Sorry yes it works in isolation but I can't get it working in my full script. Link to comment Share on other sites More sharing options...
Andreik Posted July 1, 2023 Share Posted July 1, 2023 Post your full script. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
TalesFromTheScript Posted July 1, 2023 Author Share Posted July 1, 2023 (edited) It's a lot of code but here it all is. It's a GUI for making it easier to do different things on a GARMIN device. All the bat files are done, this is just a GUI to save digging around running bat files. I have ended up with two scripts, both trying to do the same thing, but neither one has the full functionality. The first one is the original where it all works perfectly, it just doesn't have the right-click functionality put in yet. The second one does have the right-click functionality working (albeit only on one button for now) but for some reason the About tab has vanished from the GUI completely, despite being there in the code. Original script, no right clicking implemented yet: expandcollapse popup#include <GuiConstants.au3> #include <AutoItConstants.au3> #include <WindowsConstants.au3> #include <ColorConstantS.au3> #include <GUIConstantsEx.au3> #include <TrayConstants.au3> #include <FontConstants.au3> #include <ListViewConstants.au3> #include <TabConstants.au3> ; No tray icon TraySetState(2) ; Tab colours Global $aTabColours[6] = [0xFFC0C0, 0xC0FFC0, 0xC0C0FF, 0xC0C0C0, 0xC0FFC0, 0xC0C0C0] Global $sMyIniLocation = "----\WinPos\WinPos_GM.ini" ;; Raising DesktopWidth moves the GUI left ;; Raising DesktopHeight moves the GUI up Global $nIniXPos = Int(IniRead($sMyIniLocation, 'MAINWINPOS', 'XPOS', Int(@DesktopWidth/3.5))) Global $nIniYPos = Int(IniRead($sMyIniLocation, 'MAINWINPOS', 'YPOS', Int(@DesktopHeight/2.8))) Global $iWidth = 394, $iHeight = 428 $nIniXPos = (($nIniXPos <> -32000) ? ($nIniXPos) : ((@DesktopWidth - $iWidth) / 2)) $nIniYPos = (($nIniYPos <> -32000) ? ($nIniYPos) : ((@DesktopHeight - $iHeight) / 2)) Func _myWM_MOVE($hWnd, $nMsg, $wParam, $lParam) Local $aWPos = WinGetPos($hWnd) If IsArray($aWPos) Then IniWrite($sMyIniLocation, 'MAINWINPOS', 'XPOS', $aWPos[0]) IniWrite($sMyIniLocation, 'MAINWINPOS', 'YPOS', $aWPos[1]) EndIf Return EndFunc GUIRegisterMsg(0x03, "_myWM_MOVE") GUISetState() ; GUI ; This creates an "Always on top" version of the GUI... ; $hGUI = GUICreate("GMenu", $iWidth, $iHeight, $nIniXPos, $nIniYPos, Default, $WS_EX_TOPMOST) ; This creates a standard GUI... $hGUI = GUICreate("GMenu", $iWidth, $iHeight, $nIniXPos, $nIniYPos, Default) GUISetBkColor(0x000000) ; GUI background color GuiSetIcon("icon.ico", 0) ; GUISetBkColor(0x990000) ; GUISetBkColor(0xe6f2ff) ; GUISetBkColor(0x000000) ; PIC ; GuiCtrlCreatePic("pic.jpg", 0, 0, 300, 700) ; Font for all tabs $MainTabCtrl = GUICtrlCreateTab(0, 0, 394, 428,$GUI_SS_DEFAULT_TAB) GUICtrlSetFont ($MainTabCtrl,13, 700, 0, "Segoe UI") ; Centralize tab text GUICtrlSendMsg ($MainTabCtrl, $TCM_SETMINTABWIDTH , 0, 0) ; |======| ; | | ; | Tabs | ; | | ; |======| ; ; ---------------------------------------------------------------------------------------- ; Button position/sizing explained: ; 1st number = Left/Right position, number applies to top left corner (5) ; 2nd number = Top/Bottom position, number applies to top left corner (40) ; 3rd number = Button length (189) [This allows for 20 characters with current font setup] ; 4th number = Button height (30) [A difference of 32 between each button is required] ; ---------------------------------------------------------------------------------------- ; ########################################################################################### ; Main tab $hTab1 = GUICtrlCreateTab(0, 0, 394, 428) ; Create tabitems For $main_tab = 1 To 1 GUICtrlCreateTabItem("Menu") ; Main tab buttons $Backupbutton1 = GUICtrlCreateButton ("Basic Backup", 5,40,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton1, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton2 = GUICtrlCreateButton ("Combine Backups", 197,40,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton2, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton3 = GUICtrlCreateButton ("Copy GPX to GARMIN", 5,72,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton3, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton4 = GUICtrlCreateButton ("Placeholder 4", 197,72,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton4, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton5 = GUICtrlCreateButton ("Placeholder 5", 5,104,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton5, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x80ffff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton6 = GUICtrlCreateButton ("Placeholder 6", 197,104,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton6, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x80ffff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton7 = GUICtrlCreateButton ("Placeholder 7", 5,136,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton7, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x80ffff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton8 = GUICtrlCreateButton ("Placeholder 8", 197,136,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton8, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x80ffff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton9 = GUICtrlCreateButton ("Placeholder 9", 5,168,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton9, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton10 = GUICtrlCreateButton ("Placeholder 10", 197,168,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton10, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton11 = GUICtrlCreateButton ("Placeholder 11", 5,200,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton11, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton12 = GUICtrlCreateButton ("Placeholder 12", 197,200,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton12, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton13 = GUICtrlCreateButton ("Placeholder 13", 5,232,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton13, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0xffcc00) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton14 = GUICtrlCreateButton ("Placeholder 14", 197,232,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton14, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x00e6e6) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton15 = GUICtrlCreateButton ("Placeholder 15", 5,264,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton15, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x00e6e6) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton16 = GUICtrlCreateButton ("Placeholder 16", 197,264,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton16, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x00e6e6) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton17 = GUICtrlCreateButton ("Placeholder 17", 5,296,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton17, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x00e6e6) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton18 = GUICtrlCreateButton ("Placeholder 18", 197,296,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton18, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0xffb3ff) GUICtrlSetImage (-1, "Icon2.ico",-1) ; $Backupbutton19 = GUICtrlCreateButton ("Placeholder 19", 5,328,189,30,$BS_ICON) ; GUICtrlSetFont ($Backupbutton19, 12, 700, 0, "Segoe UI") ; GUICtrlSetBkColor(-1, 0x99ccff) ; GUICtrlSetImage (-1, "Icon2.ico",-1) ; $Backupbutton20 = GUICtrlCreateButton ("Placeholder 20", 197,328,189,30,$BS_ICON) ; GUICtrlSetFont ($Backupbutton20, 12, 700, 0, "Segoe UI") ; GUICtrlSetBkColor(-1, 0x99ccff) ; GUICtrlSetImage (-1, "Icon2.ico",-1) ; $Backupbutton21 = GUICtrlCreateButton ("Placeholder 21", 5,360,189,30,$BS_ICON) ; GUICtrlSetFont ($Backupbutton21, 12, 700, 0, "Segoe UI") ; GUICtrlSetBkColor(-1, 0x99ccff) ; GUICtrlSetImage (-1, "Icon2.ico",-1) ; $Backupbutton22 = GUICtrlCreateButton ("Placeholder 22", 197,360,189,30,$BS_ICON) ; GUICtrlSetFont ($Backupbutton22, 12, 700, 0, "Segoe UI") ; GUICtrlSetBkColor(-1, 0x99ccff) ; GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton23 = GUICtrlCreateButton ("Open Garmin Folder", 5,392,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton23, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0xcccccc) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton24 = GUICtrlCreateButton ("Help Guide", 197,392,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton24, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0xf2f2f2) GUICtrlSetImage (-1, "Icon2.ico",-1) Next ; Close Tab definiton GUICtrlCreateTabItem("") ; ########################################################################################### ; About tab $hTab6 = GUICtrlCreateTab(0, 0, 394, 428) ; Create tabitems For $about_tab = 1 To 1 GUICtrlCreateTabItem("About") ; title GUICtrlCreateLabel("Gmenu v1.01", 35, 50, 394, 30) GUICtrlSetFont(-1, 14, 700, "Segoe UI") GUICtrlCreateLabel("(2023-06-30)", 35, 75, 394, 30) GUICtrlSetFont(-1, 12, 700, "Segoe UI") ; main text GUICtrlCreateLabel("This program is provided free of charge, with", 20, 110, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("no limitations, for private or commercial use.", 20, 130, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("If you have found this menu program to be useful", 20, 160, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("and would like to donate Bitcoin to the creator,", 20, 180, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("you can via the Bitcoin address shown below.", 20, 200, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("Thanks in advance to anyone that decides to", 20, 230, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("make a donation!", 20, 250, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("Bitcoin donate address:", 100, 280, 394, 30) GUICtrlSetFont(-1, 14, 700, "Segoe UI") $btc_address = GUICtrlCreateEdit("BTC address goes here", 7, 310, 380, 25, BitOR($ES_READONLY, $WS_VISIBLE, $ES_CENTER)) GUICtrlSetFont(-1, 12, 700, "Segoe UI") GUICtrlSetColor($btc_address, $COLOR_BLUE) $copy_btc_address_button = GUICtrlCreateButton ("Copy to clipboard", 100,350,189,30,$BS_ICON) GUICtrlSetFont ($copy_btc_address_button, 12, 700, 0, "Segoe UI") Next ; Close Tab definiton GUICtrlCreateTabItem("") ; ######################## ; ####################### ; ###################### ; ##################### ; #################### ; ################### ; ################## ; ################# ; ################ ; ############### ; ############## ; ############# ; ############ ; ########### ; ########## ; ######### ; ######## ; ####### ; ###### ; ##### ; #### ; ### ; ## ; # ; ########################################################################################### ; |================================| ; | | ; | | ; | Buttons linking to batch files | ; | | ; | | ; |================================| GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit ; Batch files: Case $msg = $backupbutton1 Run("----\Basic Backup.bat") Case $msg = $backupbutton2 Run("----\Combine Basic Backups.bat") Case $msg = $backupbutton3 Run("----\Copy GPX Files to GARMIN.bat") Case $msg = $backupbutton4 Run("----\Placeholder 4.bat") Case $msg = $backupbutton5 Run("----\Placeholder 5.bat") Case $msg = $backupbutton6 Run("----\Placeholder 6.bat") Case $msg = $backupbutton7 Run("----\Placeholder 7.bat") Case $msg = $backupbutton8 Run("----\Placeholder 8.bat") Case $msg = $backupbutton9 Run("----\Placeholder 9.bat") Case $msg = $backupbutton10 Run("----\Placeholder 10.bat") Case $msg = $backupbutton11 Run("----\Placeholder 11.bat") Case $msg = $backupbutton12 Run("----\Placeholder 12.bat") Case $msg = $backupbutton13 Run("----\Placeholder 13.bat") Case $msg = $backupbutton14 Run("----\Placeholder 14.bat") Case $msg = $backupbutton15 Run("----\Placeholder 15.bat") Case $msg = $backupbutton16 Run("----\Placeholder 16.bat") Case $msg = $backupbutton17 Run("----\UserChoice\LNK Placeholder 17.bat") ; bat file runs a .lnk shortcut Case $msg = $backupbutton18 Run("----\UserChoice\LNK Placeholder 18.bat") ; bat file runs a .lnk shortcut ; Case $msg = $backupbutton19 ; Run("----\Placeholder 19.bat") ; Case $msg = $backupbutton20 ; Run("----\Placeholder 20.bat") ; Case $msg = $backupbutton21 ; Run("----\Placeholder 21.bat") ; Case $msg = $backupbutton22 ; Run("----\Placeholder 22.bat") Case $msg = $backupbutton23 Run("----\Open Device Root.bat") Case $msg = $backupbutton24 ShellExecute ("----\Basic Backup.rtf") ; ########################################################################################### Case $msg = $copy_btc_address_button ClipPut(GUICtrlRead($btc_address)) Case Else ;;; EndSelect WEnd Then there's this script where right click does work (opens an rtf file) but the About tab doesn't exist in this GUI, despite it being there in the code: expandcollapse popup#include <GuiConstants.au3> #include <AutoItConstants.au3> #include <WindowsConstants.au3> #include <ColorConstantS.au3> #include <GUIConstantsEx.au3> #include <TrayConstants.au3> #include <FontConstants.au3> #include <ListViewConstants.au3> #include <TabConstants.au3> ; No tray icon TraySetState(2) ; Tab colours Global $aTabColours[6] = [0xFFC0C0, 0xC0FFC0, 0xC0C0FF, 0xC0C0C0, 0xC0FFC0, 0xC0C0C0] Global $sMyIniLocation = "----\WinPos\WinPos_GM.ini" ;; Raising DesktopWidth moves the GUI left ;; Raising DesktopHeight moves the GUI up Global $nIniXPos = Int(IniRead($sMyIniLocation, 'MAINWINPOS', 'XPOS', Int(@DesktopWidth/3.5))) Global $nIniYPos = Int(IniRead($sMyIniLocation, 'MAINWINPOS', 'YPOS', Int(@DesktopHeight/2.8))) Global $iWidth = 394, $iHeight = 428 $nIniXPos = (($nIniXPos <> -32000) ? ($nIniXPos) : ((@DesktopWidth - $iWidth) / 2)) $nIniYPos = (($nIniYPos <> -32000) ? ($nIniYPos) : ((@DesktopHeight - $iHeight) / 2)) Func _myWM_MOVE($hWnd, $nMsg, $wParam, $lParam) Local $aWPos = WinGetPos($hWnd) If IsArray($aWPos) Then IniWrite($sMyIniLocation, 'MAINWINPOS', 'XPOS', $aWPos[0]) IniWrite($sMyIniLocation, 'MAINWINPOS', 'YPOS', $aWPos[1]) EndIf Return EndFunc GUIRegisterMsg(0x03, "_myWM_MOVE") GUISetState() ; GUI ; This creates an "Always on top" version of the GUI... ; $hGUI = GUICreate("GMenu", $iWidth, $iHeight, $nIniXPos, $nIniYPos, Default, $WS_EX_TOPMOST) ; This creates a standard version of the GUI... $hGUI = GUICreate("GMenu", $iWidth, $iHeight, $nIniXPos, $nIniYPos, Default) GUISetBkColor(0x000000) ; GUI background color GuiSetIcon("icon.ico", 0) ; Font for all tabs $MainTabCtrl = GUICtrlCreateTab(0, 0, 394, 428, $GUI_SS_DEFAULT_TAB) GUICtrlSetFont($MainTabCtrl, 13, 700, 0, "Segoe UI") ; Centralize tab text GUICtrlSendMsg($MainTabCtrl, $TCM_SETMINTABWIDTH, 0, 0) ; Main tab $hTab1 = GUICtrlCreateTab(0, 0, 394, 428) ; Create buttons For $main_tab = 1 To 1 GUICtrlCreateTabItem("Menu") $Backupbutton1 = GUICtrlCreateButton("Basic Backup", 5, 40, 189, 30) GUICtrlSetFont($Backupbutton1, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage(-1, "Icon2.ico", -1) GUISetState(@SW_SHOW, $hGUI) While True $aMsg = GUIGetMsg(1) Switch $aMsg[0] Case -3 Exit Case $Backupbutton1 Run("----\Basic Backup.bat") Case $GUI_EVENT_SECONDARYDOWN If ButtonClicked($hGUI, $Backupbutton1, $aMsg) Then ShellExecute("----\Basic Backup.rtf") EndSwitch WEnd Next ; Close Tab definition GUICtrlCreateTabItem("") Func ButtonClicked($hWin, $Backupbutton1, $aMsg) Local $aPos = ControlGetPos($hWin, '', $Backupbutton1) If $aMsg[3] > $aPos[0] And $aMsg[3] < $aPos[0] + $aPos[2] Then If $aMsg[4] > $aPos[1] And $aMsg[4] < $aPos[1] + $aPos[3] Then Return True EndIf EndIf Return False EndFunc ; About tab $hTab6 = GUICtrlCreateTab(0, 0, 394, 428) ; Create tab content While True $aMsg = GUIGetMsg(1) Switch $aMsg[0] Case -3 Exit Case $copy_btc_address_button ClipPut(GUICtrlRead($btc_address)) EndSwitch For $about_tab = 1 To 1 GUICtrlCreateTabItem("About") ; title GUICtrlCreateLabel("Gmenu v1.01", 35, 50, 394, 30) GUICtrlSetFont(-1, 14, 700, "Segoe UI") GUICtrlCreateLabel("(2023-06-30)", 35, 75, 394, 30) GUICtrlSetFont(-1, 12, 700, "Segoe UI") ; main text GUICtrlCreateLabel("This program is provided free of charge, with", 20, 110, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("no limitations, for private or commercial use.", 20, 130, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("If you have found this menu program to be useful", 20, 160, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("and would like to donate Bitcoin to the creator,", 20, 180, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("you can via the Bitcoin address shown below.", 20, 200, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("Thanks in advance to anyone that decides to", 20, 230, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("make a donation!", 20, 250, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("Bitcoin donate address:", 100, 280, 394, 30) GUICtrlSetFont(-1, 14, 700, "Segoe UI") $btc_address = GUICtrlCreateEdit("BTC address goes here", 7, 310, 380, 25, BitOR($ES_READONLY, $WS_VISIBLE, $ES_CENTER)) GUICtrlSetFont(-1, 12, 700, "Segoe UI") GUICtrlSetColor($btc_address, $COLOR_BLUE) $copy_btc_address_button = GUICtrlCreateButton("Copy to clipboard", 100, 350, 189, 30, $BS_ICON) GUICtrlSetFont($copy_btc_address_button, 12, 700, 0, "Segoe UI") Next GUICtrlCreateTabItem("") WEnd All I am trying to do is have one script where the About tab works the way it does in the first script, but it has the right click functionality on the buttons in the second script. If I ever get the second script working so the About tab is back in the GUI again, then I'll just repeat the button code and make all 24 buttons like in the first script. Well it's not going to need 24 buttons but they are there anyway with all the coordinates in case they end up getting used in future versions. Edited July 1, 2023 by TalesFromTheScript Link to comment Share on other sites More sharing options...
Andreik Posted July 1, 2023 Share Posted July 1, 2023 (edited) Are you kidding? Why it would work since you didn't used the script that I provide to you? Here is the code for first button. expandcollapse popup#include <GuiConstants.au3> #include <AutoItConstants.au3> #include <WindowsConstants.au3> #include <ColorConstantS.au3> #include <GUIConstantsEx.au3> #include <TrayConstants.au3> #include <FontConstants.au3> #include <ListViewConstants.au3> #include <TabConstants.au3> ; No tray icon TraySetState(2) ; Tab colours Global $aTabColours[6] = [0xFFC0C0, 0xC0FFC0, 0xC0C0FF, 0xC0C0C0, 0xC0FFC0, 0xC0C0C0] Global $sMyIniLocation = "----\WinPos\WinPos_GM.ini" ;; Raising DesktopWidth moves the GUI left ;; Raising DesktopHeight moves the GUI up Global $nIniXPos = Int(IniRead($sMyIniLocation, 'MAINWINPOS', 'XPOS', Int(@DesktopWidth/3.5))) Global $nIniYPos = Int(IniRead($sMyIniLocation, 'MAINWINPOS', 'YPOS', Int(@DesktopHeight/2.8))) Global $iWidth = 394, $iHeight = 428 $nIniXPos = (($nIniXPos <> -32000) ? ($nIniXPos) : ((@DesktopWidth - $iWidth) / 2)) $nIniYPos = (($nIniYPos <> -32000) ? ($nIniYPos) : ((@DesktopHeight - $iHeight) / 2)) GUIRegisterMsg(0x03, "_myWM_MOVE") GUISetState() ; GUI ; This creates an "Always on top" version of the GUI... ; $hGUI = GUICreate("GMenu", $iWidth, $iHeight, $nIniXPos, $nIniYPos, Default, $WS_EX_TOPMOST) ; This creates a standard GUI... $hGUI = GUICreate("GMenu", $iWidth, $iHeight, $nIniXPos, $nIniYPos, Default) GUISetBkColor(0x000000) ; GUI background color GuiSetIcon("icon.ico", 0) ; GUISetBkColor(0x990000) ; GUISetBkColor(0xe6f2ff) ; GUISetBkColor(0x000000) ; PIC ; GuiCtrlCreatePic("pic.jpg", 0, 0, 300, 700) ; Font for all tabs $MainTabCtrl = GUICtrlCreateTab(0, 0, 394, 428,$GUI_SS_DEFAULT_TAB) GUICtrlSetFont ($MainTabCtrl,13, 700, 0, "Segoe UI") ; Centralize tab text GUICtrlSendMsg ($MainTabCtrl, $TCM_SETMINTABWIDTH , 0, 0) ; |======| ; | | ; | Tabs | ; | | ; |======| ; ; ---------------------------------------------------------------------------------------- ; Button position/sizing explained: ; 1st number = Left/Right position, number applies to top left corner (5) ; 2nd number = Top/Bottom position, number applies to top left corner (40) ; 3rd number = Button length (189) [This allows for 20 characters with current font setup] ; 4th number = Button height (30) [A difference of 32 between each button is required] ; ---------------------------------------------------------------------------------------- ; ########################################################################################### ; Main tab $hTab1 = GUICtrlCreateTab(0, 0, 394, 428) ; Create tabitems For $main_tab = 1 To 1 GUICtrlCreateTabItem("Menu") ; Main tab buttons $Backupbutton1 = GUICtrlCreateButton ("Basic Backup", 5,40,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton1, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton2 = GUICtrlCreateButton ("Combine Backups", 197,40,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton2, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton3 = GUICtrlCreateButton ("Copy GPX to GARMIN", 5,72,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton3, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton4 = GUICtrlCreateButton ("Placeholder 4", 197,72,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton4, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton5 = GUICtrlCreateButton ("Placeholder 5", 5,104,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton5, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x80ffff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton6 = GUICtrlCreateButton ("Placeholder 6", 197,104,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton6, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x80ffff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton7 = GUICtrlCreateButton ("Placeholder 7", 5,136,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton7, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x80ffff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton8 = GUICtrlCreateButton ("Placeholder 8", 197,136,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton8, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x80ffff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton9 = GUICtrlCreateButton ("Placeholder 9", 5,168,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton9, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton10 = GUICtrlCreateButton ("Placeholder 10", 197,168,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton10, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton11 = GUICtrlCreateButton ("Placeholder 11", 5,200,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton11, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton12 = GUICtrlCreateButton ("Placeholder 12", 197,200,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton12, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton13 = GUICtrlCreateButton ("Placeholder 13", 5,232,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton13, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0xffcc00) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton14 = GUICtrlCreateButton ("Placeholder 14", 197,232,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton14, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x00e6e6) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton15 = GUICtrlCreateButton ("Placeholder 15", 5,264,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton15, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x00e6e6) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton16 = GUICtrlCreateButton ("Placeholder 16", 197,264,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton16, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x00e6e6) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton17 = GUICtrlCreateButton ("Placeholder 17", 5,296,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton17, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x00e6e6) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton18 = GUICtrlCreateButton ("Placeholder 18", 197,296,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton18, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0xffb3ff) GUICtrlSetImage (-1, "Icon2.ico",-1) ; $Backupbutton19 = GUICtrlCreateButton ("Placeholder 19", 5,328,189,30,$BS_ICON) ; GUICtrlSetFont ($Backupbutton19, 12, 700, 0, "Segoe UI") ; GUICtrlSetBkColor(-1, 0x99ccff) ; GUICtrlSetImage (-1, "Icon2.ico",-1) ; $Backupbutton20 = GUICtrlCreateButton ("Placeholder 20", 197,328,189,30,$BS_ICON) ; GUICtrlSetFont ($Backupbutton20, 12, 700, 0, "Segoe UI") ; GUICtrlSetBkColor(-1, 0x99ccff) ; GUICtrlSetImage (-1, "Icon2.ico",-1) ; $Backupbutton21 = GUICtrlCreateButton ("Placeholder 21", 5,360,189,30,$BS_ICON) ; GUICtrlSetFont ($Backupbutton21, 12, 700, 0, "Segoe UI") ; GUICtrlSetBkColor(-1, 0x99ccff) ; GUICtrlSetImage (-1, "Icon2.ico",-1) ; $Backupbutton22 = GUICtrlCreateButton ("Placeholder 22", 197,360,189,30,$BS_ICON) ; GUICtrlSetFont ($Backupbutton22, 12, 700, 0, "Segoe UI") ; GUICtrlSetBkColor(-1, 0x99ccff) ; GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton23 = GUICtrlCreateButton ("Open Garmin Folder", 5,392,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton23, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0xcccccc) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton24 = GUICtrlCreateButton ("Help Guide", 197,392,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton24, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0xf2f2f2) GUICtrlSetImage (-1, "Icon2.ico",-1) Next ; Close Tab definiton GUICtrlCreateTabItem("") ; ########################################################################################### ; About tab $hTab6 = GUICtrlCreateTab(0, 0, 394, 428) ; Create tabitems For $about_tab = 1 To 1 GUICtrlCreateTabItem("About") ; title GUICtrlCreateLabel("Gmenu v1.01", 35, 50, 394, 30) GUICtrlSetFont(-1, 14, 700, "Segoe UI") GUICtrlCreateLabel("(2023-06-30)", 35, 75, 394, 30) GUICtrlSetFont(-1, 12, 700, "Segoe UI") ; main text GUICtrlCreateLabel("This program is provided free of charge, with", 20, 110, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("no limitations, for private or commercial use.", 20, 130, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("If you have found this menu program to be useful", 20, 160, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("and would like to donate Bitcoin to the creator,", 20, 180, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("you can via the Bitcoin address shown below.", 20, 200, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("Thanks in advance to anyone that decides to", 20, 230, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("make a donation!", 20, 250, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("Bitcoin donate address:", 100, 280, 394, 30) GUICtrlSetFont(-1, 14, 700, "Segoe UI") $btc_address = GUICtrlCreateEdit("BTC address goes here", 7, 310, 380, 25, BitOR($ES_READONLY, $WS_VISIBLE, $ES_CENTER)) GUICtrlSetFont(-1, 12, 700, "Segoe UI") GUICtrlSetColor($btc_address, $COLOR_BLUE) $copy_btc_address_button = GUICtrlCreateButton ("Copy to clipboard", 100,350,189,30,$BS_ICON) GUICtrlSetFont ($copy_btc_address_button, 12, 700, 0, "Segoe UI") Next ; Close Tab definiton GUICtrlCreateTabItem("") ; ######################## ; ####################### ; ###################### ; ##################### ; #################### ; ################### ; ################## ; ################# ; ################ ; ############### ; ############## ; ############# ; ############ ; ########### ; ########## ; ######### ; ######## ; ####### ; ###### ; ##### ; #### ; ### ; ## ; # ; ########################################################################################### ; |================================| ; | | ; | | ; | Buttons linking to batch files | ; | | ; | | ; |================================| GUISetState() While 1 $msg = GUIGetMsg(1) Select Case $msg[0] = $GUI_EVENT_CLOSE Exit ; Batch files: Case $msg[0] = $backupbutton1 Run("----\Basic Backup.bat") Case $msg[0] = $backupbutton2 Run("----\Combine Basic Backups.bat") Case $msg[0] = $backupbutton3 Run("----\Copy GPX Files to GARMIN.bat") Case $msg[0] = $backupbutton4 Run("----\Placeholder 4.bat") Case $msg[0] = $backupbutton5 Run("----\Placeholder 5.bat") Case $msg[0] = $backupbutton6 Run("----\Placeholder 6.bat") Case $msg[0] = $backupbutton7 Run("----\Placeholder 7.bat") Case $msg[0] = $backupbutton8 Run("----\Placeholder 8.bat") Case $msg[0] = $backupbutton9 Run("----\Placeholder 9.bat") Case $msg[0] = $backupbutton10 Run("----\Placeholder 10.bat") Case $msg[0] = $backupbutton11 Run("----\Placeholder 11.bat") Case $msg[0] = $backupbutton12 Run("----\Placeholder 12.bat") Case $msg[0] = $backupbutton13 Run("----\Placeholder 13.bat") Case $msg[0] = $backupbutton14 Run("----\Placeholder 14.bat") Case $msg[0] = $backupbutton15 Run("----\Placeholder 15.bat") Case $msg[0] = $backupbutton16 Run("----\Placeholder 16.bat") Case $msg[0] = $backupbutton17 Run("----\UserChoice\LNK Placeholder 17.bat") ; bat file runs a .lnk shortcut Case $msg[0] = $backupbutton18 Run("----\UserChoice\LNK Placeholder 18.bat") ; bat file runs a .lnk shortcut ; Case $msg[0] = $backupbutton19 ; Run("----\Placeholder 19.bat") ; Case $msg[0] = $backupbutton20 ; Run("----\Placeholder 20.bat") ; Case $msg[0] = $backupbutton21 ; Run("----\Placeholder 21.bat") ; Case $msg[0] = $backupbutton22 ; Run("----\Placeholder 22.bat") Case $msg[0] = $backupbutton23 Run("----\Open Device Root.bat") Case $msg[0] = $backupbutton24 ShellExecute ("----\Basic Backup.rtf") ; ########################################################################################### Case $msg[0] = $copy_btc_address_button ClipPut(GUICtrlRead($btc_address)) Case $msg[0] = $GUI_EVENT_SECONDARYDOWN If ButtonClicked($hGUI, $Backupbutton1, $msg) Then MsgBox(0, '', 'Whatever, do you stuff.') Case Else ;;; EndSelect WEnd Func _myWM_MOVE($hWnd, $nMsg, $wParam, $lParam) Local $aWPos = WinGetPos($hWnd) If IsArray($aWPos) Then IniWrite($sMyIniLocation, 'MAINWINPOS', 'XPOS', $aWPos[0]) IniWrite($sMyIniLocation, 'MAINWINPOS', 'YPOS', $aWPos[1]) EndIf Return EndFunc Func ButtonClicked($hWin, $Backupbutton, $aMsg) Local $aPos = ControlGetPos($hWin, '', $Backupbutton) If $aMsg[3] > $aPos[0] And $aMsg[3] < $aPos[0] + $aPos[2] Then If $aMsg[4] > $aPos[1] And $aMsg[4] < $aPos[1] + $aPos[3] Then Return True EndIf EndIf Return False EndFunc Btw, what on earth is this suppose to do? For $main_tab = 1 To 1 ... Next Edited July 1, 2023 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
TalesFromTheScript Posted July 1, 2023 Author Share Posted July 1, 2023 Thanks Andreik I owe you one. It's all working and I can (just about) manage to carry on adding the right-click for the other buttons. I'm almost useless at this stuff compared to you guys. I don't even know how I got the original script working or who helped me, but it was probably someone from here. Or maybe I was getting it all from somewhere like superuser and just botching it all together myself with trial and error. 😛 Who put that... For $main_tab = 1 To 1 ... Next I don't know lol. It could be me, it could be anyone! Now it's all good 🙂 expandcollapse popup#include <GuiConstants.au3> #include <AutoItConstants.au3> #include <WindowsConstants.au3> #include <ColorConstantS.au3> #include <GUIConstantsEx.au3> #include <TrayConstants.au3> #include <FontConstants.au3> #include <ListViewConstants.au3> #include <TabConstants.au3> ; No tray icon TraySetState(2) ; Tab colours Global $aTabColours[6] = [0xFFC0C0, 0xC0FFC0, 0xC0C0FF, 0xC0C0C0, 0xC0FFC0, 0xC0C0C0] Global $sMyIniLocation = "----\WinPos\WinPos_GM.ini" ;; Raising DesktopWidth moves the GUI left ;; Raising DesktopHeight moves the GUI up Global $nIniXPos = Int(IniRead($sMyIniLocation, 'MAINWINPOS', 'XPOS', Int(@DesktopWidth/3.5))) Global $nIniYPos = Int(IniRead($sMyIniLocation, 'MAINWINPOS', 'YPOS', Int(@DesktopHeight/2.8))) Global $iWidth = 394, $iHeight = 428 $nIniXPos = (($nIniXPos <> -32000) ? ($nIniXPos) : ((@DesktopWidth - $iWidth) / 2)) $nIniYPos = (($nIniYPos <> -32000) ? ($nIniYPos) : ((@DesktopHeight - $iHeight) / 2)) GUIRegisterMsg(0x03, "_myWM_MOVE") GUISetState() ; GUI ; This creates an "Always on top" version of the GUI... ; $hGUI = GUICreate("GMenu", $iWidth, $iHeight, $nIniXPos, $nIniYPos, Default, $WS_EX_TOPMOST) ; This creates a standard GUI... $hGUI = GUICreate("GMenu", $iWidth, $iHeight, $nIniXPos, $nIniYPos, Default) GUISetBkColor(0x000000) ; GUI background color GuiSetIcon("icon.ico", 0) ; GUISetBkColor(0x990000) ; GUISetBkColor(0xe6f2ff) ; GUISetBkColor(0x000000) ; PIC ; GuiCtrlCreatePic("pic.jpg", 0, 0, 300, 700) ; Font for all tabs $MainTabCtrl = GUICtrlCreateTab(0, 0, 394, 428,$GUI_SS_DEFAULT_TAB) GUICtrlSetFont ($MainTabCtrl,13, 700, 0, "Segoe UI") ; Centralize tab text GUICtrlSendMsg ($MainTabCtrl, $TCM_SETMINTABWIDTH , 0, 0) ; |======| ; | | ; | Tabs | ; | | ; |======| ; ; ---------------------------------------------------------------------------------------- ; Button position/sizing explained: ; 1st number = Left/Right position, number applies to top left corner (5) ; 2nd number = Top/Bottom position, number applies to top left corner (40) ; 3rd number = Button length (189) [This allows for 20 characters with current font setup] ; 4th number = Button height (30) [A difference of 32 between each button is required] ; ---------------------------------------------------------------------------------------- ; ########################################################################################### ; Main tab $hTab1 = GUICtrlCreateTab(0, 0, 394, 428) ; Create tabitems For $main_tab = 1 To 1 GUICtrlCreateTabItem("Menu") ; Main tab buttons $Backupbutton1 = GUICtrlCreateButton ("Basic Backup", 5,40,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton1, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton2 = GUICtrlCreateButton ("Combine Backups", 197,40,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton2, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton3 = GUICtrlCreateButton ("Copy GPX", 5,72,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton3, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton4 = GUICtrlCreateButton ("Placeholder 4", 197,72,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton4, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton5 = GUICtrlCreateButton ("Placeholder 5", 5,104,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton5, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x80ffff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton6 = GUICtrlCreateButton ("Placeholder 6", 197,104,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton6, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x80ffff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton7 = GUICtrlCreateButton ("Placeholder 7", 5,136,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton7, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x80ffff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton8 = GUICtrlCreateButton ("Placeholder 8", 197,136,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton8, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x80ffff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton9 = GUICtrlCreateButton ("Placeholder 9", 5,168,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton9, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton10 = GUICtrlCreateButton ("Placeholder 10", 197,168,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton10, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton11 = GUICtrlCreateButton ("Placeholder 11", 5,200,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton11, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton12 = GUICtrlCreateButton ("Placeholder 12", 197,200,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton12, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x99ccff) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton13 = GUICtrlCreateButton ("Placeholder 13", 5,232,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton13, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0xffcc00) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton14 = GUICtrlCreateButton ("Placeholder 14", 197,232,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton14, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x00e6e6) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton15 = GUICtrlCreateButton ("Placeholder 15", 5,264,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton15, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x00e6e6) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton16 = GUICtrlCreateButton ("Placeholder 16", 197,264,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton16, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x00e6e6) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton17 = GUICtrlCreateButton ("Placeholder 17", 5,296,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton17, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0x00e6e6) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton18 = GUICtrlCreateButton ("Placeholder 18", 197,296,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton18, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0xffb3ff) GUICtrlSetImage (-1, "Icon2.ico",-1) ; $Backupbutton19 = GUICtrlCreateButton ("Placeholder 19", 5,328,189,30,$BS_ICON) ; GUICtrlSetFont ($Backupbutton19, 12, 700, 0, "Segoe UI") ; GUICtrlSetBkColor(-1, 0x99ccff) ; GUICtrlSetImage (-1, "Icon2.ico",-1) ; $Backupbutton20 = GUICtrlCreateButton ("Placeholder 20", 197,328,189,30,$BS_ICON) ; GUICtrlSetFont ($Backupbutton20, 12, 700, 0, "Segoe UI") ; GUICtrlSetBkColor(-1, 0x99ccff) ; GUICtrlSetImage (-1, "Icon2.ico",-1) ; $Backupbutton21 = GUICtrlCreateButton ("Placeholder 21", 5,360,189,30,$BS_ICON) ; GUICtrlSetFont ($Backupbutton21, 12, 700, 0, "Segoe UI") ; GUICtrlSetBkColor(-1, 0x99ccff) ; GUICtrlSetImage (-1, "Icon2.ico",-1) ; $Backupbutton22 = GUICtrlCreateButton ("Placeholder 22", 197,360,189,30,$BS_ICON) ; GUICtrlSetFont ($Backupbutton22, 12, 700, 0, "Segoe UI") ; GUICtrlSetBkColor(-1, 0x99ccff) ; GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton23 = GUICtrlCreateButton ("Open Garmin Folder", 5,392,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton23, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0xcccccc) GUICtrlSetImage (-1, "Icon2.ico",-1) $Backupbutton24 = GUICtrlCreateButton ("Help Guide", 197,392,189,30,$BS_ICON) GUICtrlSetFont ($Backupbutton24, 12, 700, 0, "Segoe UI") GUICtrlSetBkColor(-1, 0xf2f2f2) GUICtrlSetImage (-1, "Icon2.ico",-1) Next ; Close Tab definiton GUICtrlCreateTabItem("") ; ########################################################################################### ; About tab $hTab6 = GUICtrlCreateTab(0, 0, 394, 428) ; Create tabitems For $about_tab = 1 To 1 GUICtrlCreateTabItem("About") ; title GUICtrlCreateLabel("Gmenu v1.01", 35, 50, 394, 30) GUICtrlSetFont(-1, 14, 700, "Segoe UI") GUICtrlCreateLabel("(2023-06-30)", 35, 75, 394, 30) GUICtrlSetFont(-1, 12, 700, "Segoe UI") ; main text GUICtrlCreateLabel("This program is provided free of charge, with", 20, 110, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("no limitations, for private or commercial use.", 20, 130, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("If you have found this menu program to be useful", 20, 160, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("and would like to donate Bitcoin to the creator,", 20, 180, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("you can via the Bitcoin address shown below.", 20, 200, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("Thanks in advance to anyone that decides to", 20, 230, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("make a donation!", 20, 250, 394, 30) GUICtrlSetFont(-1, 11, 700, "Segoe UI") GUICtrlCreateLabel("Bitcoin donate address:", 100, 280, 394, 30) GUICtrlSetFont(-1, 14, 700, "Segoe UI") $btc_address = GUICtrlCreateEdit("BTC address goes here", 7, 310, 380, 25, BitOR($ES_READONLY, $WS_VISIBLE, $ES_CENTER)) GUICtrlSetFont(-1, 12, 700, "Segoe UI") GUICtrlSetColor($btc_address, $COLOR_BLUE) $copy_btc_address_button = GUICtrlCreateButton ("Copy to clipboard", 100,350,189,30,$BS_ICON) GUICtrlSetFont ($copy_btc_address_button, 12, 700, 0, "Segoe UI") Next ; Close Tab definiton GUICtrlCreateTabItem("") ; ######################## ; ####################### ; ###################### ; ##################### ; #################### ; ################### ; ################## ; ################# ; ################ ; ############### ; ############## ; ############# ; ############ ; ########### ; ########## ; ######### ; ######## ; ####### ; ###### ; ##### ; #### ; ### ; ## ; # ; ########################################################################################### ; |================================| ; | | ; | | ; | Buttons linking to batch files | ; | | ; | | ; |================================| GUISetState() While 1 $msg = GUIGetMsg(1) Select Case $msg[0] = $GUI_EVENT_CLOSE Exit ; Batch files: Case $msg[0] = $backupbutton1 Run("----\Basic Backup.bat") Case $msg[0] = $backupbutton2 Run("----\Combine Basic Backups.bat") Case $msg[0] = $backupbutton3 Run("----\Copy GPX Files.bat") Case $msg[0] = $backupbutton4 Run("----\Placeholder 4.bat") Case $msg[0] = $backupbutton5 Run("----\Placeholder 5.bat") Case $msg[0] = $backupbutton6 Run("----\Placeholder 6.bat") Case $msg[0] = $backupbutton7 Run("----\Placeholder 7.bat") Case $msg[0] = $backupbutton8 Run("----\Placeholder 8.bat") Case $msg[0] = $backupbutton9 Run("----\Placeholder 9.bat") Case $msg[0] = $backupbutton10 Run("----\Placeholder 10.bat") Case $msg[0] = $backupbutton11 Run("----\Placeholder 11.bat") Case $msg[0] = $backupbutton12 Run("----\Placeholder 12.bat") Case $msg[0] = $backupbutton13 Run("----\Placeholder 13.bat") Case $msg[0] = $backupbutton14 Run("----\Placeholder 14.bat") Case $msg[0] = $backupbutton15 Run("----\Placeholder 15.bat") Case $msg[0] = $backupbutton16 Run("----\Placeholder 16.bat") Case $msg[0] = $backupbutton17 Run("----\UserChoice\LNK Placeholder 17.bat") ; bat file runs a .lnk shortcut Case $msg[0] = $backupbutton18 Run("----\UserChoice\LNK Placeholder 18.bat") ; bat file runs a .lnk shortcut ; Case $msg[0] = $backupbutton19 ; Run("----\Placeholder 19.bat") ; Case $msg[0] = $backupbutton20 ; Run("----\Placeholder 20.bat") ; Case $msg[0] = $backupbutton21 ; Run("----\Placeholder 21.bat") ; Case $msg[0] = $backupbutton22 ; Run("----\Placeholder 22.bat") Case $msg[0] = $backupbutton23 Run("----\Open Device Root.bat") Case $msg[0] = $backupbutton24 ShellExecute ("----\Basic Backup.rtf") ; ########################################################################################### Case $msg[0] = $copy_btc_address_button ClipPut(GUICtrlRead($btc_address)) ; RIGHT CLICKS Case $msg[0] = $GUI_EVENT_SECONDARYDOWN If ButtonClicked1($hGUI, $Backupbutton1, $msg) Then ShellExecute ("----\Basic Backup.rtf") If ButtonClicked2($hGUI, $Backupbutton2, $msg) Then ShellExecute ("----\Combine Basic Backups.rtf") If ButtonClicked3($hGUI, $Backupbutton3, $msg) Then ShellExecute ("----\Copy GPX Files.rtf") Case Else EndSelect WEnd ; Code for saving window position Func _myWM_MOVE($hWnd, $nMsg, $wParam, $lParam) Local $aWPos = WinGetPos($hWnd) If IsArray($aWPos) Then IniWrite($sMyIniLocation, 'MAINWINPOS', 'XPOS', $aWPos[0]) IniWrite($sMyIniLocation, 'MAINWINPOS', 'YPOS', $aWPos[1]) EndIf Return EndFunc ; BUTTON CLICK CHECKS Func ButtonClicked1($hWin, $Backupbutton1, $aMsg) Local $aPos = ControlGetPos($hWin, '', $Backupbutton1) If $aMsg[3] > $aPos[0] And $aMsg[3] < $aPos[0] + $aPos[2] Then If $aMsg[4] > $aPos[1] And $aMsg[4] < $aPos[1] + $aPos[3] Then Return True EndIf EndIf Return False EndFunc Func ButtonClicked2($hWin, $Backupbutton2, $aMsg) Local $aPos = ControlGetPos($hWin, '', $Backupbutton2) If $aMsg[3] > $aPos[0] And $aMsg[3] < $aPos[0] + $aPos[2] Then If $aMsg[4] > $aPos[1] And $aMsg[4] < $aPos[1] + $aPos[3] Then Return True EndIf EndIf Return False EndFunc Func ButtonClicked3($hWin, $Backupbutton3, $aMsg) Local $aPos = ControlGetPos($hWin, '', $Backupbutton3) If $aMsg[3] > $aPos[0] And $aMsg[3] < $aPos[0] + $aPos[2] Then If $aMsg[4] > $aPos[1] And $aMsg[4] < $aPos[1] + $aPos[3] Then Return True EndIf EndIf Return False EndFunc 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