Solved

Screenshot--No taskbar

Posted on 2001-08-05
16
4,198 Views
Last Modified: 2012-08-14
Hello all,

I need to get a screenshot of the desktop...without the taskbar...
Thanks
0
Comment
Question by:Form_Glow
  • 9
  • 5
  • 2
16 Comments
 
LVL 3

Expert Comment

by:andysalih
ID: 6354216
ill tell you the way how to without vb code,

i asume thats what you want

click on START

SETTINGS

TASKBAR

tick AUTOHIDE.

then go to your desk top and press


press PRINT SCREEN BUTTON (PRTSCN)

THEN CLICK ON START

RUN

TYPE write in the open dialog box

then into EDIT & PASTE

presto

you have a copy of your desk top
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6354220
ps if you want a piece of code then download the following,

A Nice Looking Screen Capturing Tool. Use this camera take pictures of your desktop screen. You can take screenshots for your works using this


http://www.planetsourcecode.com/xq/ASP/txtCodeId.25287/lngWId.1/qx/vb/scripts/ShowCode.htm

cheers
Andy
0
 
LVL 1

Author Comment

by:Form_Glow
ID: 6354227
The planet code....won't even load...I don't have time to mess with it.
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 3

Expert Comment

by:andysalih
ID: 6354230
are you after a vb code to do it then ??

cheers

andy
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6354240


Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long


Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)


Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
    (LpVersionInformation As OSVERSIONINFO) As Long
    Public Const VK_MENU = &H12
    Public Const KEYEVENTF_KEYUP = &H2


Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128 ' Maintenance string for PSS usage
    End Type
         
         
'**************************************
' Name: GetWindowSnapShot
' Description:This allows a VB program t
'     o capture either the screen or the progr
'     am window.
It has been tested under Win95 and NT4.0. It derives from a routine by Dan Appleman (VisualBasic 5.0 Programmer's Guide to the WIN32 API.



Private Sub Command1_Click()
    GetWindowSnapShot 0, Image1
End Sub


Private Sub Command2_Click()
    GetWindowSnapShot 1, Image1
End Sub






'Insert this in a module:


Public Sub GetWindowSnapShot(Mode As Long, ThisImage As Image)
   
    ' mode = 0 -> Screen snapshot
    ' mode = 1 -> Window snapshot
   
    Dim altscan%, NT As Boolean, nmode As Long
   
    NT = IsNT


    If Not NT Then
        If Mode = 0& Then Mode = 1& Else Mode = 0&
    End If
   


    If NT And Mode = 0 Then
        keybd_event vbKeySnapshot, 0&, 0&, 0&
    Else
        altscan = MapVirtualKey(VK_MENU, 0)
        keybd_event VK_MENU, altscan, 0, 0


        DoEvents
            keybd_event vbKeySnapshot, Mode, 0&, 0&
        End If


        DoEvents
            ThisImage = Clipboard.GetData(vbCFBitmap)
            keybd_event VK_MENU, altscan, KEYEVENTF_KEYUP, 0
        End Sub


Public Function IsNT() As Boolean
    Dim verinfo As OSVERSIONINFO
    verinfo.dwOSVersionInfoSize = Len(verinfo)
    If (GetVersionEx(verinfo)) = 0 Then Exit Function
    If verinfo.dwPlatformId = 2 Then IsNT = True
End Function


hope this helps. it will not hide the taskbar though, but it will snap shot the desktop.

cheers
Andy
0
 
LVL 1

Author Comment

by:Form_Glow
ID: 6354244
The planet code....won't even load...I don't have time to mess with it.
0
 
LVL 1

Author Comment

by:Form_Glow
ID: 6354245
no taskbar...is the question. I have screen capture code.
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6354248
okey i can give you some code to hide the task bar which you will need to add to your code will that do??
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6354253
if you have code to snap shot the desktop before it does that then insert this code


Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long


Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal
lpWindowName As String) As Long


Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal
hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long


that will then hide the taskbar before you take the snap

thats the only way your gonna do it

cheers
Andy
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6354257
add this to the end
Sub Show_TaskBar()
   ShowWindow FindWindow("Shell_TrayWnd", vbNullString), 5
