Clipboard Images

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • richkid
    New Member
    • Apr 2007
    • 28

    Clipboard Images

    Hi everyone,
    I am trying to get an imagefrom the clipboard.. The senario is the user presses printScreen button on the keyboard and captures an image then go to my web page and click a button and copies the image from the clipboard and saves it to the server....

    I tried using javascript and it worked for Text but not for Images :(

    does anyone knows a way to get it done????
  • TRScheel
    Recognized Expert Contributor
    • Apr 2007
    • 638

    #2
    Originally posted by richkid
    Hi everyone,
    I am trying to get an imagefrom the clipboard.. The senario is the user presses printScreen button on the keyboard and captures an image then go to my web page and click a button and copies the image from the clipboard and saves it to the server....

    I tried using javascript and it worked for Text but not for Images :(

    does anyone knows a way to get it done????

    You want this done in Javascript or ASPX?

    Comment

    • richkid
      New Member
      • Apr 2007
      • 28

      #3
      any way is good for me !!!!

      Comment

      • TRScheel
        Recognized Expert Contributor
        • Apr 2007
        • 638

        #4
        Originally posted by richkid
        any way is good for me !!!!

        In C# you can do this:
        [CODE=cpp]
        Image myImage;
        if (Clipboard.Cont ainsImage())
        {
        myImage = Clipboard.GetIm age();
        // save image
        }[/CODE]

        Havent tried it in ASPX though... would probably take some fiddling with to work right.

        Comment

        • richkid
          New Member
          • Apr 2007
          • 28

          #5
          well thanx for that.....

          it works but not for aspx no clipboard obj :(

          Comment

          • TRScheel
            Recognized Expert Contributor
            • Apr 2007
            • 638

            #6
            Originally posted by richkid
            well thanx for that.....

            it works but not for aspx no clipboard obj :(
            Well, I did some more research into your problem and came upon this:

            ASPX Clipboard

            Comment

            • richkid
              New Member
              • Apr 2007
              • 28

              #7
              well.. i tried something like that b4 but i think my problem is including the .dll

              I created the .dll, set the COM visible and COM class to true, copy the .dll to the web folder, add a reference from a web page and still not getting it to show in the web page... what am i doing wrong?

              Comment

              • TRScheel
                Recognized Expert Contributor
                • Apr 2007
                • 638

                #8
                Originally posted by richkid
                well.. i tried something like that b4 but i think my problem is including the .dll

                I created the .dll, set the COM visible and COM class to true, copy the .dll to the web folder, add a reference from a web page and still not getting it to show in the web page... what am i doing wrong?
                Care to post your code?

                Comment

                • richkid
                  New Member
                  • Apr 2007
                  • 28

                  #9
                  I created anew Windows Control Library Project > add a button and picture box > add the following code :

                  Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
                  Dim myImage As Image
                  Dim txt, path As String
                  path = "C:\Documen ts and Settings\SPY\De sktop\"

                  If Clipboard.Conta insImage() Then
                  myImage = Clipboard.GetIm age()

                  'save image as jpeg
                  Dim myFormat As System.Drawing. Imaging.ImageFo rmat
                  myFormat = System.Drawing. Imaging.ImageFo rmat.Jpeg

                  myImage.Save(pa th & ".jpg", myFormat)
                  PictureBox1.Ima ge = myImage

                  ElseIf Clipboard.Conta insText() Then
                  txt = Clipboard.GetTe xt()
                  TextBox1.Text = txt

                  Else
                  Label1.Text = "Empty"
                  End If
                  End Sub


                  Next I run the program and get a .dll > Copy .dll to web folder > add the foll in source (html) of web page default.aspx :

                  <object id="myControl1 " name="myControl 1" classid="Screen Shot.dll#Screen Shot.ScreenCont rol" style="width: 572px; height: 460px">
                  </object>



                  Then add a reference to the .dll to the project


                  ... get no error but not seeing anything on the web page!!

                  Comment

                  • TRScheel
                    Recognized Expert Contributor
                    • Apr 2007
                    • 638

                    #10
                    I am curious... try

                    Clipboard.SetTe xt("This is from the clipboard")

                    then try and retrieve it. Something that small.

                    My bet is that the SetText call will throw an error.

                    If it does, please post the error. On continuation with that wager, it would have something to do with STA Thread or something similiar.

                    Comment

                    • richkid
                      New Member
                      • Apr 2007
                      • 28

                      #11
                      This is excerpts from the Windows Class that created the .dll;

                      Namespace ActiveXDotNet

                      Public Interface AxScreenCapture

                      Property Path() As String
                      Property FileName() As String

                      End Interface
                      End Namespace

                      Public Class ScreenCapture
                      'Inherits System.Windows. Forms.UserContr ol ', AxScreenCapture
                      Inherits System.Windows. Forms.UserContr ol
                      Implements ActiveXDotNet.A xScreenCapture

                      Private m_strPath As String
                      Private m_strFileName As String
                      Public strS As [String]

                      Public Property FileName() As String Implements ActiveXDotNet.A xScreenCapture. FileName
                      Get
                      Return m_strFileName
                      End Get
                      Set(ByVal value As String)
                      m_strFileName = value
                      End Set
                      End Property

                      //////////////////////////////////////////////////////////////////////////////////////////////////

                      I got the dll to work. seeing images now. Problem is to set the property on the control to a text via javascript (ex. passing a filename to property)



                      <object id="obj1" name="obj1" classid="GetIma ge.dll#GetImage .ScreenCapture" style="border-right: thin solid; border-top: thin solid; border-left: thin solid; border-bottom: thin solid; width: 480px; height: 400px;">
                      </object>
                      <input id="newButton" style="z-index: 102; left: 606px; position: absolute; top: 530px"
                      type="button" value="Click Me!!" onclick="doScri pt();"/>


                      <script type="text/javascript" >
                      function doScript()
                      {
                      obj1.FileName = "testing123 "
                      // GetImage.Screen Capture.FileNam e= "case5846"
                      }
                      </script>

                      //////////////////////////////////////////////////////////////////////////////////////////////////

                      The error message I am getting:

                      'obj1' undefined

                      Please help.

                      Comment

                      • TRScheel
                        Recognized Expert Contributor
                        • Apr 2007
                        • 638

                        #12
                        I dont profess to be a master of javascript, but I believe that you will have issues referencing obj1 directly because it is just an object, with no casting per say.

                        Comment

                        • richkid
                          New Member
                          • Apr 2007
                          • 28

                          #13
                          well finally i get this thing to show and i can now access the properties of the object using <param value>

                          I am trying to save the image on the server now i get the follow error::
                          System.Security .SecurityExcept ion:
                          Request for the permission of type 'System.Securit y.Permissions.F ileIOPermission ,mscorlib,Versi on 2.0.0.0, Culture = neutral, PublicKey Token = b77a5c561934e08 9' failed

                          any ideas?

                          Comment

                          Working...