Created
April 1, 2022 16:45
-
-
Save JoeGlines/aa9df3c2bf27e71070d1ca74c389f292 to your computer and use it in GitHub Desktop.
Saving and Importing to a GUI - example from friday support call
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#SingleInstance, Force | |
; Create the sub-menus for the menu bar: | |
Menu, FileMenu, Add, &New, Clear | |
Menu, FileMenu, Add | |
Menu, FileMenu, Add, &Import, Import | |
Menu, FileMenu, Add, &Export, Export | |
Menu, FileMenu, Add | |
Menu, FileMenu, Add, E&xit, GuiClose | |
; Create the menu bar by attaching the sub-menus to it: | |
Menu, MyMenuBar, Add, &File, :FileMenu | |
; Attach the menu bar to the window: | |
Gui, Main:Menu, MyMenuBar | |
; Create the main Edit control and display the window: | |
; Gui [Main] Layout | |
;------------------ | |
;--------------------------- | |
Gui, Main:Color, 41D2BE | |
Gui Main:+AlwaysOnTop | |
;Gui Text | |
Gui, Main:Add, Text, x22 y19 w100 h20 , User: | |
Gui, Main:Add, Text, x22 y49 w100 h20 , Institution: | |
Gui, Main:Add, Text, x22 y79 w100 h20 , Started Work: | |
Gui, Main:Add, Text, x22 y109 w100 h20 , Current Issue: | |
Gui, Main:Add, Text, x22 y139 w100 h20 , Callback Number: | |
Gui, Main:Add, Text, x22 y169 w100 h20 , Ticket Number: | |
;Gui Edit Fields | |
Gui, Main:Add, Edit, x132 y19 w140 h20 vUser, | |
Gui, Main:Add, Edit, x132 y49 w140 h20 vInst, | |
Gui, Main:Add, Edit, x132 y79 w140 h20 vStWk, | |
Gui, Main:Add, Edit, x132 y109 w140 h20 vTSum, | |
Gui, Main:Add, Edit, x132 y139 w140 h20 vCbNum, | |
Gui, Main:Add, Edit, x132 y169 w140 h20 vTNum, | |
Gui, Main:Add, Edit, x282 y19 w700 h280 vWkDn, Work Done: | |
Gui, Main:Add, Edit, x282 y309 w150 h20 vSgnSt, Signed Status: | |
Gui, Main:Add, Edit, x22 y199 w250 h130 vEmail, Email Body: | |
;Gui Buttons | |
Gui, Main:Add, Button, x442 y309 w100 h20 gEmail, Email | |
Gui, Main:Add, Button, x552 y309 w100 h20 gChat, Chat | |
Gui, Main:Add, Button, x662 y309 w100 h20 gClosingNote, Closing Note | |
Gui, Main:Add, Button, Default x772 y309 w100 h20 gWork, Work Done | |
Gui, Main:Add, Button, x882 y309 w100 h20 gClear, Clear | |
Gui, Main:Show, w999 h346, New Ticket GUI | |
GuiControl, Main:Focus, User | |
return | |
; Gui Labels | |
;------------------ | |
;--------------------------- | |
Work: ;sends the entiretly of the template. | |
Gui, Main:Submit | |
Send, ^bUser^b: %User%{Enter} | |
Send, ^bInstitution^b: %Inst% {Enter} | |
Send, ^bStarted Work^b: %StWk% {Enter} | |
Send, ^bTicket Summary^b: %TSum% {Enter} | |
Send, ^bCallback Number^b: %CbNum% {Enter} | |
Send, {Enter} | |
Send, ^bWork Done^b: {Enter}%WkDn% {Enter} | |
Send, {Enter} | |
Send, ^bSigned^b: ^uJoshua Thurman - %SgnSt% ^u | |
Gui, Main:Show | |
return | |
ClosingNote: ;sends JUST the first portion of the template with included variable | |
Gui, Main:Submit | |
Send, ^bUser^b: %User% {Enter} | |
Send, ^bSummary of Issue^b: %TSum% {Enter} | |
Send, ^bSummary of Resolution^b: {Enter} | |
Send, {Enter} | |
Send, Thanks for working with us on this issue. If it persists please feel free to reply to this email directly with any further information about the issue or it's continuance.{Enter} | |
Send, {Enter} | |
Send, Thanks,{Enter} | |
Send, ^uJosh Thurman - Closing as "Issue Resolved"^u | |
Gui, Main:Show | |
return | |
Email: | |
Gui, Main:Submit | |
send, Good Day %User%,{Enter} | |
Send, {Enter} | |
Send, %Email% {Enter} | |
Send, {Enter} | |
Send, Thanks, {Enter} | |
Send, Joshua Thurman | |
Gui, Main:Show | |
Return | |
Chat: | |
Gui, Main:Submit | |
Send, ^bUser^b: %User% {Enter} | |
Send, ^bTicket Number^b: %TNum% {Enter} | |
Send, ^bClient Institution^b: %Inst% {Enter} | |
Send, ^bDescription of Issue^b: %WkDn% {Enter} | |
Send, ^bTroubleshooting Summary^b: %TSum% | |
Gui, Main:Show | |
Return | |
Clear: | |
for each, control in ["User","Inst","StWk","TSum","CbNum", "TNum"] | |
GuiControl,, %control% | |
for control,value in {WkDn: "Work Done:", SgnSt: "Signed Status:", EMail: "Email Body:"} | |
GuiControl, Text, %control%, %value% | |
return | |
Import: | |
FileSelectFile, imFile, 3, % A_ScriptDir , Select file to import | |
if !imFile | |
{ | |
MsgBox, No file selected! | |
return | |
} | |
FileReadLine, data, %imFile%, 1 | |
data := StrSplit(data, "`t") | |
for each,control in ["User","Inst","StWk","TSum","CbNum","TNum","WkDn","SgnSt","EMail"] | |
GuiControl, Text, %control%, % data[a_index] | |
return | |
Export: | |
Gui Main:Submit, NoHide | |
FileSelectFile, exFile, S8, % A_ScriptDir "\" (exFile := User "-" A_Mon "-" A_WDay ".txt"), Select file to export to | |
if !exFile | |
{ | |
MsgBox, No file selected! | |
return | |
} | |
If (FileExist(exFile)) | |
FileDelete, %exFile% | |
data = %User% %Inst% %StWk% %TSum% %CbNum% %TNum% %WkDn% %SgnSt% %EMail% | |
FileAppend, %data%, %exFile% | |
Gosub, Clear | |
return | |
; FileNew: | |
; GuiControl,, User | |
; GuiControl,, Inst | |
; GuiControl,, StWk | |
; GuiControl,, TSum | |
; GuiControl,, CbNum | |
; GuiControl, Text, WkDn, Work Done: | |
; GuiControl, Text, SgnSt, Signed Status: | |
; GuiControl,, TNum | |
; GuiControl, Text, EMail, Email Body: | |
; return | |
GuiClose: | |
ExitApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment