Automatic screenshots from online presentations

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ritesh99
Posts: 3
Joined: 07 Jun 2021, 09:03

Automatic screenshots from online presentations

07 Jun 2021, 09:33

Hello,

I often use WebEx and Zoom to attend Webinars, and I save the slides by clicking either, right click and save or snipping tool, manually every time the presenter changes the slides. So, is there a way to automatize this process, so that the AHK script will take the screenshot or right-click-save the image, every time the slide changes? Also, if the presenter takes back the slides, it should not take screenshot again and mouse movements on the slide should not be considered as a change in slide.

I know this maybe really hard, but any help or idea will be appreciated!

Thanks a lot : )
User avatar
mikeyww
Posts: 27068
Joined: 09 Sep 2014, 18:38

Re: Automatic screenshots from online presentations

07 Jun 2021, 10:05

You could write a script that saves a screenshot, uses ImageSearch to see when the image changes, and then repeats the process. You would have some work to do to figure out when to exclude an updated screen.
ritesh99
Posts: 3
Joined: 07 Jun 2021, 09:03

Re: Automatic screenshots from online presentations

08 Jun 2021, 03:48

mikeyww wrote:
07 Jun 2021, 10:05
You could write a script that saves a screenshot, uses ImageSearch to see when the image changes, and then repeats the process. You would have some work to do to figure out when to exclude an updated screen.
Thank You! Will try working on that!
ritesh99
Posts: 3
Joined: 07 Jun 2021, 09:03

Re: Automatic screenshots from online presentations

18 Jun 2021, 00:28

Hello,
I would like to share my code for Auto Screenshot of presentation slides. Its using an external app called Lightshot and ScrCmp() Function by SKAN
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=82812&sid=934666f43ca8d6cd38e83f72e40631ed. You an refer to their thread to see the function usage.

Its currently able to take screenshot when slide is changed and save it in the Lightshot's Save Directory. But its not able to figure out if there is repetition of the slide or if the slides were taken back. Please do reply if anyone knows how to compare and remove doubles from saved screenshots

Also, the window in which screenshot has to be taken has to remain active, but I wanted to run this process in the background, so any help on that also will be great!!!

Thanks

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance, Force ; Only launch 1 instance of this script
#Persistent

^r::Reload 

F1::
    Tooltip Please Click the diagnolly opposite corners of selection area ;To select interested area
	KeyWait, LButton, D
	MouseGetPos, X1, Y1
	KeyWait, LButton, U
	ToolTip,  click opposite corner
	ToolTip
	KeyWait, LButton, D
	MouseGetPos, X2, Y2
	
	;Take a start screenshot
	Run, C:\Program Files (x86)\Skillbrains\lightshot\Lightshot.exe
    Send {PrintScreen}
    sleep 100
    MouseClickDrag, Left, %X1%, %Y1%, %X2%, %Y2%
    sleep 100
	Send, ^s
	
	W := X2 - X1
	H := Y2 - Y1
	
	Loop {
		if (ScrCmp( X1, Y1, W, H, , 2000, 0 )) {
		Run, C:\Program Files (x86)\Skillbrains\lightshot\Lightshot.exe
        Send {PrintScreen}
        sleep 100
		MouseClickDrag, Left, %X1%, %Y1%, %X2%, %Y2%
        sleep 100
	    Send, ^s
		sleep 100
	    }
	}
	Until Key Esc

Return

~Esc::ExitApp


ScrCmp( X, Y, W, H, Hwnd:=0x0, Sleep* )  {                                        
Local
Global A_Args
  Sleep[1] := Sleep[1]="" ? 100 : Format("{:d}", Sleep[1])
  Sleep[2] := Sleep[2]="" ? 100 : Format("{:d}", Sleep[2])

  VarSetCapacity(BITMAPINFO, 40, 0)
  NumPut(32, NumPut(1, NumPut(0-H*2, NumPut(W, NumPut(40,BITMAPINFO,"Int"),"Int"),"Int"),"Short"),"Short")

  hBM := DllCall("Gdi32.dll\CreateDIBSection", "Ptr",0, "Ptr",&BITMAPINFO, "Int",0, "PtrP",pBits := 0, "Ptr",0, "Int",0, "Ptr")
  sDC := DllCall("User32.dll\GetDC", "Ptr",(Hwnd := WinExist("ahk_id" . Hwnd)), "Ptr")
  mDC := DllCall("Gdi32.dll\CreateCompatibleDC", "Ptr",sDC, "Ptr")
  DllCall("Gdi32.dll\SaveDC", "Ptr",mDC)
  DllCall("Gdi32.dll\SelectObject", "Ptr",mDC, "Ptr",hBM)
  DllCall("Gdi32.dll\BitBlt", "Ptr",mDC, "Int",0, "Int",H, "Int",W, "Int",H, "Ptr",sDC, "Int",X, "Int",Y, "Int",0x40CC0020)

  A_Args.ScrCmp := {"Wait": 1},   Bytes := W*H*4,  Count := 0
  hMod := DllCall("Kernel32.dll\LoadLibrary", "Str","ntdll.dll", "Ptr")
  While ( A_Args.ScrCmp.Wait && (Count<2) )
  {
      DllCall("Gdi32.dll\BitBlt", "Ptr",mDC, "Int",0, "Int",0, "Int",W, "Int",H, "Ptr",sDC, "Int",X, "Int",Y, "Int",0x40CC0020)
      Count := ( (Byte := DllCall("ntdll.dll\RtlCompareMemory", "Ptr",pBits, "Ptr",pBits+Bytes, "Ptr",Bytes) ) != Bytes )
               ? (Count + 1) : 0
      Sleep % (Count ? Sleep[2] : Sleep[1])
  }   Byte +=1
  DllCall("Kernel32.dll\FreeLibrary", "Ptr",hMod)

  SX := (CX := Mod((Byte-1)//4, W) + X),    SY := (CY := (Byte-1) // (W*4)   + Y)
  If (Hwnd)
    VarsetCapacity(POINT,8,0), NumPut(CX,POINT,"Int"), NumPut(CY,POINT,"Int")
  , DllCall("User32.dll\ClientToScreen", "Ptr",Hwnd, "Ptr",&POINT)
  , SX := NumGet(POINT,0,"Int"),  SY := NumGet(POINT,4,"Int")

  If (Wait := A_Args.ScrCmp.Wait)
      A_Args.ScrCmp := { "Wait":0, "CX":CX, "CY":CY, "SX":SX, "SY":SY }
  DllCall("Gdi32.dll\RestoreDC", "Ptr",mDC, "Int",-1)
  DllCall("Gdi32.dll\DeleteDC", "Ptr",mDC)
  DllCall("User32.dll\ReleaseDC", "Ptr",Hwnd, "Ptr",sDC)
  DllCall("Gdi32.dll\DeleteObject", "Ptr",hBM)
Return ( !!Wait )
}

User avatar
mikeyww
Posts: 27068
Joined: 09 Sep 2014, 18:38

Re: Automatic screenshots from online presentations

18 Jun 2021, 06:32

These pages may help with the issue of comparing images.

https://www.autohotkey.com/boards/viewtopic.php?t=73820

https://autohotkey.com/board/topic/92535-comparing-two-images/

As far as I know, a screenshot reflects only what is visible, not what is hidden on the screen.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], cinematic6436, jjaysreicarnten, mikeyww and 303 guests