• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

[XAP] Screen capture program (Based on "The DllImport Project")

Search This thread

fiinix

Retired Recognized Developer
Oct 9, 2010
570
224
28
Stockholm
WP7 Screen capture program
[OBSOLETE, INSTEAD USE Screen Capturer v3]


Program structure

At application start Jaxbot's dehydrate hack, its enabled automatic by setting some registry values (that enables sort of multitasking). So that you can just run this app, go to home, enter the wanted app of you choice that you want to capture.

Brief info about how this app has functionality to take captures.: Uses The DllImport Project to talk to the system that enables C# code to call C++ for me.

The app is actually only an infinitive loop that listen for [Focus]-key.
As you can see below, a Sleep is enabled of 500ms to spare your battery so that is does not spam the system cpu with a while loop that runs forever, draining your battery fast.

Code:
public static void StartHook()
{
    Phone.Screen.init();

    bw = new BackgroundWorker();
    bw.DoWork += bw_DoWork;
    bw.RunWorkerAsync();
}

static void bw_DoWork(object sender, DoWorkEventArgs e)
{
    int key = (int)Phone.KeyboardHook.PhysicalKeys.Focus;
    while (true)
    {
        if (DllImportCaller.lib.GetAsyncKeyState7(key) != 0)
        {
            Phone.Screen.Capture cap = Phone.Screen.CaptureScreenToPictures();

            var str = string.Format("PictureName: {0}\nTimeElapsed: {1}ms\nPictureByteSize: {2}", 
                cap.PictureName, cap.TimeElapsed.TotalMilliseconds, cap.PictureByteSize);

            int res;
            DllImportCaller.lib.MessageBox7(str, "Screen Capture", (uint)MB.MB_OK, out res);
        }
        System.Threading.Thread.Sleep(500);
    }
}

In App instructions (Web)

[Checkbox] Jaxbot' Dehydrate hack (On / Off)
- This is for yourself, so you can toggle the "multitask" after capturing the app.
- Automatic activate on app launch (this)

"How to":
- Enter this app

- Navigate to the app you want to capture (no more than 2 apps in between (this app will be killed by "Watchdog"))

- Hold "focus" (not click, >focus), for at least 500ms
- Wait for messagebox to verify capture
- (SUCCESS) > Located under "Pictures > All > Saved Pictures"



Extras comments by me

(100% Verified to work (on mine lol))
Test pictures made at the moment: 460!

Fixed-list

- (1.0.1) Collision with real "Dll Import" when the guids are the same
- (1.0.2) GUI + Standalone + No collision with overwrite whats so ever (Same GUID)
- (1.0.3) "In-app dehydration toggler" + "better experience", EPIC release
- (1.0.4) Fail-safe, for sure no more multiple capture bug (2-4). (Test: I Can hold focus for 1 min and only one is captured).
- (1.0.4.0.0.0.1) For some random reason without debugger it took 1-6 captures, but WITH the debugger i could hold it for a minute and only one would be captured. Fixed now with a "Sleep()" to prevent 1+.
- (1.0.5) Now, problem with 2 msg box are 100000% GONE NOW! Ill pay you money else if 2 come up lol, jk :)
> Problem was located in "CSharp___DllImport.MainPage(); .ctor" that ALSO hooked to key-press.
- (1.0.5, HD2 edition) Now supports HD2, works now because its binded to "Search" instead of "Focus" -button; Aka "Search version".

Thanks for my time :)
 

Attachments

  • Photo_EBE40C6E-B593-544A-64EC-74C13AF15A08.jpg
    Photo_EBE40C6E-B593-544A-64EC-74C13AF15A08.jpg
    46.6 KB · Views: 6,940
Last edited:

Heathcliff74

Inactive Recognized Developer
Dec 1, 2010
1,646
2,609
Thanks!

Feature request: disable / enable dehydration from within the app. Maybe an option to automatically reenable dehydration after the screenshot. I don't want to leave dehydration on, because of performance and batterylife.

Well done!
Heathcliff74
 

fiinix

Retired Recognized Developer
Oct 9, 2010
570
224
28
Stockholm
Thanks!

Feature request: disable / enable dehydration from within the app. Maybe an option to automatically reenable dehydration after the screenshot. I don't want to leave dehydration on, because of performance and batterylife.

Well done!
Heathcliff74
Is there a good cross device that can toggle dehydrate? Because of how i see it its device specific (root access). Is there a basic lib out there that i know exist somewhere, ill implent it.
Thanks for criticism :)
 

Heathcliff74

Inactive Recognized Developer
Dec 1, 2010
1,646
2,609
Is there a good cross device that can toggle dehydrate? Because of how i see it its device specific (root access). Is there a basic lib out there that i know exist somewhere, ill implent it.
Thanks for criticism :)

I'm not sure, but I believe the registry value that needs to be set can be changed with the normal registry api (no root access required). I could be wrong though. If it doesn't work, then the COM dll's from Samsung and HTC will work for sure. But you need to add the COM dll's for all the different brands and they have different interfaces. It isn't too hard though.

By the way, the criticism was meant as "constructive criticism" ;) I appreciate your work.

Ciao,
Heathcliff74
 

fiinix

