Open Side Menu Go to the Top
Register
I need AHK help my friends I need AHK help my friends

08-19-2016 , 12:23 PM
Several years ago, someone on 2+2 wrote a short AHK program for me that works with my wife's EMR (electronic medical records). Essentially expands a very small text input box to full screen to allow easier viewing as she enters patient data......then saves and closes the full screen window.

The original program was written for a specific text box...but I could always add different boxes by adding to the Control command at the top of the script.

ControlName=ThunderRT6TextBox1,ThunderRT6TextBox2, ThunderRT6TextBox3,ThunderRT6TextBox4,,,,,etc

Fast forward to a new job (same software) that requires the use of a different set of text boxes. When I Spy,,, I find the following Class for ALL of the new boxes my wife would like to expand.

Class NN ahk_classInternetexplorer_server3

I searched AHK site and found several posts about this...but to be honest, it is all way over my head.

Any idea how I can find the hook (handle?).....and would I be able to simply add to the ControlName line in the script ?

Thank you
KS
I need AHK help my friends Quote
08-20-2016 , 04:04 PM
Code:
;Oct 2010
;F9 is the launcher


ControlName=ThunderRT6TextBox1,ThunderRT6TextBox2,ThunderRT6TextBox3,ThunderRT6TextBox4


font := "Ariel"
style := "s16 bold italic"
color:=0xFF


SetBatchLines, -1
Gui, +AlwaysOnTop +ToolWindow
Gui, Add, Edit, % "x0 y0 w" A_ScreenWidth " h" A_ScreenHeight-100 " vData"
Gui, Add, Button, % "x0 y" A_ScreenHeight-90 " w" A_ScreenWidth/2 " h18 gSav",Save
Gui, Add, Button, % "x+0 y" A_ScreenHeight-90 " w" A_ScreenWidth/2 " h18 gCan",Cancel

return

;can I simply add this next line? Or will interfer with the ThunderRT6FormDC line that has worked for the other text boxes?
;#IfWinActive, ahk_class Internetexplorer_server3

#IfWinActive, ahk_class ThunderRT6FormDC 
F9::


ControlGetFocus, Control, A
If Control in %ControlName%
 {
   WinGet, WID, ID, A
   ControlGetText, Data, %Control%, ahk_id %WID%
   GuiControl, , Data, %Data%
   Gui, Show, % "x0 y0 w" A_ScreenWidth " h" A_ScreenHeight-70, Edit- F2 To Auto Increase Font Size --- F3 To Bring Up Standard Font Edit Window

}
Return
#IfWinActive

