Solved screen prints of mouse clicks and only of active window.

August 3, 2015 at 03:09:03
Specs: Windows 7
How can i take screen prints of mouse clicks and only of active window.. something like psr, the problem i am having is psr takes screenprint of entire screen. is there a code that i can use to get this done

See More: screen prints of mouse clicks and only of active window.

Report •

✔ Best Answer
September 4, 2015 at 05:31:43
Hi mmccconaghy,

Thanks for the link

This is the same as what i am attempting to you, i did something similar that the OP requested years ago in VB6 as part of a uni project, but as i dont use VB6 anymore on my current machine i cannot compile the code to and exe.

i am using this again in VBA in Excel and it works ok, seems to capture the screen shot of the active window, but that is on every click, so even if you click on the start button it snaps that. It also has a lot of issues with efficiency, the timer causes the pc to hang for a few seconds, i know this can be resolved but i dont have time right now to play with it.

The code looks for the click event, evaluates whether it was the left or right, then print screens and pastes the content of the clipboard to sheet1. Then it exports the content of sheet one to a folder with the time hhmmss .jpg.

I was hoping Derby would take a look if he doesnt mind. Lets see what the OP thinks of this sort of solution..

Thanks again



#1
August 3, 2015 at 03:19:42
Im not sure what you mean by 'of mouse clicks'

In Windows 7 you have a tool called 'Snipping Tool' under 'Accessories' you can use this to highlight and select the area you wish to copy. Then copy and paste it into where every you desire.

Alternatively to take a snap shot of the active window you can hold down the Alt key and press the psr key this will take a screen shot of the Active WIndow only.

message edited by AlwaysWillingToLearn


Report •

#2
August 3, 2015 at 10:16:19
I am in a training team and when i explain the processes to the employees i need to take screen print of each of the activity to create SOP (standard operating procedure).

I am looking at a solution where it automatically takes the screen print of the window where i click the mouse.. for example if i am using notepad it have to take screenprint of it.

PSR is a inbuilt app in windows.. however there are few limitations like it take screen print of entire scree and limits to only 99 screen prints


Report •

#3
August 4, 2015 at 05:25:33
I'm afraid I've never heard of a Windows App named PSR. What exactly is it? I'm curious

Or, you could try the fourth link:

https://www.google.com/search?q=scr...

Or, create a video of what you're trying to do rather than screen prints.

message edited by beachyhbt


Report •

Related Solutions

#4
September 3, 2015 at 01:28:34
May be I am not clear let me try and put it in better way.

I am part of a training team, where I have to show how to process a particular task. say I am have to teach users how to do a "vlookup" in excel.

For creating documentation, I have to click on specific buttons and take screen print and delete unnecessary windows that have been captured as part of the screen print

What I am looking for is a program while I am teaching students on the PC it have to record the screenprints based on the mouse clicks, only of the active window as at times i get messages in Microsoft communicator which will also being captured

Microsoft inbuilt program PSR(problem statement recorder) does a good job however, I takes the screen print of entire screen but not the active window.

Hope I am clear and thank you everybody for earlier suggestions and questions.


Report •

#5
September 3, 2015 at 05:43:41
I just tried PSR and I get an error when I click Stop Recording:

"An error occurred while attempting to save the recorded steps"

It may be because zip files are disabled on my corporate computer or it might be that I am not an administrator. I'll have to play with it at home.

That said, I do not see a setting to limit the capture to just the active window, but since I can't really use the program at this time, I can't play around to see what I can get it to do. Maybe I'll have a suggestion later.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

message edited by DerbyDad03


Report •

#6
September 3, 2015 at 07:09:40
I messed around with a VBA solution in excel, seems to work OK...Sometimes... iv not had much time to play with it at work but can share the code if this is something you may be interested in? it will most definetly need tweeking and support from Derby if you are interested Derby? my VBA skills are average so there most likely be things that Derby can improve.

The code looks out for a left click and takes a screen shot of the active window and saves it to a specified folder using the current time, format hhmmss .jpg.

the code isnt perfect iv only just started to play with this so will need some messing with. if this isnt an option for you then fair enough, it was worth the challenge anyways :)


Report •

#7
September 3, 2015 at 07:44:46
I know very little about Visual Basic,
But, here is a link to some Visual Basic code that appears to do what is needed:

https://support.microsoft.com/en-us...

Note the instructions 5 & 6 at the bottom.

MIKE

http://www.skeptic.com/


Report •

#8
September 4, 2015 at 05:31:43
✔ Best Answer
Hi mmccconaghy,

Thanks for the link

This is the same as what i am attempting to you, i did something similar that the OP requested years ago in VB6 as part of a uni project, but as i dont use VB6 anymore on my current machine i cannot compile the code to and exe.

i am using this again in VBA in Excel and it works ok, seems to capture the screen shot of the active window, but that is on every click, so even if you click on the start button it snaps that. It also has a lot of issues with efficiency, the timer causes the pc to hang for a few seconds, i know this can be resolved but i dont have time right now to play with it.

The code looks for the click event, evaluates whether it was the left or right, then print screens and pastes the content of the clipboard to sheet1. Then it exports the content of sheet one to a folder with the time hhmmss .jpg.

I was hoping Derby would take a look if he doesnt mind. Lets see what the OP thinks of this sort of solution..

Thanks again


Report •

#9
September 4, 2015 at 05:38:23
Here is the code just in case you guys want to play, as mentioned this is not perfect by any means i put it together in a short amount of time and havent had time to test extensively.

