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

Using AutoHotkey Text Functions in Excel

In this example I demonstrate how to use AutoHotkey string / text functions on text that is in Excel.

 

XL:=XL_Handle(1) ; 1=pointer to Application   2= Pointer to Workbook
MsgBox % XL.range("A1").Text

MsgBox % SubStr(XL.range("A1").Text,6)
MsgBox % InStr(XL.range("A1").Text,"and")
MsgBox % StrSplit(XL.range("A1").Text," ").3
RegExMatch(XL.range("A1").Text,".*?(\d+)",Numb)
MsgBox % Numb1

XL.range("A1").Value:="This didn't work"



;********************Connect to current Excel Worksheet***********************************
XL_Handle(Sel){
  ControlGet, hwnd, hwnd, , Excel71, ahk_class XLMAIN ;identify the hwnd for Excel
  Obj:=ObjectFromWindow(hwnd,-16)
  return (Sel=1?Obj.Application:Sel=2?Obj.Parent:Sel=3?Obj.ActiveSheet:"")
}
;***borrowd & tweaked from Acc.ahk Standard Library*** by Sean  Updated by jethrow*****************
ObjectFromWindow(hWnd, idObject = -4){
  if(h:=DllCall("LoadLibrary","Str","oleacc","Ptr"))
    If DllCall("oleacc\AccessibleObjectFromWindow","Ptr",hWnd,"UInt",idObject&=0xFFFFFFFF,"Ptr",-VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0
      Return ComObjEnwrap(9,pacc,1)
}

 

How to use Simple Text Encrypting to prevent keeping your passwords stored in plain text files – Keep hackers away in 2021!

Simple Text EncryptingIn one of my videos on what I’ve automated lately, I demonstrated the little tool I wrote to encode / decode text (typically passwords). Someone asked if I could share the code so I’m doing that here. In case you missed the video, I created a shorter one just on this topic below.

Text Encrypting Code

How to use Simple Text Encrypting

 

 

Merging Files with similar structure but removing duplicate headers

I often get text files of similar type (Tab delimited, CSV, etc.) but they all have a header row.  A super easy way to merge the data together is to

  1. Created a folder that only has the files you want to merge
  2. create a command prompt in the directory
  3. use the following dos command to merge the files (adjusting the extension to your purpose:  copy *.csv  merged.csv

This will merge all of the files ending in .csv into the merged.csv file however it keeps all the header rows. 🙁   This annoyed me so I wrote a short program to use AutoHotkey and only keep the first header row.

Continue reading