xmlHTTPRequest vs. WinHTTPRequest- What killer advantages does the xmlRequest have?

xmlHTTPRequest vs. WinHTTPRequestIn this video I walk through both the xmlHTTPRequest and the WinHTTPRequest and I compare the xmlHTTPRequest vs. WinHTTPRequest.  As I mention in the video, Jackie Sztuk and I have a great  AutoHotkey webinar on Intro to API calls.  I also have several examples on my API page.

I also mention using Fiddler to monitor the browser traffic and grab your cookies / headers.

xmlHTTPRequest vs. WinHTTPRequest tutorial


Here’s the syntax I used for the WinHTTPRequest example

WinHTTPRequest syntax

And here’s the corresponding two XML API calls I demonstrated in the video

xmlHTTPRequest example using Msxml2.XMLHTTP COM object

Here’s the example connecting to the IE page and sending the API request with the xmlHTTPRequest()

AutoHotkey Webinar- Using AHK string functions in Excel

AHK In this webinar we walked through using AutoHotkey String functions in Excel.

Script Highlight:  Pull data about your computer with WMI by shajul.  Forum post and my link to the zipped files of the separate scripts I wrote

Video Hour 1 & 2 : AHK string functions in Excel

Books on RPA (Robotics Process Automation) that I mentioned in the webinar

Below are links to books I showed during the webinar. I put them into two groups (those I like/recommend and those I don’t). I’m more of a “glass is half-full” kind of guy and think technology is good. The books I don’t recommend were much more negative towards technology. While I don’t recommend them, I think time will tell who is right/wrong.  Personally any of the following you buy I’d try and buy as used.  Many are pretty expensive new (probably because of the small market size)

Recommended Robotics Process Automation books

Service Automation: Robots and the Future of Work 2016 -Great book!
Robotic Process Automation and Risk Mitigation: The Definitive Guide 2017
Robotic Process and Cognitive Automation: The Next Phase 2018 -Great book!
The Singularity Is Near: When Humans Transcend Biology 2019 – very interesting
Life After Google: The Fall of Big Data and the Rise of the Blockchain Economy 2018 – some wild ideas here
The Human Advantage: The Future of American Work in an Age of Smart Machines 2018
The Glass Cage: How Our Computers Are Changing Us 2015
Managing IT as a Strategic Resource 1997
Beyond the IT Productivity Paradox 1999 – old but still interesting

Not recommended but still on the RPA topic

In The Age Of The Smart Machine: The Future Of Work And Power 1989
The Lights in the Tunnel: Automation, Accelerating Technology and the Economy of the Future 2009
A Dangerous Master: How to Keep Technology from Slipping Beyond Our Control 2015
Rise of the Robots: Technology and the Threat of a Jobless Future 2016

 

We also mentioned using ternary operators

and Alternate Data Stream as data storage

Here’s the code Jackie walked through.

#SingleInstance,Force
username := "Jackie"

msgbox % "Name: " username "`nPassword: " password()
return
password(){
  FilePath := A_ScriptFullPath
  IniRead, Var, %FilePath%:Stream:$DATA, Settings, Pass, error
  If (Var="error"){
    InputBox, Var , New, Please enter password, HIDE
    IniWrite, %Var%, %FilePath%:Stream:$DATA, Settings, Pass
  }
  return Var
}

 

Insert / Delete columns in Excel via AutoHotkey

Columns in Excel via AutoHotkeyThis post continues to build on using AutoHotkey via COM to manipulate Excel.  This time I demonstrate how easy it is to use an AutoHotkey function to insert columns, delete columns and set column widths.  All of which are utilizing a simple function after connecting to Excel via AutoHotkey and COM.

Here’s the video demonstrating how to manipulate columns in Excel via AutoHotkey.

AutoHotkey Merchandise-White Stress ballHere is the code where I demonstrate in the above video how to manipulate columns in Excel via AutoHotkey.  Make sure you connect to the Excel object before calling the functions!

 
#SingleInstance,Force
RAlt::Reload
RControl::
XL_Handle(XL,1) ;get handle to Application

XL_Col_Width_Set(XL,RG:="A:B=-1|D:F=-1|H=15|K=3") ;-1 is auto
XL_Col_Insert(XL,RG:="B:C",WD:=8)   ;insert column(s) and set width
XL_Col_Delete(XL,RG:="A|D:F|Z|BB:BC") ;Delete columns
return
;***********column width*******************
XL_Col_Width_Set(PXL,RG=""){
 for k, v in StrSplit(rg,"|") ;Iterate over array
    (StrSplit(v,"=").2="-1")?(PXL.Application.ActiveSheet.Columns(StrSplit(v,"=").1).AutoFit):(PXL.Application.ActiveSheet.Columns(StrSplit(v,"=").1).ColumnWidth:=StrSplit(v,"=").2)
}

