• Intro to AutoHotkey Intermediate AutoHotkey Intermediate Objects GUIs are Easy w/AutoHotkey Painlessly switch from V1 to V2

AutoHotkey Webinar- Finding presence of text in a large file

AutoHotkey webinarIn this working-session webinar we helped Dimitri with a project he was working on.  In short, he is looking for specific text in a “large” text file.  We discussed various approaches to the solution and created a few example solutions

Script Highlight:  Control panel objects by jNizM

Several things to consider before writing a solution

1.Just how large is/will the text file get?

A.Is the file going to be appended to over time?

2.Do you just need to answer “is the text value in the file” or do you need more information

A.how many occurrences

B.which lines it is on

C.other values related to it (key-value pairs, other fields, etc.)

3.Do you care if the text is found multiple times?

4.How important is speed

5.Would a “fuzzy search” help?

6.Will you be running single or multiple searches?

Possible Approaches for finding text in a large text file

  • Use InString on file read (see below example)
  • Shove it into an Object  (see below example)
  • Use built-in ADO database query by VXE
  • Use SQLite3

Simple InStr solution

Loop,Read, B:\the-automator\Webinar\Scripts\2020-01-Working Session\Dimitri\glbintf3.dat ;loop over data file (line by line)
  if InStr(A_LoopReadLine,"ENP-001213") ;If there is a : in the row, then proceed
    m(A_LoopReadLine,A_Index)

Shoving into an Object

  obj:={} ;Create object for storing data
  Loop,Read, B:\the-automator\Webinar\Scripts\2020-01-Working Session\Dimitri\glbintf3.dat ;loop over data file (line by line)
  {
    if InStr(A_LoopReadLine,":"){ ;If there is a : in the row, then proceed
      RegExMatch(A_LoopReadLine,"(\d+:)(\s+)?(?<Str>\S+.*)",arr_) ;Grab everything to the right of the : and push into Arr_Str
      obj[arr_Str]:=1
    }
  }
;********************Show all in object***********************************
  for k,v in obj
    output.=k "`n"
  MsgBox  %output% 
  
;********************Loop and find your value***********************************
  for k,v in obj{
    if(InStr(k,"ENP-003066"))
      m(k)
  }

 

 

Moving data from one column to many; Parsing a variable using an SPSS macro

one column to many

Older online vendor tools and databases would frequently put multi-select questions into one column having a pipe,tab,semicolon or comma delimiter (what was real fun is when they would use a comma for a delimiter in a CSV file).

This can be very problematic in nearly any tool. In this video I demonstrate how easy it can be to move data from one column to many with an SPSS macro.

Move one column to many

https://www.youtube.com/watch?v=ldoPLOFyVAI

Here is the SPSS macro demonstrated in the video:

 
*///////////////.
DEFINE !Parse (Var !TOKENS (1)  / Stem !TOKENS (1) /Del !TOKENS (1))
STRING #(A1000).
VECTOR !Stem(25A500).
COMPUTE #=CONCAT(RTRIM(!Var),!Del).
COMPUTE #cnt=1.
LOOP IF INDEX(#,!Del)>0.
COMPUTE !Stem(#cnt)=SUBSTR(#,1,INDEX(#,!Del)-1).
COMPUTE #cnt=#cnt + 1.
COMPUTE #=SUBSTR(#,INDEX(#,!Del)+1).
Var width !Concat(!Stem,1) to !Concat(!Stem,25) (10).
END LOOP.
EXECUTE.
!ENDDEFINE.
*///////////////.
/* !Parse Var=NAIC_All Stem=NAIC  Del=";".

 

SPSS Macros for replacing missing data

SPSS macro

SPSS Macros for replacing missing data

A lot of online vendor tools provide a data value on a multi-select question however they leave the value missing if the respondent didn’t select it. Most of the analysis I want to do needs to have a zero (or some other value) present in order to calculate the statistics correctly.

I wrote a few SPSS Macros that make it very easy to replace the missing values on your data.  Here are the two macros

 
*///////////////.
DEFINE !Rep_Miss  (Beg !TOKENS (1) /Prez !TOKENS (1)  /End !TOKENS (1))
Do if !PREZ>0.
do repeat v=!BEG to !END.
if missing (v) v=0.
end repeat.
end if.
exe.
!ENDDEFINE.
*///////////////.

/*!Rep_Miss  Prez=presentvariable  Beg=v11  End=v19.

*///////////////.
DEFINE !Rep_Miss2  (Beg !TOKENS (1)   /End !TOKENS (1))
do repeat v=!BEG to !END.
if missing (v) v=0.
end repeat.
exe.
!ENDDEFINE.
*///////////////.
/*!Rep_Miss2   Beg=v11  End=v19.

 

https://www.youtube.com/watch?v=5CBm_F3zBOo

Windows autocorrect- Auto-replace text in any Windows program with a Hotstring from AutoHotKey


HotStrings / Text Expansion

windows autocorrect

Windows Autocorrect– Auto-replace an abbreviation with full text in any windows program

Years ago I realized I was frequently typing the same thing over and over. For a while I used autocorrect in Microsoft Word which was helpful but had limitations (one huge one is that it only worked in Word). AutoHotKey is a free scripting program that allows you to do an amazing amount of things; one of which is how to use Hotstrings to autocorrect text in any windows program via Hotstrings.

If you want to learn more about HotStrings, check out our Udemy course on HotStrings here

I have hundreds of Hotstrings which allow me to type a few letters and have them, automatically, replaced with the full word, sentence, paragraph, etc.   Below is a simple example where I want to type my main website domain.  Instead of typing the entire thing out I just type tac. which is quickly replaced with  http://the-automator.com

The second example is one where I want to have line-breaks inserted (This is my template when starting a new AutoHotKey script.)  I simply type tst.  and the following “magically” appears in its place via windows autocorrect.

The below video outlines how I use hotstrings to reduce the amount of mundane work that I have to do.  It is amazing how much time you can save once you get used to using them!  Remember your Hotstrings (windows autocorrect) will work in any Windows program!  Did I mention it was free?  What more could you ask for?AutoHotkey Merchandise-White Stress ball

Windows autocorrect is just one of many amazing things you can do with AutoHotKey however hotstrings is a great, easy, way to start down the path of automation and efficiency!