Sav:
GuiControlGet, Data, , Data
StringReplace, Data, Data, `n, `r`n, All
ControlSetText, %Control%, %Data%, ahk_id %WID%
GuiControl, , Data
Gui, Cancel
Return

Can:
GuiClose:
GuiControl, , Data
Gui, Cancel
Return

f3::
gui -alwaysontop
Dlg_Font( font := "Ariel", style := "s16 bold", color:=0xFF)
gui +alwaysontop
return

#ifwinactive Edit
f2::
Gui, Font, %style% c%color% Bold, %font% 
GuiControl, Font, edit1
return
#IfWinActive


; the following code thanks to Majkinetor common dialog functions http://www.autohotkey.com/forum/topic17230.html


Dlg_Font(ByRef Name, ByRef Style, ByRef Color, Effects=true, hGui=0) {

   LogPixels := DllCall("GetDeviceCaps", "uint", DllCall("GetDC", "uint", hGui), "uint", 90)   ;LOGPIXELSY
   VarSetCapacity(LOGFONT, 128, 0)

   Effects := 0x041 + (Effects ? 0x100 : 0)  ;CF_EFFECTS = 0x100, CF_SCREENFONTS=1, CF_INITTOLOGFONTSTRUCT = 0x40

   ;set initial name
   DllCall("RtlMoveMemory", "uint", &LOGFONT+28, "Uint", &Name, "Uint", 32)

   ;convert from rgb 
   clr := ((Color & 0xFF) << 16) + (Color & 0xFF00) + ((Color >> 16) & 0xFF)

   ;set intial data
   if InStr(Style, "bold")
      NumPut(700, LOGFONT, 16)

   if InStr(Style, "italic")
      NumPut(255, LOGFONT, 20, 1)

   if InStr(Style, "underline")
      NumPut(1, LOGFONT, 21, 1)
   
   if InStr(Style, "strikeout")
      NumPut(1, LOGFONT, 22, 1)

   if RegExMatch(Style, "s[1-9][0-9]*", s){
      StringTrimLeft, s, s, 1     
      s := -DllCall("MulDiv", "int", s, "int", LogPixels, "int", 72)
      NumPut(s, LOGFONT, 0, "Int")         ; set size
   }
   else  NumPut(16, LOGFONT, 0)         ; set default size

   VarSetCapacity(CHOOSEFONT, 60, 0)
    ,NumPut(60,       CHOOSEFONT, 0)      ; DWORD lStructSize
    ,NumPut(hGui,    CHOOSEFONT, 4)      ; HWND hwndOwner (makes dialog "modal").
    ,NumPut(&LOGFONT,CHOOSEFONT, 12)   ; LPLOGFONT lpLogFont
    ,NumPut(Effects, CHOOSEFONT, 20)   
    ,NumPut(clr,    CHOOSEFONT, 24)   ; rgbColors

   r := DllCall("comdlg32\ChooseFontA", "uint", &CHOOSEFONT)  ; Display the dialog.
   if !r
      return false

  ;font name
   VarSetCapacity(Name, 32)
   DllCall("RtlMoveMemory", "str", Name, "Uint", &LOGFONT + 28, "Uint", 32)
   Style := "s" NumGet(CHOOSEFONT, 16) // 10

  ;color
   old := A_FormatInteger
   SetFormat, integer, hex                      ; Show RGB color extracted below in hex format.
   Color := NumGet(CHOOSEFONT, 24)
   SetFormat, integer, %old%

  ;styles
   Style =
   VarSetCapacity(s, 3)
   DllCall("RtlMoveMemory", "str", s, "Uint", &LOGFONT + 20, "Uint", 3)

   if NumGet(LOGFONT, 16) >= 700
     Style .= "bold "

   if NumGet(LOGFONT, 20, "UChar")
      Style .= "italic "
   
   if NumGet(LOGFONT, 21, "UChar")
      Style .= "underline "

   if NumGet(LOGFONT, 22, "UChar")
      Style .= "strikeout "

   s := NumGet(LOGFONT, 0, "Int")
   Style .= "s" Abs(DllCall("MulDiv", "int", abs(s), "int", 72, "int", LogPixels))

 ;convert to rgb
   oldFormat := A_FormatInteger
    SetFormat, integer, hex  ; Show RGB color extracted below in hex format.

    Color := (Color & 0xff00) + ((Color & 0xff0000) >> 16) + ((Color & 0xff) << 16)
    StringTrimLeft, Color, Color, 2
    loop, % 6-strlen(Color)
      Color=0%Color%
    Color=0x%Color%
    SetFormat, integer, %oldFormat%

   return 1
}



;=========================================== PRIVATE ===============================================

Dlg_callback(wparam, lparam, msg, hwnd) {
   static FR_DIALOGTERM = 0x40, FR_DOWN=1, FR_MATCHCASE=4, FR_WHOLEWORD=2, FR_HIDEMATCHCASE=0x8000, FR_HIDEWHOLEWORD=0x10000, FR_HIDEUPDOWN=0x4000, FR_REPLACE=0x10, FR_REPLACEALL=0x20, FR_FINDNEXT=8
   static handler
   ifEqual, hwnd, ,return handler := wparam
   
   hFlags := NumGet(lparam+12)
   if (hFlags & FR_DIALOGTERM)
      return %handler%("C", "", "", "")

    flags .= (hFlags & FR_MATCHCASE) && !(hFlags & FR_HIDEMATCHCASE)? "c" :
   flags .= (hFlags & FR_WHOLEWORD) && !(hFlags & FR_HIDEWHOLEWORD)? "w" :
   findText := DllCall("MulDiv", "Int", NumGet(lparam+16), "Int",1, "Int",1, "str")

   if (hFlags & FR_FINDNEXT) {
      flags .= (hFlags & FR_DOWN) && !(hFlags & FR_HIDEUPDOWN) ? "d" :
      return %handler%("F", flags, findText, "")
   }

   if (hFlags & FR_REPLACE) || (hFlags & FR_REPLACEALL) {
      event := (hFlags & FR_REPLACEALL) ? "A" : "R"
      replaceText := DllCall("MulDiv", "Int", NumGet(lparam+20), "Int",1, "Int",1, "str")
      return %handler%(event, flags, findText, replaceText)
   }
}
I need AHK help my friends Quote
08-21-2016 , 10:34 PM
You really should spend more time going into details (include everything you can, including program names, pictures, and entire results from the spy utility) before asking for help like this.

Code:
#IfWinActive, ahk_class ThunderRT6FormDC
this line is saying "if the active window is of class 'ThunderRT6FormDC' - execute the lines of code below (until the return statement)".
ahk_class (or window class) is just a textual identifier for what 'type' of window it is. some programs have custom names for their window class and some use generic class names. all that matters to you is that you can use the class to narrow down the scope of windows to windows of [class name] type.

from your last post it seems that your wife is no longer working with the 'ThunderRT6FormDC' window class but instead window class 'Internetexplorer_server3', so that line would need to be changed.

Doing a quick search you can find that...
So you may not be able to just swap out the class name and have it work.
It might be easy enough for someone like me to get you the same functionality back, but I don't know what you're working with (which program, which window inside of said program, etc) so not much I can do without spending more time than I'd like on it.
I need AHK help my friends Quote
08-21-2016 , 11:13 PM
take a video of yourself mousing over the different areas with the window spy visible in the video
I need AHK help my friends Quote
08-22-2016 , 02:39 AM
Thanks for the feedback. I will try to get more information over the next few days. (I have to work around her evening work schedule)

ThunderRT6FormDC is still the Window Class

ahk_class Internetexplorer_server3 is the "new" Control ClassNN. Previously, I have only added the different ThunderRTtextbox# from the ClassNN box
I need AHK help my friends Quote
08-23-2016 , 03:57 AM
You're gonna have a hard time

It sounds to me like the new workplace is using a newer (or older!) version of the software written in a different manner.

I suspect it is almost certainly possible however.

An internetexplorer_server is as you might guess, an instance of the html browser engine of the same name. AHK can access it, but it isn't nearly so straightforward as accessing normal controls that AHK can controlgettext / controlsettext with a single command.

The controls in this version I expect are HTML form elements.

What you can do is get access to the internetexplorer_server with AHK, and inject then execute JavaScript on the browser's DOM. This allows you to return the whole HTML of a page, or set the focus to a particular element, or anything in between - but it's a different (yet similar) language.

You can see examples of this in my old BetPot AHK code for iPoker - their dealer chat is an internetexplorer_server to which I send some JavaScript to get all the text and then process it back in AHK-land for calculating bets.

Last edited by _dave_; 08-23-2016 at 04:08 AM.
I need AHK help my friends Quote
08-26-2016 , 07:42 PM
Thanks _dave_.

As I suspected, the fix will be past my programming abilities. But if I can get the hospital IT department interested (NOT friggin' likely!) or the balance of the physicians to revolt!...at least I have a direction to lead them. I also may be able to get the users (docs, nurses etc) to rethink how they use the current boxes and steer them toward using the text boxes that my wife (and prior group) used successfully.

Until then, the script above works fine for all the textboxes that are indeed, textboxes. Grrrrrrr.
I need AHK help my friends Quote

      
m