Using AHK (Auto Hot Key) scripts to resize and crop images in Microsoft Powerpoint Professional Plus 2016

Powerpoint may be notoriously difficult to contain, in terms of efficiency and workflow. While it is great, creatively speaking, it is not just as geared towards fast forwarding image cataloging than one would have wished for.

Regardless, it has improved over the years. Using VBA for efficient useful macros is still an issue though, and free definition of all sorts of keyboard shortcuts seems to be not available too easily – so externally controlling the application using AHK scripts seemed to be a logical next step. I already use AHK scripts profusely for web stuff and also for LaTeX typesetting, so who says it is a problem to use the same approach for Powerpoint.

Here are a few short cuts I programmed for fast image cropping and placement.

The script parts are pretty much self explanatory, otherwise just try them out – continuous crop sliding and set resize widths to full, half and third page width are all there. The resize command that I use here works on grouped images also.

Obviously, there seems to be some type of prefix encoded object oriented approach to variable handling, so if you want to perform something else, just see what you come up with inside Powerpoint’s macro environment and transfer it to AHK in the same way. At least that was how I came up with these: check some example of an AHK script for Powerpoint control, then write these.

+NumPad4:: 
ppt := ComObjActive("PowerPoint.Application")
ma:= ppt.ActiveWindow.Selection.ShapeRange
mal:= ma.PictureFormat.CropLeft
ma.PictureFormat.CropLeft:= mal-10
return
NumPad4:: 
ppt := ComObjActive("PowerPoint.Application")
ma:= ppt.ActiveWindow.Selection.ShapeRange
mal:= ma.PictureFormat.CropLeft
ma.PictureFormat.CropLeft:= mal+10
return
+Numpad6:: 
ppt := ComObjActive("PowerPoint.Application")
ma:= ppt.ActiveWindow.Selection.ShapeRange
mal:= ma.PictureFormat.CropRight
ma.PictureFormat.CropRight:= mal-10
return
NumPad6:: 
ppt := ComObjActive("PowerPoint.Application")
ma:= ppt.ActiveWindow.Selection.ShapeRange
mal:= ma.PictureFormat.CropRight
ma.PictureFormat.CropRight:= mal+10
return
+Numpad8:: 
ppt := ComObjActive("PowerPoint.Application")
ma:= ppt.ActiveWindow.Selection.ShapeRange
mal:= ma.PictureFormat.CropTop
ma.PictureFormat.CropTop:= mal-10
return
Numpad8:: 
ppt := ComObjActive("PowerPoint.Application")
ma:= ppt.ActiveWindow.Selection.ShapeRange
mal:= ma.PictureFormat.CropTop
ma.PictureFormat.CropTop:= mal+10
return
+Numpad2:: 
ppt := ComObjActive("PowerPoint.Application")
ma:= ppt.ActiveWindow.Selection.ShapeRange
mal:= ma.PictureFormat.CropBottom
ma.PictureFormat.CropBottom:= mal-10
return
NumPad2:: 
ppt := ComObjActive("PowerPoint.Application")
ma:= ppt.ActiveWindow.Selection.ShapeRange
mal:= ma.PictureFormat.CropBottom
ma.PictureFormat.CropBottom:= mal+10
return
^NumPad4:: 
ppt := ComObjActive("PowerPoint.Application")
ma:= ppt.ActiveWindow.Selection.ShapeRange
mav:= ma.Width
ma.Width := 500
return
^NumPad5:: 
ppt := ComObjActive("PowerPoint.Application")
ma:= ppt.ActiveWindow.Selection.ShapeRange
mav:= ma.Width
ma.Width := 500/2
return
^NumPad6:: 
ppt := ComObjActive("PowerPoint.Application")
ma:= ppt.ActiveWindow.Selection.ShapeRange
mav:= ma.Width
ma.Width := 500/3
return
^NumpadAdd:: 
ppt := ComObjActive("PowerPoint.Application")
ma:= ppt.ActiveWindow.Selection.ShapeRange
maw:= ma.Width
mah:=ma.Height
ma.Width := maw*1.03
ma.Height:=mah*1.03
return
^NumpadSub::
ppt := ComObjActive("PowerPoint.Application")
ma:= ppt.ActiveWindow.Selection.ShapeRange
maw:= ma.Width
mah:=ma.Height
ma.Width := maw*0.98
ma.Height:=mah*0.98
return

 

tech Cite this article:
Wolf Schweitzer: swisswuff.ch - Using AHK (Auto Hot Key) scripts to resize and crop images in Microsoft Powerpoint Professional Plus 2016; published 12/11/2018, 14:35; URL: https://www.swisswuff.ch/wordpress/?p=1657

BibTeX: @MISC{schweitzer_wolf_1775117600, author = {Wolf Schweitzer}, title = {{swisswuff.ch - Using AHK (Auto Hot Key) scripts to resize and crop images in Microsoft Powerpoint Professional Plus 2016}}, month = {November}, year = {2018}, url = {https://www.swisswuff.ch/wordpress/?p=1657} }