End Sub


sorry forgot to copy it from my code

cheers
Andy
0
 
LVL 1

Author Comment

by:Form_Glow
ID: 6354260
Sorry...I can't hide the taskbar. I just need to get the RECT of the taskbar...and not include that portion in the screenshot.
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6354262
FORGET ALL THE ABOVE CODE

sorry its late

do this

insert this into your code before it takes a shot of the desktop

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Sub form_load()
ShowWindow FindWindow("Shell_TrayWnd", vbNullString), 0
End Sub


cheers
Andy
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6354266
i cant do it for you then , the code ive given which is :-

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Sub form_load()
ShowWindow FindWindow("Shell_TrayWnd", vbNullString), 0
End Sub

that will hide the task bar, but i don't know how to get the task bar and not show it in your snap, i dont think you can, without hiding it first.

why not make it hide, then snap, then show task bar. back to normal state.

good luck with your project sorry i couldnt help

andy

0
 
LVL 6

Accepted Solution

by:
sharmon earned 100 total points
ID: 6354569
Here is an example of an idea I had while reading your question.  Give it a try, it seems to be what you are asking for as long as I am reading it correctly.  If you have any questions, please let me know.

Option Explicit

'Constants
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source

'Types
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

'Windows API declarations
Private Declare Function BitBlt Lib "gdi32" _
    (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, _
    ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _
    ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function FindWindowEx Lib "user32" _
    Alias "FindWindowExA" (ByVal hWnd1 As Long, _
    ByVal hWnd2 As Long, ByVal lpsz1 As String, _
    ByVal lpsz2 As String) As Long

Private Declare Function GetDesktopWindow Lib "user32" () As Long

Private Declare Function GetWindowDC Lib "user32" _
    (ByVal hwnd As Long) As Long

Private Declare Function GetWindowRect Lib "user32" _
    (ByVal hwnd As Long, lpRect As RECT) As Long
   
   
Private Sub Form_Load()
    'Setup form and picture
    'Make sure you added one picture box to the form
    'named Picture1
    Me.ScaleMode = vbPixels
    Picture1.AutoRedraw = True
    Picture1.ScaleMode = vbPixels
   
    Dim lngSysListView As Long
    Dim lngRet As Long
    Dim lngDesktop As Long
    Dim lngDesktopDC As Long
    Dim rc As RECT
   
    'Find the system listview window it will give us a rectangle
    'that is equal to the desktop's position without the taskbar
    lngRet = FindWindow("Progman", "Program Manager")
    lngRet = FindWindowEx(lngRet, 0&, "SHELLDLL_DefView", "")
    lngSysListView = FindWindowEx(lngRet, 0&, "SysListView32", "")
   
    'Get the rectangle of the system listview
    lngRet = GetWindowRect(lngSysListView, rc)
   
    'Get our desktop hdc so we can bitblt the screen to the
    'picture box
    lngDesktop = GetDesktopWindow()
    lngDesktopDC = GetWindowDC(lngDesktop)
       
    'Resize our picture box to fit the rectangle
    Picture1.Height = rc.Bottom - rc.Top
    Picture1.Width = rc.Right - rc.Left
       
    'Copy the image to our picture box...
    BitBlt Picture1.hDC, 0, 0, rc.Right - rc.Left, rc.Bottom - rc.Top, _
        lngDesktopDC, rc.Left, rc.Top, SRCCOPY
   
    'Save the picture out to a file for testing...whatever.
    SavePicture Picture1.Image, "c:\temp.bmp"
End Sub
0
 
LVL 1

Author Comment

by:Form_Glow
ID: 6354594
Works great...(might chop a pixel or two)

I figured another way...

Dim rc As RECT
Just get the available desktop real estate:
Call SystemParametersInfo(SPI_GETWORKAREA, 0&, rc, 0&)


0
 
LVL 6

Expert Comment

by:sharmon
ID: 6354626
Yeah, I thought about that just a few minutes after I posted:)  I was going to update it for that, but you beat me to it.  What I gave you was the first thing that popped in my head, but I am glad it helped you take care of the problem.  Take care...

Shannon
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question