Erratic behaviour of script when combo box is used

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
vbanait
Posts: 50
Joined: 09 Jul 2016, 05:51

Erratic behaviour of script when combo box is used

Post by vbanait » 16 Sep 2022, 05:59

Hi
In the following script, when I check checkboxes from different TABs, and a combobox in esophageal TAB, some of the checked items are not sent, while when they are sent individually, the script works fine. I am not able to understand this erratic behaviour.
Kindly help.

Here is the script

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.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Gui, Destroy
Gui, Margin, 10, 5
Gui, Add, Tab2,buttons left,  Past History|Addiction|Esophageal 
Gui, Tab, Past History
Gui, Add, CheckBox,vDiabetes, Diabetes 
Gui, Add, Edit, vDM w500
Gui, Add, ComboBox, vDur_DM, Diet|OHA|Insulin
Gui, Add, CheckBox,vHT,HT:
Gui, Add, Edit, vHT1 w500
Gui, Add, CheckBox,vIHD ,IHD
Gui, Add, Edit, vIHD1 w500
Gui, Add, CheckBox,vCVE,CVE
Gui, Add, Edit, vCVE1 w500

Gui, Add, CheckBox, vTB,TB
Gui, Add, Edit, vTB1 w500

Gui, Add, CheckBox, vAsthma,Asthma |COAD
Gui, Add, Edit, vAsthma1 w500
Gui, Add, CheckBox, vCirrhosis,Cirrhosis
Gui, Add, Edit, vCirrhosis1 w500

Gui, Add, CheckBox,vIUC,IUC 
Gui, Add, Edit, vIUC1 w500

Gui, Add, CheckBox,vIBS,IBS
Gui, Add, Edit, vIBS1 w500 

Gui, Add, CheckBox,vCarcinoma,Carcinoma
Gui, Add, Edit, vCarcinoma1 w500 

Gui, Add, CheckBox, vHypothyroid, Hypothyroid 
Gui, Add, Edit, vHypothyroid1 w500

Gui, Add, CheckBox, vAppendectomy, Appendectomy
Gui, Add, Edit, vAppendectomy1 w500

Gui, Add, CheckBox,vCholecystectomy, Cholecystectomy
Gui, Add, Edit, vCholecystectomy1 w500 

Gui, Add, CheckBox, vHysterectomy, Hysterectomy 
Gui, Add, Edit, vHysterectomy1 w500

Gui, Add, CheckBox, vPancreatitis,Acute pancreatitis 
Gui, Add, Edit, vPancreatitis1 w500
Gui, Add, Edit  , vOther w500, Other illness

;; Personal History goes here 

Gui, Tab, Addiction
Gui, Add, CheckBox, vAlcohol, Significant alcohol intake
Gui, Add, Edit, vAlcohol1 w500 
Gui, Add, CheckBox, vTobacco, Tobacco in any form
Gui, Add, Edit, vTobacco1 w500

;; Present history
Gui, TAB, Esophageal 
Gui, Add, CheckBox, vHR, Heartburn + Regurgitation 
Gui, Add, Edit, vvHR1 w500
Gui, Add, CheckBox, vH, Heartburn - Regurgitation 
Gui, Add, Edit, vH1 w500 
Gui, Add, CheckBox, vRH, Regurgitation - HR
Gui, Add, Edit, vRH1, w500
Gui, Add, CheckBox, vID, Intermittent dysphagia for solids and liquids 
Gui, Add, Edit, vID1 w500 
Gui, Add, CheckBox, vPrD, Progressive dysphagia 
Gui, Add, Edit, vPrD1 w500 
Gui, Add, CheckBox, CD, Current grade of dysphagia 
Gui, Add, Edit, vCD1 w500, 
Gui, Add, CheckBox, wW, Water to clear 
Gui, Add, CheckBox, vNR, nasal regurgitation at night 
Gui, Add, CheckBox, vNR1, nasal regurgitation after swallow 
Gui, Add, CheckBox, vOdynophagia, Odynophagia
Gui, Add, Edit, vOdynophagia1 w500 
Gui, Add, CheckBox , vHiccup, Hiccup 
Gui, Add, Edit, v Hiccup1 w500 

Gui, Add, CheckBox, vNausea, Nausea 
Gui, Add, Edit, vNausea1 w500

Gui, Add, CheckBox,vVomiting, Vomiting for 
Gui, Add, ComboBox, vVR w500, Related to FOOD|Related to HEADACHE| Related to abdominal PAIN| Related to VERTIGO|Related to menses| No relation with food, headache, vertigo, menses
Gui, Add, ComboBox, vVC w500, Vomitus contained food residue| Vomitus contained bilious fluid| Vomitus contained fecal matter | Vomitus contained fresh blood| Vomitus contained altered blood|Did not see vomitus


