It sounds like you want a window rollup. The following threads may help you.
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=88722
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=87235
GUI help with control in autoselecting items.
Re: GUI help with control in autoselecting items.
Code: Select all
GuiControl, %type%:Hide, ListBox1
...
Gui, %type%:Show, AutoSize
Re: GUI help with control in autoselecting items.
Thank you very much for the suggestion and Ill read up on those sites regarding the windows "rollup". I certainly don't want to reinvent the wheel if there is something already robust out there. However, this has been a great learning opportunity!
Re: GUI help with control in autoselecting items.
Try just me's method-- possibly the easiest approach.
Re: GUI help with control in autoselecting items.
Thank you Just me. Appreciate you! I give this a shot.also thanks for pointing out the errors earlier at the bottom of the script.just me wrote: ↑18 May 2021, 09:49Code: Select all
GuiControl, %type%:Hide, ListBox1 ... Gui, %type%:Show, AutoSize
Re: GUI help with control in autoselecting items.
Hello! I added it to the function side of the code but the hiding of the ListBox didn't occur. I set XX as global variables as well and not sure if that was the right thing to do but that did not help. I tested it with a msgbox which seemed to work without the hiding bit. Any other ideas?
I get an error with but if I remove the %type% the script runs but the hiding still not kicking in. I tried without luck.
I get an error with
Code: Select all
Gui, %type%:Show, AutoSize
Code: Select all
GuiControl, %type%:Hide, ListBox1
Code: Select all
findings("LIVER", FFI1x, FFI1y), findings("LUNG_BASES", FFI2x, FFI2y)
findings(type, x := -1, y := 0) {
If (x < 0) {
Gui, %type%:Hide
Return
}
Static finding
For k, v in scan[type]
box .= (A_Index > 1 ? "|" : "") v.1
Gui, %type%:New
Gui, Color, c000111, c34294d
Gui, +AlwaysOnTop +LastFound
Gui, Add, Progress, xm-1 ym-12 w150 h35 BackgroundCC6633 Disabled ;hwndHPROG
Gui, Add, Text, xm+6 ym w100 h20 r1 BackgroundTrans Center 0x200, %type%
Gui, Add, Progress, xm+160 ym-12 w20 h35 BackgroundCC6633 Disabled ;hwndHPROG
Gui, Add, Text, xm+120 ym w100 h20 r1 gShowHide BackgroundTrans Center 0x200, X
Gui, Font, s10 cFFFFFF, Verdana
Gui, Add, Edit, vFindingsEdit WantTab R5 xm ym+20 w180 r1 hwndMyEditBox1Hwnd
Gui, Font, s10 cFFFFFF, Verdana
Gui, Add, Edit, vImpressionEdit WantTab xm ym+40 w180 r1 hwndMyEditBox2Hwnd
Gui, Font, s10 c6A9955, VerdanaFF
Gui, Add, ListBox, xm ym+65 r5 w180 vfinding AltSubmit Multi Choose2, %box%
Gui, Add, Button, Default, OK
Gui, -Caption
WinSet, TransColor, 000111 110
Gui, Show, x%x% y%y% h200 w200, % StrReplace(type, "_", " ")
Return
ShowHide:
IF XX=1
{
xx=0
msgbox, hideit
GuiControl, %type%:Hide, ListBox1
}
else
{
msgbox, showit
Gui, %type%:Show, AutoSize
xx=1
}
return
LIVERButtonOK:
LUNG_BASESButtonOK:
Gui, %A_Gui%:Submit, NoHide
ttext =
For k, v in StrSplit(finding, "|")
ttext .= scan[A_Gui][v].1 ". "
ttext := Trim(ttext) ""","""
For k, v in StrSplit(finding, "|")
ttext .= scan[A_Gui][v].2 " "
ttext := """" StrReplace(A_Gui, "_", " ") """,""" Trim(ttext) """"
MsgBox, 64, Result, %ttext%
Loop, parse, ttext, ".",
{
FileAppend, %A_LoopField%, template.txt
}
FileRead, template, template.txt
ControlSetText, Edit1, %template% `n, DD
return
}
Re: GUI help with control in autoselecting items.
Why do you think that the 'GUI_In_A_Function' concept has any advantages?
Code: Select all
...
Gui, Add, ListBox, xm ym+65 r5 w180 vfinding AltSubmit Multi Choose2, %box%
...
ShowHide:
GuiControlGet, Vis, Visible, finding ; the ListBox is named 'finding', not ListBox1
GuiControl, Hide%Vis%, finding
Gui, Show, AutoSize
Return
Re: GUI help with control in autoselecting items.
That is a good question. I assumed that since the labels for Liver and Lung were in the function than so should the ShowHide? I still trying to understand the global/local variable concept and still confused on how functions work since limited knowledge but learning from this script so I appreciate the time.
The new code however did not work either. Out or inside the function. I included the entire script with the new snippet to see if I keep making blunders.
The new code however did not work either. Out or inside the function. I included the entire script with the new snippet to see if I keep making blunders.
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#MaxHotkeysPerInterval 250 ;Avoid warning when mouse wheel turned very fast
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance, force
CoordMode, Caret, Relative
CoordMode, Mouse, Relative
SetBatchLines -1
OnMessage(0x201, "WM_LBUTTONDOWN")
WM_LBUTTONDOWN()
{
PostMessage 0xA1,2
}
;/////////////////////////////////////////////////////////////
;Color and Brightness/transparancy
Purple := "34294d"
White := "FFFFFF"
Green2 := "007369"
Green := "6A9955"
DarkGrey := "c000000"
Orange := "CC6633"
GuiColor := 0x000111
trans := 110
Brightness := 225
;///////////////////////////////////////////////////////////////////////
Global FindingsEdit := []
Global ImpressionEdit := []
Global Findings := []
Global Impression := []
Global scan := []
Global MyEdit1 := []
Global MyEdit2 := []
Global template := []
;Findings1
scan["LUNG_BASES"]
:= [["Clear."]
,["Bibasilar atelectasis." , "Bibasilar atelectasis versus lung scarring."]
,["Centrilobular emphysematous changes are present." ,"Emphysematous/COPD Lung disease."]
,["Hiatal hernia is present." ,"Hiatal hernia is present."]
,["Pulmonary nodule present." ,"Pulmonary nodule(s). Recommend dedicated CT of the chest to assess for other nodules and initiate a Lung Cancer Screening program."]]
;Findings2
scan["LIVER"]
:= [["No biliary obstruction."]
,["Liver appears hypodense." ,"Hepatic Steatosis."]]
;/////////////////////////////////////////////////////////////////
;Screen positions
FFI1x := 225 ;lungs
FFI1y := 1475
FFI2x := 0 ;Liver
FFI2y := 675
FFI3x := 0 ;gb
FFI3y := 525
FFI4x := 875 ;spleen
FFI4y := 1400
FFI5x := 875 ;panc
FFI5y := 650
FFI6x := 0 ;adrenals
FFI6y := 1380
FFI7x := 875 ;urological
FFI7y := 500
FFI8x := 655 ;bowel
FFI8y := 500
FFI9x := 235 ;abd wall
FFI9y := 500
FFI10x := 450 ;reproductive
FFI10y := 1500
FFI11x := 660 ;bones
FFI11y := 1480
FFI12x := 450 ;vasc
FFI12y := 450
;///////////////////////////////////////////////////////////
findings("LIVER", FFI1x, FFI1y), findings("LUNG_BASES", FFI2x, FFI2y)
findings(type, x := -1, y := 0) {
If (x < 0) {
Gui, %type%:Hide
Return
}
;findings(type, x := -1, y := 0) {
Static finding
For k, v in scan[type]
box .= (A_Index > 1 ? "|" : "") v.1
Gui, %type%:New
Gui, Color, c000111, c34294d
Gui, +AlwaysOnTop +LastFound
Gui, Add, Progress, xm-1 ym-12 w150 h35 BackgroundCC6633 Disabled ;hwndHPROG
Gui, Add, Text, xm+6 ym w100 h20 r1 BackgroundTrans Center 0x200, %type%
Gui, Add, Progress, xm+160 ym-12 w20 h35 BackgroundCC6633 Disabled ;hwndHPROG
Gui, Add, Text, xm+120 ym w100 h20 r1 gShowHide BackgroundTrans Center 0x200, X
Gui, Font, s10 cFFFFFF, Verdana
Gui, Add, Edit, vFindingsEdit WantTab R5 xm ym+20 w180 r1 hwndMyEditBox1Hwnd
Gui, Font, s10 cFFFFFF, Verdana
Gui, Add, Edit, vImpressionEdit WantTab xm ym+40 w180 r1 hwndMyEditBox2Hwnd
Gui, Font, s10 c6A9955, VerdanaFF
Gui, Add, ListBox, xm ym+65 r5 w180 vfinding AltSubmit Multi Choose2, %box%
Gui, Add, Button, Default, OK
Gui, -Caption
WinSet, TransColor, 000111 110
Gui, Show, x%x% y%y% h200 w200, % StrReplace(type, "_", " ")
Return
LIVERButtonOK:
LUNG_BASESButtonOK:
Gui, %A_Gui%:Submit, NoHide
ttext =
For k, v in StrSplit(finding, "|")
ttext .= scan[A_Gui][v].1 ". "
ttext := Trim(ttext) ""","""
For k, v in StrSplit(finding, "|")
ttext .= scan[A_Gui][v].2 " "
ttext := """" StrReplace(A_Gui, "_", " ") """,""" Trim(ttext) """"
MsgBox, 64, Result, %ttext%
Loop, parse, ttext, ".",
{
;ControlSetText, Edit1, %A_LoopField% `n, DD
;msgbox, %A_LoopField%
FileAppend, %A_LoopField%, template.txt
}
FileRead, template, template.txt
ControlSetText, Edit1, %template% `n, DD
return
}
;////////////////////MAIN GUI///////////////////////////////////////////////////
Gui, Main:Destroy
Gui, Main:+AlwaysOnTop +ToolWindow -border +LastFound +HwndMyGuiHwnd ;+E0x08000000
WinSet, Transparent, 190
Gui, Main:Color, %Purple%, %DarkGrey%
Gui, Main:Margin, 0, 0
Gui, Main:Font, c%White% s8, q5 Bold
Gui, Main:Add, Button, x970 y1 w30 h18 gGuiClose, X
Gui, Main:Add, Button, x885 y1 w60 h18 gSave, Save
Gui, Main:-Caption
Gui, Main:Font, s12 c%Orange%, Verdana
Gui, Main:Add, Edit, vMyEdit1 WantTab xm ym+20 w1000 r12 hwndMyEdit1Hwnd
Gui Main:Show, x+10 y1625 w1000 h270, DD
;///////////////////////////////////////////////////////////////////////////////
ShowHide:
msgbox, test
GuiControlGet, Vis, Visible, finding
GuiControl, Hide%Vis%, finding
Gui, Show, AutoSize
Return
FindingsEditSend:
Return
ImpressionEditSend:
Return
;Manual hide/show
F11::findings("LIVER", FFI1x, FFI1y), findings("LUNG_BASES", FFI2x, FFI2y)
F12::findings("LIVER"), findings("LUNG_BASES")
;Not working
Save:
;FileDelete, template.txt
;Sleep, 20
;Gui, Main:Submit, NoHide
;FileAppend, %MyEdit1% `n, template.txt
;Sleep, 50
Return
GuiEscape:
GuiClose:
;Gui, %A_Gui%:Destroy
ExitApp
Re: GUI help with control in autoselecting items.
Using Subroutines Within a Function:
?
- Such subroutines should use only global variables (not static variables) as GUI control variables.
Re: GUI help with control in autoselecting items.
Sorry, did not see that the label is outside of the function. But the variable does not exist in the global context:
Code: Select all
Static finding
Re: GUI help with control in autoselecting items.
So how would I fix this. I did declare findings as global but I guess the static findings goes against that logic. Put the ShowHide label in the function then? Your beginning to also understand my limited abilities. I'm a small fish in big waters chasing sharks and getting into trouble.
Re: GUI help with control in autoselecting items.
Yes still working on this as it seems not to be that simple.
On the other hand getting the script to slowly function. Some guidance? Right now each GUI sends out data. Then clears the data on the next GUI adjustment. Should I somehow append these strings into one file or variable? After all the guis are submitted eventually, I would grab that file or variable and then do a loop parse to separate them out? The ultimate goal is to have it look like this:
Lungs: Clear.
Liver: Hypodense liver.
Impression:
Hypodense liver suggest hepatic steatosis.
Re: GUI help with control in autoselecting items.
You can build a string without having to create a file to do it. You could have a global findings string, and a global impressions string. You can append to each string when you process each GUI.
Re: GUI help with control in autoselecting items.
Ok great I will try that and then parse using loop parse and concatenate them? Do you not suggest using stringsplit etc commmands and better to loop parse?
Re: GUI help with control in autoselecting items.
Whether you loop or StrSplit makes no difference, but if you are just building a text string for the report, then there is perhaps nothing that needs to be parsed from that.
Re: GUI help with control in autoselecting items.
I also overlooked the Ok button added at the bottom of the GUIs. To make AutoSIze work as intended, it must be hidden or moved to the top.
I spent some time on your last script version. I would do something like
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
#MaxHotkeysPerInterval 250 ;Avoid warning when mouse wheel turned very fast
#SingleInstance, force
SetBatchLines -1
SendMode, Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir, %A_ScriptDir% ; Ensures a consistent starting directory.
CoordMode, Caret, Relative
CoordMode, Mouse, Relative
;///////////////////////////////////////////////////////////////////////////////
;Color and Brightness/transparancy
Purple := "34294d"
White := "FFFFFF"
Green2 := "007369"
Green := "6A9955"
DarkGrey := "c000000"
Orange := "CC6633"
GuiColor := 0x000111
Trans := 110
Bright := 225
;///////////////////////////////////////////////////////////////////////////////
Global Scan := []
;Findings1
Scan["LUNG_BASES"]
:= {X: 225, Y: 300
, Findings: [["Clear."
, ""]
, ["Bibasilar atelectasis."
, "Bibasilar atelectasis versus lung scarring."]
, ["Centrilobular emphysematous changes are present."
, "Emphysematous/COPD Lung disease."]
, ["Hiatal hernia is present."
, "Hiatal hernia is present."]
, ["Pulmonary nodule present."
, "Pulmonary nodule(s). Recommend dedicated CT of the chest "
. "to assess for other nodules and initiate a Lung Cancer "
. "Screening program."]]}
;Findings2
Scan["LIVER"]
:= {X: 0 , Y: 300
, Findings: [["No biliary obstruction."
, ""]
, ["Liver appears hypodense."
, "Hepatic Steatosis."]]}
;///////////////////////////////////////////////////////////////////////////////
; Main GUI
Gui, Main:Destroy
Gui, Main:+AlwaysOnTop +ToolWindow -border +LastFound +HwndMyGuiHwnd ;+E0x08000000
WinSet, Transparent, 190
Gui, Main:Color, %Purple%, %DarkGrey%
Gui, Main:Margin, 0, 0
Gui, Main:Font, c%White% s8, q5 Bold
Gui, Main:Add, Button, x970 y1 w30 h18 gMainGuiClose, X
Gui, Main:Add, Button, x885 y1 w60 h18 gSave, Save
Gui, Main:-Caption
Gui, Main:Font, s12 c%Orange%, Verdana
Gui, Main:Add, Edit, vMyEdit1 WantTab xm ym+20 w1000 r12 hwndMyEdit1Hwnd
Gui Main:Show, x10 y600 w1000 h270, DD
;///////////////////////////////////////////////////////////////////////////////
; Findings GUIs
For Name, Obj In Scan {
GuiX := Obj.X
GuiY := Obj.Y
BoxList := ""
For I, Entry In Obj.Findings
BoxList .= (A_Index > 1 ? "|" : "") . Entry[1]
Gui, %Name%:New, -Caption +AlwaysOnTop +LastFound
Gui, Margin, 0, 0
Gui, Color, c34294d, c34294d
Gui, Add, Progress, x1 y1 w198 h29 BackgroundCC6633 Disabled ;hwndHPROG
Gui, Font, s14, Webdings
Gui, Add, Text, xm ym w30 h30 gShowHide vBtnShow cWhite BackgroundTrans Center +0x0200, 6
Gui, Font
Gui, Font, s10 Bold
Gui, Add, Text, x+0 ym w140 hp cWhite BackgroundTrans Center +0x0300 vCaption, %Name% ; SS_NOTIFY = 0x0100
Gui, Add, Text, x+0 ym w30 hp gStore cWhite BackgroundTrans Center +0x0200, OK
Gui, Font, s14, Webdings
Gui, Font
Gui, Font, s10 cFFFFFF, Verdana
Gui, Add, Edit, vFindingsEdit WantTab xm y+0 w200 r1 hwndMyEditBox1Hwnd
Gui, Font, s10 cFFFFFF, Verdana
Gui, Add, Edit, vImpressionEdit WantTab xm y+0 w200 r1 hwndMyEditBox2Hwnd
Gui, Font, s10 c6A9955, VerdanaFF
Gui, Add, ListBox, xm y+0 w200 r5 vFinding AltSubmit Multi Choose2 Hidden, %BoxList%
WinSet, Transparent, %Trans%
Gui, Show, x%GuiX% y%GuiY% AutoSize, %Name%
}
OnMessage(0x0201, "WM_LBUTTONDOWN")
Return
;///////////////////////////////////////////////////////////////////////////////
WM_LBUTTONDOWN() {
If Scan.HasKey(A_Gui) && (A_GuiControl = "Caption")
PostMessage 0xA1, 2
}
;///////////////////////////////////////////////////////////////////////////////
ShowHide:
GuiControlGet, Vis, Visible, Finding
GuiControl, Hide%Vis%, Finding
GuiControl, , %A_GuiControl%, % (Vis ? 6 : 5)
Gui, Show, AutoSize
WinSet, Transparent, % (Vis ? Trans : Bright)
Return
;///////////////////////////////////////////////////////////////////////////////
Store:
Gui, Submit, NoHide
FindingsList := ""
ImpressionsList := ""
For Each, Index In StrSplit(Finding, "|") {
FindingsList .= Scan[A_Gui, "Findings", Index, 1] . ". "
ImpressionsList .= Scan[A_Gui, "Findings", Index, 2] . " "
}
Result := """" . StrReplace(A_Gui, "_", " ") . ""","""
. Trim(FindingsList) . ""","""
. Trim(ImpressionsList) . """"
MsgBox, 0, Result:, %Result%
Return
;///////////////////////////////////////////////////////////////////////////////
FindingsEditSend:
Return
;///////////////////////////////////////////////////////////////////////////////
ImpressionEditSend:
Return
;///////////////////////////////////////////////////////////////////////////////
;Manual hide/show
F11::
For Name In Scan
Gui, %Name%:Hide
Return
F12::
For Name In Scan
Gui, %Name%:Show
Return
;///////////////////////////////////////////////////////////////////////////////
;Not working
Save:
;FileDelete, template.txt
;Sleep, 20
;Gui, Main:Submit, NoHide
;FileAppend, %MyEdit1% `n, template.txt
;Sleep, 50
Return
;///////////////////////////////////////////////////////////////////////////////
MainGuiEscape:
MainGuiClose:
;Gui, %A_Gui%:Destroy
ExitApp
Re: GUI help with control in autoselecting items.
I really appreciate you taking the time to review the entire script!
This worked well. How do I default it to keep the list box open instead of closed on first load and if user wants to minimize it later? This was mainly so that it can be minimized if in the way of the images but I guess can be moved as well so not a big issue.
I modified it to also add the Edit box for each gui a FindingsEdit and a ImpressionEdit so that the user can elaborate on the items choosen in the list. I'm assuming the """,""" to to help parse this at a later time?
This worked well. How do I default it to keep the list box open instead of closed on first load and if user wants to minimize it later? This was mainly so that it can be minimized if in the way of the images but I guess can be moved as well so not a big issue.
I modified it to also add the Edit box for each gui a FindingsEdit and a ImpressionEdit so that the user can elaborate on the items choosen in the list. I'm assuming the """,""" to to help parse this at a later time?
Code: Select all
Result := """" . StrReplace(A_Gui, "_", " ") . ""","""
. Trim(FindingsList) . ""","""
. Trim(FindingsEdit) . """" . ""","""
. Trim(ImpressionsList) . """" . ""","""
. Trim(ImpressionEdit) . """"
Last edited by iilabs on 21 May 2021, 09:59, edited 1 time in total.
Re: GUI help with control in autoselecting items.
I figure I still need to parse and concatenate since the data are not really in format I want for a report?
I was able to parse and concatenate a report in the EditBox and a file saved as template. Would you mind looking at the code if this was optimally done?
My last step is to add a "`n" after each findings and impression. Ive tried everywhere including editbox, in the string split command, and also tried in the file append without luck. Last step folks!!
Code: Select all
Store:
Gui, Submit, NoHide
FindingsList := ""
ImpressionsList := ""
For Each, Index In StrSplit(Finding, "|") {
FindingsList .= Scan[A_Gui, "Findings", Index, 1] ;removed . ". "
ImpressionsList .= Scan[A_Gui, "Findings", Index, 2] ;removed . " "
}
ResultT := StrReplace(A_Gui, "_", " ") . ": " . "," ;added ":"
ResultF := ResultT . Trim(FindingsList) . " "
. ","
ResultI := Trim(ImpressionsList) . " "
. ","
loop, parse, ResultF, `,
{
DraftF := DraftF . A_LoopField
;MsgBox, %DraftF%
Sleep, 20
}
DraftF := DraftF . FindingsEdit
loop, parse, ResultI, `,
{
DraftI := DraftI . A_LoopField
;MsgBox, %DraftI%
Sleep, 20
}
DraftI := DraftI . ImpressionEdit
ControlSetText, Edit1, %DraftF% %DraftI%, DD
Return
Last edited by iilabs on 22 May 2021, 08:43, edited 2 times in total.
Re: GUI help with control in autoselecting items.
I figured this out by removing "hidden" from the listbox code. Thanks!
Code: Select all
Gui, Add, ListBox, xm y+0 w200 r5 vFinding gStore AltSubmit Multi Choose2, %BoxList%
Who is online
Users browsing this forum: No registered users and 243 guests