Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


ScreenShot help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
AndrewMan
Grandmaster Cheater Supreme
Reputation: 0

Joined: 01 Aug 2007
Posts: 1257

PostPosted: Sat May 24, 2008 9:31 pm    Post subject: ScreenShot help Reply with quote

Edit: Code for "screenshot" button:

Code:
Me.WindowState = FormWindowState.Minimized
        Dim bounds As Rectangle
        Dim screenshot As System.Drawing.Bitmap
        Dim graph As Graphics
        bounds = Screen.PrimaryScreen.Bounds
        screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
        graph = Graphics.FromImage(screenshot)
        graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
        PictureBox1.Image = screenshot


Their something wrong here?????


NOTE: Coded in .NET

Basically I am workin on a screenshot program now.

I have created something that when you click "Take screenshot", it captures the screen, and pastes it into the window in a PictureBox.

There is another button called "Save" where it
1) Writes your image you captured into a .gif form in the folder "C:/temp/".

Problem: Writes the image and everything, but nothing is showing up. Basically you click it, windows picture viewer comes up, and "no image is available".

Here is the code for the save button:

Code:
Dim savef As New System.IO.StreamWriter("C:/temp/" +  TextBox2.Text +".gif")
        savef.Write(PictureBox1.Image)
        savef.Close()
        MsgBox("Picture Saved!")



2nd Problem: How do you make the form exit right before the screenshot, than re-appear?

_________________


Last edited by AndrewMan on Sun May 25, 2008 12:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sat May 24, 2008 9:37 pm    Post subject: Reply with quote

Change form visibility. I don't know vb. But it's probably something like

Code:

form1.visible = false

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
AndrewMan
Grandmaster Cheater Supreme
Reputation: 0

Joined: 01 Aug 2007
Posts: 1257

PostPosted: Sat May 24, 2008 9:41 pm    Post subject: Reply with quote

oib111 wrote:
Change form visibility. I don't know vb. But it's probably something like

Code:

form1.visible = false


Tried that, than after screenshot I did

Code:
Me.visible = true


didn't work...

_________________
Back to top
View user's profile Send private message
Typhoon808
Expert Cheater
Reputation: 0

Joined: 27 Mar 2008
Posts: 175
Location: Wales

PostPosted: Sun May 25, 2008 5:35 am    Post subject: Reply with quote

To minimise:
Code:
Me.WindowState = FormWindowState.Minimized


Declarations etcetera:
Code:

Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As String) As Integer
    Private Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hDC As Integer) As Integer
    Private Declare Function CreateCompatibleBitmap Lib "GDI32" (ByVal hDC As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer) As Integer
    Private Declare Function GetDeviceCaps Lib "gdi32" Alias "GetDeviceCaps" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
    Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Integer, ByVal hObject As Integer) As Integer
    Private Declare Function BitBlt Lib "GDI32" (ByVal srchDC As Integer, ByVal srcX As Integer, ByVal srcY As Integer, ByVal srcW As Integer, ByVal srcH As Integer, ByVal desthDC As Integer, ByVal destX As Integer, ByVal destY As Integer, ByVal op As Integer) As Integer
    Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Integer) As Integer
    Private Declare Function DeleteObject Lib "GDI32" (ByVal hObj As Integer) As Integer

    Const SRCCOPY As Integer = &HCC0020
    Private Background As Bitmap

    Private fw, fh As Integer
    Dim Counter As Integer

    Protected Sub CaptureScreen()
        Dim hsdc, hmdc As Integer
        Dim hbmp, hbmpold As Integer
        Dim r As Integer
        hsdc = CreateDC("DISPLAY", "", "", "")
        hmdc = CreateCompatibleDC(hsdc)
        fw = GetDeviceCaps(hsdc, 8)
        fh = GetDeviceCaps(hsdc, 10)
        hbmp = CreateCompatibleBitmap(hsdc, fw, fh)
        hbmpold = SelectObject(hmdc, hbmp)
        r = BitBlt(hmdc, 0, 0, fw, fh, hsdc, 0, 0, 13369376)
        hbmp = SelectObject(hmdc, hbmpold)
        r = DeleteDC(hsdc)
        r = DeleteDC(hmdc)
        Background = Image.FromHbitmap(New IntPtr(hbmp))
        DeleteObject(hbmp)
    End Sub