Gui, Add, Button, gEncounter w75 h35, OK
!^h:: Gui, Show,, Encounter
Encounter: 
Gui, Submit, hide
EncounterIndex:= {"Diabetes" : "Diabetes" .  DM , "HT": "Systemic hypertension" .  HT1, "IHD":"Ischemic heart disease" . IHD1, "CVE": "CVE" . CVE1, "TB":"Tuberculosis" . TB1, "Asthma": "Bronchial Asthma" . Asthma1,"IUC":"IUC" . IUC1, "IBS":"Irritable bowel syndrome" . IBS1, "Cirrhosis":"Cirrhosis of liver" . Cirrhosis1, "Carcinoma": "Carcinoma" .  Carcinoma1, "Hypothyroid": "Hypothyroid"  . Hypothyroid1, "Appendectomy": "Appendectomy" .  Appendectomy1, "Cholecystectomy": "Laparoscopic cholecystectomy" . Cholecystectomy1, "Hysterectomy":"Hysterectomy  for" . Hysterectomy1, "Pancreatitis":"Pancreatitis" . Pancreatitis1, "Other":"Other", "Alcohol": "Significant alcohol intake for" . Alcohl1, "Tobacco": "Consumption of tobacco (in any form) is present" . Tobacco1, "Gerd": vGerd1
,  "HR" :"Frequent episodes of heartburn and regurgitation of sour fluid for" .  HR1
, "H" : "Patient complained of episodes of frequent heartburn, but there is no history of regurgitation of sour fluid in the mouth" .  H1
, "RH" : "Frequent episodes of regurgitation of the sour fluid in the mouth, but no significant heartburn " . RH1
, "ID" : "Intermittent episodes of dysphagia for solids and liquids:" .  ID1 
, "PrD" : "Progressive dysphagia had started with solids"  .   PrD1
, "CD" :"Current grade of dysphagia:"   .                                CD1       
,  "W" : "Patient requires water to clear the food stuck in chest" 
, "NR" : "Patient regurgitates swallowed food and residue, when (s)he is lying down at night. "
, "NR1" : "Patient regurgitates food through nose and mouth immediately after the swallow." 
, "Odynophagia" : "Pain during swallowing of food :" .  Odynophagia1 
, "Hiccup" : "Patient is getting hiccups for"  .  Hiccup1
, "Nausea" : "Feels nauseated for" . VNausea1
, "Vomiting" : "Vomiting for " . VR . VC}


for Encounter, advice in EncounterIndex 
  if (%Encounter% =1) {
    SendInput, {Enter}- %advice%
    Reload
  }
Return



RussF
Posts: 1242
Joined: 05 Aug 2021, 06:36

Re: Erratic behaviour of script when combo box is used

Post by RussF » 16 Sep 2022, 06:19

In your For loop at the bottom, as soon as you find a match, you reload the script. That's why you can only get one result at a time and also why if you only check one box, it works. Move the Reload command outside of the loop.

Russ

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Erratic behaviour of script when combo box is used

Post by BoBo » 16 Sep 2022, 06:25

Code: Select all

for Encounter, advice in EncounterIndex 
  if (%Encounter% =1) {
    SendInput, {Enter}- %advice%
    Reload
  }
Return
This will reload the script once the first checked checkbox has been processed. So there's no further processing/validation for additional checked items. But I might be wrong :|

Code: Select all

;easier to read/edit
EncounterIndex:= {"Diabetes" : "Diabetes" .  DM 
                  , "HT": "Systemic hypertension" .  HT1
                  , "IHD":"Ischemic heart disease" . IHD1
                  , "CVE": "CVE" . CVE1, "TB":"Tuberculosis" . TB1
                  , "Asthma": "Bronchial Asthma" . Asthma1
                  ,"IUC":"IUC" . IUC1
                  , "IBS":"Irritable bowel syndrome" . IBS1
                  , "Cirrhosis":"Cirrhosis of liver" . Cirrhosis1
                  , "Carcinoma": "Carcinoma" .  Carcinoma1
                  , "Hypothyroid": "Hypothyroid"  . Hypothyroid1
                  , "Appendectomy": "Appendectomy" .  Appendectomy1
                  , "Cholecystectomy": "Laparoscopic cholecystectomy" . Cholecystectomy1
                  , "Hysterectomy":"Hysterectomy  for" . Hysterectomy1
                  , "Pancreatitis":"Pancreatitis" . Pancreatitis1
                  , "Other":"Other"
                  , "Alcohol": "Significant alcohol intake for" . Alcohl1
                  , "Tobacco": "Consumption of tobacco (in any form) is present" . Tobacco1
                  , "Gerd": vGerd1
                  ,  "HR" :"Frequent episodes of heartburn and regurgitation of sour fluid for" .  HR1
                  , "H" : "Patient complained of episodes of frequent heartburn, but there is no history of regurgitation of sour fluid in the mouth" .  H1
                  , "RH" : "Frequent episodes of regurgitation of the sour fluid in the mouth, but no significant heartburn " . RH1
                  , "ID" : "Intermittent episodes of dysphagia for solids and liquids:" .  ID1 
                  , "PrD" : "Progressive dysphagia had started with solids"  .   PrD1
                  , "CD" :"Current grade of dysphagia:"   .                                CD1       
                  ,  "W" : "Patient requires water to clear the food stuck in chest" 
                  , "NR" : "Patient regurgitates swallowed food and residue, when (s)he is lying down at night. "
                  , "NR1" : "Patient regurgitates food through nose and mouth immediately after the swallow." 
                  , "Odynophagia" : "Pain during swallowing of food :" .  Odynophagia1 
                  , "Hiccup" : "Patient is getting hiccups for"  .  Hiccup1
                  , "Nausea" : "Feels nauseated for" . VNausea1
                  , "Vomiting" : "Vomiting for " . VR . VC}

vbanait
Posts: 50
Joined: 09 Jul 2016, 05:51

Re: Erratic behaviour of script when combo box is used

Post by vbanait » 01 Oct 2022, 06:20

Thanks

Post Reply

Return to “Ask for Help (v1)”