Retired Recognized Developer
Oct 9, 2010
570
224
28
Stockholm
I'm not sure, but I believe the registry value that needs to be set can be changed with the normal registry api (no root access required). I could be wrong though. If it doesn't work, then the COM dll's from Samsung and HTC will work for sure. But you need to add the COM dll's for all the different brands and they have different interfaces. It isn't too hard though.

By the way, the criticism was meant as "constructive criticism" ;) I appreciate your work.

Ciao,
Heathcliff74
Yep thats what i tried to say, "constructive criticism", forgot how to call if fully out :)
 

contable

Senior Member
Oct 25, 2009
1,755
996
Also working fine on my OMNIA 7. I can enable/disable dehydration with advanced config tool on both devices.

@Heathcliff:

After testing the HD7 for some weeks now I decided to go back to the OMNIA 7 when you have finished your work. The HD7 isn´t nearly as good as the OMNIA 7 but atm the best choice if you wanna do some customizations...
 

noelito

Senior Member
Mar 26, 2009
559
26
It is buggy but works! That's the important thing, thank you so much! Keep up the great work!

Sent from my HD7 using XDA Windows Phone 7 App
 

Top Liked Posts

  • There are no posts matching your filters.
  • 35
    WP7 Screen capture program
    [OBSOLETE, INSTEAD USE Screen Capturer v3]


    Program structure

    At application start Jaxbot's dehydrate hack, its enabled automatic by setting some registry values (that enables sort of multitasking). So that you can just run this app, go to home, enter the wanted app of you choice that you want to capture.

    Brief info about how this app has functionality to take captures.: Uses The DllImport Project to talk to the system that enables C# code to call C++ for me.

    The app is actually only an infinitive loop that listen for [Focus]-key.
    As you can see below, a Sleep is enabled of 500ms to spare your battery so that is does not spam the system cpu with a while loop that runs forever, draining your battery fast.

    Code:
    public static void StartHook()
    {
        Phone.Screen.init();
    
        bw = new BackgroundWorker();
        bw.DoWork += bw_DoWork;
        bw.RunWorkerAsync();
    }
    
    static void bw_DoWork(object sender, DoWorkEventArgs e)
    {
        int key = (int)Phone.KeyboardHook.PhysicalKeys.Focus;
        while (true)
        {
            if (DllImportCaller.lib.GetAsyncKeyState7(key) != 0)
            {
                Phone.Screen.Capture cap = Phone.Screen.CaptureScreenToPictures();
    
                var str = string.Format("PictureName: {0}\nTimeElapsed: {1}ms\nPictureByteSize: {2}", 
                    cap.PictureName, cap.TimeElapsed.TotalMilliseconds, cap.PictureByteSize);
    
                int res;
                DllImportCaller.lib.MessageBox7(str, "Screen Capture", (uint)MB.MB_OK, out res);
            }
            System.Threading.Thread.Sleep(500);
        }
    }

    In App instructions (Web)

    [Checkbox] Jaxbot' Dehydrate hack (On / Off)
    - This is for yourself, so you can toggle the "multitask" after capturing the app.
    - Automatic activate on app launch (this)

    "How to":
    - Enter this app

    - Navigate to the app you want to capture (no more than 2 apps in between (this app will be killed by "Watchdog"))

    - Hold "focus" (not click, >focus), for at least 500ms
    - Wait for messagebox to verify capture
    - (SUCCESS) > Located under "Pictures > All > Saved Pictures"



    Extras comments by me

    (100% Verified to work (on mine lol))
    Test pictures made at the moment: 460!

    Fixed-list

    - (1.0.1) Collision with real "Dll Import" when the guids are the same
    - (1.0.2) GUI + Standalone + No collision with overwrite whats so ever (Same GUID)
    - (1.0.3) "In-app dehydration toggler" + "better experience", EPIC release
    - (1.0.4) Fail-safe, for sure no more multiple capture bug (2-4). (Test: I Can hold focus for 1 min and only one is captured).
    - (1.0.4.0.0.0.1) For some random reason without debugger it took 1-6 captures, but WITH the debugger i could hold it for a minute and only one would be captured. Fixed now with a "Sleep()" to prevent 1+.
    - (1.0.5) Now, problem with 2 msg box are 100000% GONE NOW! Ill pay you money else if 2 come up lol, jk :)
    > Problem was located in "CSharp___DllImport.MainPage(); .ctor" that ALSO hooked to key-press.
    - (1.0.5, HD2 edition) Now supports HD2, works now because its binded to "Search" instead of "Focus" -button; Aka "Search version".

    Thanks for my time :)
    2
    Fantastic ! Thanks for this app. Confirmed working on my HD7.

    Attached some screenies.
    2
    FML when my face did mfw.

    > Problem was located in "CSharp___DllImport.MainPage(); .ctor" that ALSO hooked to key-press.

    "CSharp___DllImport.MainPage.This = new CSharp___DllImport.MainPage();"

    Update 1.0.5 where NO chance of multi capture problem.
    Also a new ico made by a friend :)
    1
    Thanks for the update. :) But...

    Now stay the "PhoneRestartApp" again on my Mozart, but the "BatteryStatusApp" flay a way. ;( ;)
    if you're having problems with the batteryStatusApp, try this one instead:

    Newer battery app
    1
    @fiinix:

    The latest version isn´t working well on my HD7:
    when I press the focus button the message box always appears 2 times.

    Any chance to fix this ?