Note i was previously using Application.onTime but because it was cauing issues i tried another method using a do while loop to create a timer event.

For now i am using a userform to make it easier to test the code

Form code

Private Sub UserForm_Terminate()
    ClearClipboard
    UnhookWindowsHookEx gHook
End Sub

Private Sub CommandButton1_Click()
    Run Module1.StopAll
End Sub

Private Sub UserForm_Initialize()

'Application.WindowState = xlMinimized

gHook = SetWindowsHookEx(WH_MOUSE_LL, AddressOf MouseProc, Application.Hinstance, 0)

StartTimer

End Sub

I have seperated the other code into modules for neatness

module 1

Public gHook As Long
Public Const WH_MOUSE_LL As Long = 14
Private Const WM_LBUTTONDOWN As Long = &H201
Private Const HC_ACTION As Long = 0
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_SNAPSHOT = &H2C
Private Const VK_MENU = &H12

Public HasClicked As Boolean

Public Function MouseProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    
    If (nCode = HC_ACTION) Then
        If wParam = WM_LBUTTONDOWN Then
            HasClicked = True
      '  Else
      '      HasClicked = False
        End If
    End If
                        
    CallNextHookEx 0, nCode, wParam, ByVal lParam
End Function

Sub AltPrintScreen()
    keybd_event VK_MENU, 0, 0, 0
    keybd_event VK_SNAPSHOT, 0, 0, 0
    keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
    keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
End Sub

Sub PrintScreen()
    keybd_event VK_SNAPSHOT, 1, 0, 0
End Sub

Public Sub Add_Schedule()
    
    Dim iShape As Shape
    
    gHook = SetWindowsHookEx(WH_MOUSE_LL, AddressOf MouseProc, Application.Hinstance, 0)
    
If HasClicked Then
    
    AltPrintScreen
    
    Sheet1.Activate
    
    DoEvents
    Sheet1.Range("A1").PasteSpecial 'xlBitmap
    DoEvents
    
    Sheet1.Cells.Clear
   ' Application.CutCopyMode = False

    For Each iShape In Sheet1.Shapes
        ExportMyPicture iShape.Name
    Next iShape

    HasClicked = False

    DoEvents
    
End If

    StartTimer

End Sub

Public Sub StartTimer()

Dim PauseTime, Start, Finish, TotalTime
    
    PauseTime = 1  ' Set duration.
    Start = Timer    ' Set start time.
    
    Do While Timer < Start + PauseTime
        DoEvents    ' Yield to other processes.
    Loop
    
    Finish = Timer    ' Set end time.
    TotalTime = Finish - Start    ' Calculate total time.

    Add_Schedule

End Sub


module 2

Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function CloseClipboard Lib "user32" () As Long

Public Function ClearClipboard()
    OpenClipboard (0&)
    EmptyClipboard
    CloseClipboard
    DoEvents
End Function


module 3

Public Sub ExportMyPicture(PicName As String)
DoEvents
     Dim MyChart As String, MyPicture As String
     Dim PicWidth As Long, PicHeight As Long

     Application.ScreenUpdating = False
'     On Error GoTo Finish

'     MyPicture = Selection.Name
    
     MyPicture = PicName
    Sheet1.Shapes(MyPicture).Select
        
'     With Selection
'           PicHeight = .ShapeRange.Height
'           PicWidth = .ShapeRange.Width
'     End With

     With Sheet1.Shapes(MyPicture)
           PicHeight = .Height
           PicWidth = .Width
     End With

     Charts.Add
     ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
     Selection.Border.LineStyle = 0
     MyChart = Selection.Name & " " & Split(ActiveChart.Name, " ")(2)

     With ActiveSheet
           With .Shapes(MyChart)
                 .Width = PicWidth
                 .Height = PicHeight
           End With

           .Shapes(MyPicture).Copy

           With ActiveChart
                 .ChartArea.Select
                 .Paste
           End With

           '.ChartObjects(1).Chart.Export Filename:="MyPic.jpg", FilterName:="jpg"
           .ChartObjects(1).Chart.Export ThisWorkbook.Path & "\images\" & Format(Now(), "mmhhss") & ".jpg"
           
           .Shapes(MyChart).Cut
     End With

     Application.ScreenUpdating = True
     
     Sheet1.Shapes(MyPicture).Delete
     Application.CutCopyMode = False
     
     'Call ClearClipboard
 DoEvents
     Exit Sub

'Finish:
 '    MsgBox "You must select a picture"
End Sub


message edited by AlwaysWillingToLearn


Report •

#10
September 4, 2015 at 06:22:03
Pardon me for butting in but ...

beachyhbt wrote I'm afraid I've never heard of a Windows App named PSR. What exactly is it? I'm curious

Check out http://windows.microsoft.com/en-us/...

i_Xp/Vista/W7/W10 User


Report •

#11
September 4, 2015 at 06:25:42
PSR is (problem statment recorder), when you click on start buttion and type PSR in run i dailog opens to record, when you start recording, it records every screen based on the click

Report •

#12
September 4, 2015 at 07:20:57
MWSnap (free) is a good capture utility. It has a feature to capture the current Window. I've used it for years.

http://www.mirekw.com/winfreeware/m...

Always pop back and let us know the outcome - thanks

message edited by Derek


Report •

#13
September 21, 2015 at 01:38:16
Apowersoft Free Screen Capture has a screenshot mode of "Window" which means taking screenshot of active window.

Report •

Ask Question