;***********************Column Insert********************************.
XL_Col_Insert(PXL,RG="",WD:="5"){ ;Default width is 5
PXL.Application.ActiveSheet.Columns(RG).Insert(-4161).Select
PXL.Application.ActiveSheet.Columns(RG).ColumnWidth:=WD
}

;***********************Column Delete********************************.
XL_Col_Delete(PXL,RG=""){
    for j,k in StrSplit(rg,"|")
	 (instr(k,":")=1)?list.=k ",":(list.=k ":" k ",") ;need to make for two if only 1 col
PXL.Application.ActiveSheet.Range(SubStr(list,1,(StrLen(list)-1))).Delete ;use list but remove final comma
}

;  Function for connecting to Excel
XL_Handle(ByRef PXL,Sel){
ControlGet, hwnd, hwnd, , Excel71, ahk_class XLMAIN ;identify the hwnd for Excel
IfEqual,Sel,1, Return, PXL:= ObjectFromWindow(hwnd,-16).application ;Handle to Excel Application
IfEqual,Sel,2, Return, PXL:= ObjectFromWindow(hwnd,-16).parent ;Handlle to active Workbook
IfEqual,Sel,3, Return, PXL:= ObjectFromWindow(hwnd,-16).activesheet ;Handle to Active Worksheet
}
;***********adapted from ACC.ahk*******************
ObjectFromWindow(hWnd, idObject = -4){
(if Not h)?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)
}

Setting Horizontal and Vertical Excel cell alignment with AutoHotkey

Excel cell alignment with AutoHotkey

Excel cell alignment with AutoHotkey

I love how easy it is to use AutoHotkey to set Excel formatting.   The below AutoHotkey syntax and video show how easy it is to set both vertical and horizontal alignment within Excel.  It also introduces the concepts of Excel Constants.

 
; Excel cell alignment with AutoHotkey
XL_Handle(XL,1) ;get handle to Application
;~ XL_Format_HAlign(XL,RG:="A1:C1",h:=1) ;1=Left 2=Center 3=Right
XL_Format_VAlign(XL,RG:="A1:C1") ;1=Top 2=Center 3=Distrib 4=Bottom

XL_Format_HAlign(PXL,RG="",h="1"){ ;defaults are Right bottom
IfEqual,h,1,Return,PXL.Application.ActiveSheet.Range(RG).HorizontalAlignment:=-4131 ;Left
IfEqual,h,2,Return,PXL.Application.ActiveSheet.Range(RG).HorizontalAlignment:=-4108 ;Center
IfEqual,h,3,Return,PXL.Application.ActiveSheet.Range(RG).HorizontalAlignment:=-4152 ;Right
}
; Excel cell alignment with AutoHotkey
XL_Format_VAlign(PXL,RG="",v="1"){
IfEqual,v,1,Return,PXL.Application.ActiveSheet.Range(RG).VerticalAlignment:=-4160 ;Top
IfEqual,v,2,Return,PXL.Application.ActiveSheet.Range(RG).VerticalAlignment:=-4108 ;Center
IfEqual,v,3,Return,PXL.Application.ActiveSheet.Range(RG).VerticalAlignment:=-4117 ;Distributed
IfEqual,v,4,Return,PXL.Application.ActiveSheet.Range(RG).VerticalAlignment:=-4107 ;Bottom
}

;  Function for connecting to Excel
XL_Handle(ByRef PXL,Sel){
ControlGet, hwnd, hwnd, , Excel71, ahk_class XLMAIN ;identify the hwnd for Excel
IfEqual,Sel,1, Return, PXL:= ObjectFromWindow(hwnd,-16).application ;Handle to Excel Application
IfEqual,Sel,2, Return, PXL:= ObjectFromWindow(hwnd,-16).parent ;Handlle to active Workbook
IfEqual,Sel,3, Return, PXL:= ObjectFromWindow(hwnd,-16).activesheet ;Handle to Active Worksheet
}
;***********adapted from ACC.ahk*******************
ObjectFromWindow(hWnd, idObject = -4){
(if Not h)?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)
}

Video walking through Excel cell alignment with AutoHotkey