The following is tailored specifically to a website that has a webcam on a bald eagle nest but could be adapted to any other site. The web cam image should display on a dialog but may not show up precisely in the dialog on your system.. but no worries.
- arrow keys will move the view around the webpage
- Alt + arrow keys will resize the window
- ctrl + up/down arrow keys will change magnification
- Pick and drag on the window to move it
- Press Esc to close
Settings are saved to an ini file in the temp folder. As written this script requires Macro Scheduler version 12.
The eaglets are due to start hatching soon, maybe today. Today is April 1, 2011
Code: Select all
Let>RP_WINDOWMODE=0
RunProgram>mshta.exe http://www.ustream.tv/decoraheagles
WaitWindowOpen>decorah*
Wait>2
GetWindowHandle>decorah*,Winhndl
GoSub>MakeOpaque,Winhndl,2
IfFileExists>%temp_dir%Eagle_parameters.ini~
ReadIniFile>%temp_dir%Eagle_parameters.ini~,Settings,Magnification,Factor
ReadIniFile>%temp_dir%Eagle_parameters.ini~,Settings,Window Width,Wide
ReadIniFile>%temp_dir%Eagle_parameters.ini~,Settings,Window Height,High
ReadIniFile>%temp_dir%Eagle_parameters.ini~,Settings,View X Location,CX
ReadIniFile>%temp_dir%Eagle_parameters.ini~,Settings,View Y Location,CY
ReadIniFile>%temp_dir%Eagle_parameters.ini~,Settings,Window X Location,WinX
ReadIniFile>%temp_dir%Eagle_parameters.ini~,Settings,Window Y Location,WinY
Else
GoSub>Defaults
EndIf
Let>WIN_USEHANDLE=1
//SetFocus>Winhndl
MoveWindow>Winhndl,-32000,-32000
SetFocus>Winhndl
Let>WIN_USEHANDLE=0
Dialog>TitleBarSizeCalculation
Top=0
Left=0
Button=1,0,0,75,25,0
EndDialog>TitleBarSizeCalculation
Let>WIN_USEHANDLE=1
GetWindowPos>TitleBarSizeCalculation.msButton1.handle,OffSetX,OffSetY
Let>WIN_USEHANDLE=0
OnEvent>Key_down,VK1,0,LeftClick
OnEvent>Key_down,VK27,0,Quit
OnEvent>Key_down,VK37,0,LeftArrowLoc
OnEvent>Key_down,VK38,0,DownArrowLoc
OnEvent>Key_down,VK39,0,RightArrowLoc
OnEvent>Key_down,VK40,0,UpArrowLoc
OnEvent>Key_down,VK37,3,LeftArrowSize
OnEvent>Key_down,VK38,3,DownArrowSize
OnEvent>Key_down,VK39,3,RightArrowSize
OnEvent>Key_down,VK40,3,UpArrowSize
OnEvent>Key_down,VK38,2,UpMagnification
OnEvent>Key_down,VK40,2,DownMagnification
Dialog>Dialog1
object Dialog1: TForm
Left = 662
Top = 177
HelpContext = 5000
BorderIcons = [biSystemMenu]
BorderStyle = bsNone
Caption = 'Eagle Cam'
ClientHeight = 200
ClientWidth = 300
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
FormStyle = fsStayOnTop
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,,OnMouseDown,Move
AddDialogHandler>Dialog1,,OnMouseUp,StopMove
//AddDialogHandler>Dialog1,,OnDblClick,Quit
Let>WIN_USEHANDLE=1
MoveWindow>Dialog1.handle,WinX,WinY
Let>WIN_USEHANDLE=0
GoSub>Setup
Show>Dialog1
LibFunc>user32,GetDC,HDC3,Winhndl
LibFunc>user32,GetDC,HDC1,Dialog1.handle
Label>Loop
Wait>0.01
GoSub>Process
Goto>Loop
SRT>Move
Let>XSpa={round(%Wide%/2)}
Let>Yspa={round(%High%/2)}
Let>MoveFlag=1
While>MoveFlag=1
GetCursorPos>CurX,CurY
Let>WIN_USEHANDLE=1
Sub>CurX,%XSpa%
Sub>CurY,%YSpa%
MoveWindow>Dialog1.handle,CurX,CurY
Let>WIN_USEHANDLE=0
EndWhile
END>Move
SRT>StopMove
Let>MoveFlag=0
END>StopMove
SRT>Process
Let>ProcessFlag=1
Wait>0.01
LibFunc>Gdi32,StretchBlt,SBres,HDC1,-0,-0,%wide%,%high%,HDC3,CX,CY,Xspan,Yspan,13369376
Let>ProcessFlag=0
END>Process
SRT>Setup
Let>XSpan={round(%Wide%/%factor%)}
Let>Yspan={round(%High%/%factor%)}
Let>Height=%High%+%OffSetY%
Let>WIN_USEHANDLE=1
ResizeWindow>Dialog1.handle,Wide,Height
Let>WIN_USEHANDLE=0
END>Setup
SRT>LeftClick
Let>WIN_USEHANDLE=1
GetActiveWindow>title,Winx,WinY
Let>WIN_USEHANDLE=0
If>title=MagnifierDialog1.handle
GetCursorPos>ClickX,ClickY
CloseDialog>MagnifierDialog1
Wait>0.1
LDBLClick
Wait>0.1
Show>MagnifierDialog1
EndIf
END>LeftClick
SRT>LeftArrowLoc
Sub>cx,1
GoSub>Process
//Wait>0.1
END>LeftArrowLoc
SRT>RightArrowLoc
Add>cx,1
GoSub>Process
//Wait>0.1
END>RightArrowLoc
SRT>UpArrowLoc
Add>cy,1
GoSub>Process
//Wait>0.1
END>UpArrowLoc
SRT>DownArrowLoc
Sub>cy,1
GoSub>Process
//Wait>0.1
END>DownArrowLoc
SRT>LeftArrowSize
If>wide>1
Sub>Wide,1
EndIf
GoSub>Setup
GoSub>Process
//Wait>0.1
END>LeftArrowSize
SRT>RightArrowSize
Add>Wide,1
GoSub>Setup
GoSub>Process
//Wait>0.1
END>RightArrowSize
SRT>UpArrowSize
Add>High,1
GoSub>Setup
GoSub>Process
//Wait>0.1
END>UpArrowSize
SRT>DownArrowSize
If>High>1
Sub>High,1
EndIf
GoSub>Setup
//Wait>0.1
END>DownArrowSize
SRT>UpMagnification
If>ProcessFlag=0
If>factor<10
Add>factor,0.2
EndIf
Wait>0.1
GoSub>Setup
GoSub>Process
EndIf
END>UpMagnification
SRT>DownMagnification
If>ProcessFlag=0
If>factor>0.2
Sub>factor,0.2
EndIf
Wait>0.1
GoSub>Setup
GoSub>Process
EndIf
END>DownMagnification
SRT>Quit
Let>WIN_USEHANDLE=1
GetWindowPos>Dialog1.handle,WinX,WinY
Let>WIN_USEHANDLE=0
KillProcess>mshta.exe
EditIniFile>%temp_dir%Eagle_parameters.ini~,Settings,Magnification,Factor
EditIniFile>%temp_dir%Eagle_parameters.ini~,Settings,Window Width,Wide
EditIniFile>%temp_dir%Eagle_parameters.ini~,Settings,Window Height,High
EditIniFile>%temp_dir%Eagle_parameters.ini~,Settings,View X Location,CX
EditIniFile>%temp_dir%Eagle_parameters.ini~,Settings,View Y Location,CY
EditIniFile>%temp_dir%Eagle_parameters.ini~,Settings,Window X Location,WinX
EditIniFile>%temp_dir%Eagle_parameters.ini~,Settings,Window Y Location,WinY
Exit>0
END>Quit
SRT>MakeOpaque
//constants
Let>GWL_EXSTYLE=-20
Let>WS_EX_LAYERED=524288
Let>LWA_ALPHA=2
//get style attributes of window
LibFunc>user32,GetWindowLongA,attribs,%MakeOpaque_var_1%,GWL_EXSTYLE
Let>attribs={%attribs% OR %WS_EX_LAYERED%}
//make window transparent
LibFunc>user32,SetWindowLongA,swl,%MakeOpaque_var_1%,GWL_EXSTYLE,attribs
LibFunc>user32,SetLayeredWindowAttributes,res,%MakeOpaque_var_1%,0,255,LWA_ALPHA
END>MakeOpaque
SRT>Defaults
WriteLn>%temp_dir%Eagle_parameters.ini~,wres,[Settings]
//SetDefaults
//Magnification factor
Let>Factor=3
//Magnifier area width
Let>Wide=400
//Magnifier area height
Let>High=200
//screen X location
Let>cx=300
//screen Y locatio
Let>cy=400
//Window X location
Let>winx=100
//Window Y locatio
Let>winy=400
END>Defaults