Then to get a screenshot:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
CaptureScreen()
Counter = Counter + 1 'Used for screenshot saves (screenshot1, screenshot2 etc.)
        PictureBox1.Image = Background 'Put the image in the picturebox
        PictureBox1.Image.Save(txtScreenDir.Text & "\" & Counter & ".png", Imaging.ImageFormat.Png)

End Sub


Make a counter variable so it saves the screenshots correctly (screen1, screen2 etc). You may also want to check if the clipboard contains an image (If Clipboard.ContainsImage Then) before you save it.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun May 25, 2008 5:50 am    Post subject: Reply with quote

@Typhoon808: Please credit your code properly if you are going to copy and paste from somewhere else.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Typhoon808
Expert Cheater
Reputation: 0

Joined: 27 Mar 2008
Posts: 175
Location: Wales

PostPosted: Sun May 25, 2008 7:49 am    Post subject: Reply with quote

My bad, I'm not sure where I got it from. I've had it in a text document for a while now.
Back to top
View user's profile Send private message
AndrewMan
Grandmaster Cheater Supreme
Reputation: 0

Joined: 01 Aug 2007
Posts: 1257

PostPosted: Sun May 25, 2008 9:42 am    Post subject: Reply with quote

Thanks guys. Ill try these codes out later to see if they work. But I know how to take a screenshot and paste it into a picturbox, just not sure how to save and make the form not visible.
_________________
Back to top
View user's profile Send private message
Typhoon808
Expert Cheater
Reputation: 0

Joined: 27 Mar 2008
Posts: 175
Location: Wales

PostPosted: Sun May 25, 2008 10:00 am    Post subject: Reply with quote

Best is to just make the form minimise. Use PictureBox1.Image.Save("directoryhere.png", Imaging.ImageFormat.Png) to save the image.
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sun May 25, 2008 11:14 am    Post subject: Reply with quote

or there is the bitblt method >.>
_________________
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sun May 25, 2008 11:47 am    Post subject: Reply with quote

I believe that there are managed ways of doing this, but I'm not sure.

You should Google around a bit for managed ways of taking screen shots. Wink

Edit:

You could always send the Print Screen key (VK_SNAPSHOT = 0x2C), then use Clipboard.GetImage() or something in that class. =P

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended


Last edited by samuri25404 on Sun May 25, 2008 12:52 pm; edited 1 time in total
Back to top
View user's profile Send private message
AndrewMan
Grandmaster Cheater Supreme
Reputation: 0

Joined: 01 Aug 2007
Posts: 1257

PostPosted: Sun May 25, 2008 12:02 pm    Post subject: Reply with quote

blankrider wrote:
or there is the bitblt method >.>


That gets way to confusing. Im trying to make it as simple as a I can.

I got the save thing to work... but I cant get the minimize thing to work.

_________________
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sun May 25, 2008 12:12 pm    Post subject: Reply with quote

AndrewMan wrote:
blankrider wrote:
or there is the bitblt method >.>


That gets way to confusing. Im trying to make it as simple as a I can.

I got the save thing to work... but I cant get the minimize thing to work.


I prefer to use faster more improved ways of doing things. If not, i would just MFC everything and use fancy wrappers.

But that's just me.

_________________
Back to top
View user's profile Send private message
killersamurai
Expert Cheater
Reputation: 0

Joined: 10 Sep 2007
Posts: 197
Location: Colorado

PostPosted: Sun May 25, 2008 3:17 pm    Post subject: Reply with quote

I re-did it in c# with the fix.

Code:

Rectangle bounds = Screen.PrimaryScreen.Bounds;
Bitmap screenshot = new Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
Graphics graph = Graphics.FromImage(screenshot);

this.Visible = false;
System.Threading.Thread.Sleep(1000);
graph.CopyFromScreen(0, 0, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy); // The first two should always be 0 if it's the desktop
picCap.Image = screenshot;
this.Visible = true;


To save, you can do it with one line of code.
Code:

PictureBox1.Image.Save(<Location>);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites