anonymous1184

userInfo.ahk

Feb 5th, 2021 (edited)
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SetBatchLines, -1
  2.  
  3. global filesPath := "D:\Downloads"
  4.     , clients := []
  5.     , clientID := ""
  6.     , clientActive := ""
  7.     , clientNames := ""
  8.     , doctors := []
  9.     , doctorID := ""
  10.     , doctorActive := ""
  11.     , witnesses := []
  12.     , witnessID := ""
  13.     , witnessActive := ""
  14.  
  15. loop, read, % filesPath "\clients.csv"
  16. {
  17.     if (A_Index = 1)
  18.     {
  19.         continue
  20.     }
  21.     loop, parse, A_LoopReadLine, CSV
  22.     {
  23.         if (A_Index = 1)
  24.         {
  25.             doctors[A_LoopField] := []
  26.             , witnesses[A_LoopField] := []
  27.             , last := clients[A_LoopField] := []
  28.         }
  29.         else
  30.         {
  31.             if (A_Index = 2)
  32.             {
  33.                 clientNames .= A_LoopField "|"
  34.             }
  35.             last.Push(A_LoopField)
  36.         }
  37.     }
  38. }
  39.  
  40. slave("doctors.csv", doctors)
  41. slave("witnesses.csv", witnesses)
  42.  
  43. ^!c::chooseClient()
  44.  
  45. ^1::info(clientActive, 1) ; Client
  46. ^2::info(clientActive, 2) ; Phone
  47. ^3::info(clientActive, 3) ; Address
  48. ^4::info(clientActive, 4) ; Case
  49.  
  50. ^+1::info(doctorActive, 1) ; Doctor
  51. ^+2::info(doctorActive, 2) ; Phone
  52. ^+3::info(doctorActive, 3) ; Address
  53.  
  54. +!1::info(witnessActive, 1) ; Witness
  55. +!2::info(witnessActive, 2) ; Phone
  56. +!3::info(witnessActive, 3) ; Address
  57.  
  58. ButtonOK:
  59.    Gui, Submit
  60.     clientActive := clients[clientID]
  61.     doctorActive := doctors[clientID][doctorID]
  62.     witnessActive := witnesses[clientID][witnessID]
  63. GuiEscape:
  64.     Gui, Destroy
  65. return
  66.  
  67. chooseClient()
  68. {
  69.     Gui, New, -Caption
  70.     Gui, Add, Text,, Client
  71.     Gui, Add, ComboBox, AltSubmit GclientSelected VclientID, % clientNames
  72.     Gui, Add, Text,, Doctor
  73.     Gui, Add, ComboBox, AltSubmit VdoctorID
  74.     Gui, Add, Text,, Witness
  75.     Gui, Add, ComboBox, AltSubmit VwitnessID
  76.     Gui, Add, Button, Default, OK
  77.     Gui, Show
  78.     ; Send, !{Down}
  79. }
  80.  
  81. clientSelected()
  82. {
  83.     Gui, Submit, NoHide
  84.     doctorNames := ""
  85.     for k,doc in doctors[clientID]
  86.     {
  87.         doctorNames .= "|" doc[1]
  88.     }
  89.     GuiControl,, doctorID, % doctorNames
  90.     witnessNames := ""
  91.     for k,witness in witnesses[clientID]
  92.     {
  93.         witnessNames .= "|" witness[1]
  94.     }
  95.     GuiControl,, witnessID, % witnessNames
  96. }
  97.  
  98. info(from, field)
  99. {
  100.     if (!clientActive || !doctorActive || !witnessActive)
  101.     {
  102.         return chooseClient()
  103.     }
  104.     SendInput, % from[field]
  105. }
  106.  
  107. slave(file, ByRef slave)
  108. {
  109.     loop, read, % filesPath "\" file
  110.     {
  111.         if (A_Index = 1)
  112.         {
  113.             continue
  114.         }
  115.         loop, parse, A_LoopReadLine, CSV
  116.         {
  117.             if (A_Index = 1)
  118.             {
  119.                 last := []
  120.                 , clientID := A_LoopField
  121.             }
  122.             else
  123.             {
  124.                 last.Push(A_LoopField)
  125.             }
  126.         }
  127.         slave[clientID].Push(last)
  128.     }
  129.     return slave
  130. }
  131.  
Add Comment
Please, Sign In to add comment