Open multiple files in MS Word and change font type in word

Working with MS Word is excellent when you have AutoHotkey & COM!

Someone on the Facebook AutoHotkey group gave the following requirements

  1. Open file one
  2. open document Word
  3. CTRL+A
  4. change font to Calibri
  5. save file in another file

Here is the code wrote to open multiple files in MS Word and change the font type of all text.  COM Rocks!

Here’s a walk-through video open multiple files in MS Word

Using AutoHotkey Text Functions in Excel

Microsoft Excel logo with a green spreadsheet icon and the word Excel in white on a green backgroundIn 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)
}

 

Rip the URL from the Clipboard with AutoHotkey

Someone asked me if I had a tool that would look at the clipboard and return only the URL or Rip the  URL from the Clipboard. (The clipboard has various formats like: Files, Text, Rich Text Format, HTML, Images, etc.).

I used the cool WinClip library which can be grabbed here: https://autohotkey.com/board/topic/74670-class-winclip-direct-clipboard-manipulations/ and, with the help of maestrith, wrote a script which returns the various items on the clipboard in HTML format as an object.

Rip the URL from the Clipboard

 
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance,Force
SetBatchLines,-1
global Com:=ComObjCreate(“HTMLFile”)
;*******************************************************
Browser_Back:: ;Change this hotkey to what you want
CB:=ClipboardAll
Clipboard:=””
while(Clipboard){
Sleep,10
}
Send,^c
while(!Clipboard){
Sleep,10
}
Clip:=Get_Clipboard_Data() ;Call the function and return the HTML data in an object
MsgBox % clip.1.HREF
DebugWindow(Obj2String(Clip),1,1,200,0)
Clipboard:=CB ;restore Clipboard
return

;********************Grab data from Clipboard***********************************
Get_Clipboard_Data(){
wc := new WinClip
wc.iSnap()
Obj:=[]
try:=wc.iGetHTML()
HTML:=SubStr(Try,InStr(Try,”<HTML>”))
Com.Close()
Com.Write(HTML)
All:=Com.GetElementsByTagName(“a”)
Url:=[]
RegExMatch(Try,”OUi)SourceURL:(.*)\R”,Found)
while(aa:=All.Item[A_Index-1]){
URL.Push({Page:Found.1,Text:aa.InnerText,HREF:aa.HREF})
}
return URL
}
;~ https://autohotkey.com/board/topic/74670-class-winclip-direct-clipboard-manipulations/
#Include B:\Progs\AutoHotkey_L\AHK Work\WinClip\WinClipAPI.ahk
#Include B:\Progs\AutoHotkey_L\AHK Work\WinClip\WinClip.ahk