Jump to content

Some questions about Minimized Window


Recommended Posts

Hi,

I have some problems, the first one is How To Capture a part of a Window that isn't visible (like it's overlapped by other Windows, or Minimized)?

I've tried to search MSDN for some reference, but with no luck.. :P I came across this page. It says, I can use WM_PRINT or PrintWindow to solve the problem. But then, MSDN tells me that:

WM_PRINT:

The WM_PRINT message is sent to a window to request that it draw itself in the specified device context, most commonly in a printer device context.

PrintWindow Function:

The PrintWindow function copies a visual window into the specified device context (DC), typically a printer DC.

Well, I don't think it's what I need. I just want to grab an image, and save it to the memory, and later on, I can read it. Not to send that part of screen to any device. Maybe I'm missing something very elementary here. Can any of you guys can probably give me a push? Is there any way to do it?

-------------------------------

The second problem is, I can perform a click on a Minimize Window by using ControlClick() function. But can I create a "fake" mouse, and moving it around the (Minimized, or Visible) Window? What I mean is, I'll have 2 mice, one is controlled by me (the real one), and the other, the "fake" one, will be controlled by AutoIT. Is that even possible? I have searched, but again, failed. :P

I'm sorry if someone finds my questions to be noob. I'm pretty new to AutoIT, and have just covered some very very basic stuff of C++. And also, my major is not IT, either. :P I just code for fun. :) But well, no-one is born to know everything, right? :) I'm willing to learn something new each day. So I'll be very appreciated if you can give me some hints, or some basic examples. ;)

Thanks very much in advance. ;):P

Edited by eEniquEe
Link to comment
Share on other sites

This is going to work for your screen capture idea.

#include <ScreenCapture.au3>
$Note = "Untitled" ;<-- Name of window
_ScreenCapture_CaptureWnd (@MyDocumentsDir & "\ScreenShot.jpg", $Note)

And this is a example of a fake mouse you can control with the arrow keys. You could also disable the hot keys and just move the gui around using winmove() command for the effect you want but im not that bored. Most of this you can find in the help file its up to you to use your imagination.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
ExampleOfMouse()

Func ExampleOfMouse()
    Local $msg
    
 Global   $gui = GUICreate("test transparentpic", 8, 15)
 Global   $pic = GUICreate("", 8, 15, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui)
    GUICtrlCreatePic(@SystemDir & "\oobe\images\arrow.gif", 0, 0, 0, 0)

    GUISetState(@SW_SHOW, $pic)
    GUISetState(@SW_Hide, $gui)

    HotKeySet("{ESC}", "exitl")
    HotKeySet("{LEFT}", "left")
    HotKeySet("{RIGHT}", "right")
    HotKeySet("{DOWN}", "down")
    HotKeySet("{UP}", "up")
    $picPos = WinGetPos($pic)
    $guiPos = WinGetPos($gui)

    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example2

Func Exitl()
exit
EndFunc   ;==>exitloop

Func left()
    $picPos = WinGetPos($pic)
    WinMove($pic, "", $picPos[0] - 10, $picPos[1])
EndFunc   ;==>left

Func right()
    $picPos = WinGetPos($pic)
    WinMove($pic, "", $picPos[0] + 10, $picPos[1])
EndFunc   ;==>right

Func down()
    $picPos = WinGetPos($pic)
    WinMove($pic, "", $picPos[0], $picPos[1] + 10)
EndFunc   ;==>down

Func up()
    $picPos = WinGetPos($pic)
    WinMove($pic, "", $picPos[0], $picPos[1] - 10)
EndFunc   ;==>up
[Cheeky]Comment[/Cheeky]
Link to comment
Share on other sites

This is going to work for your screen capture idea.

#include <ScreenCapture.au3>
$Note = "Untitled" ;<-- Name of window
_ScreenCapture_CaptureWnd (@MyDocumentsDir & "\ScreenShot.jpg", $Note)
I think you've dropped out the function WinGetHandle() in the second line.. Should it read:

#include <ScreenCapture.au3>
$Note = WinGetHandle("Untitled") ;<-- Name of window
_ScreenCapture_CaptureWnd (@MyDocumentsDir & "\ScreenShot.jpg", $Note)

instead?

But even if that's the code, it still cannot capture the hidden part of the window (the overlapped part, or a minimized window). :) Are you sure it works for you? ;)

And this is a example of a fake mouse you can control with the arrow keys. You could also disable the hot keys and just move the gui around using winmove() command for the effect you want but im not that bored. Most of this you can find in the help file its up to you to use your imagination.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
ExampleOfMouse()

Func ExampleOfMouse()
    Local $msg
    
 Global   $gui = GUICreate("test transparentpic", 8, 15)
 Global   $pic = GUICreate("", 8, 15, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui)
    GUICtrlCreatePic(@SystemDir & "\oobe\images\arrow.gif", 0, 0, 0, 0)

    GUISetState(@SW_SHOW, $pic)
    GUISetState(@SW_Hide, $gui)

    HotKeySet("{ESC}", "exitl")
    HotKeySet("{LEFT}", "left")
    HotKeySet("{RIGHT}", "right")
    HotKeySet("{DOWN}", "down")
    HotKeySet("{UP}", "up")
    $picPos = WinGetPos($pic)
    $guiPos = WinGetPos($gui)

    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example2

Func Exitl()
exit
EndFunc   ;==>exitloop

Func left()
    $picPos = WinGetPos($pic)
    WinMove($pic, "", $picPos[0] - 10, $picPos[1])
EndFunc   ;==>left

Func right()
    $picPos = WinGetPos($pic)
    WinMove($pic, "", $picPos[0] + 10, $picPos[1])
EndFunc   ;==>right

Func down()
    $picPos = WinGetPos($pic)
    WinMove($pic, "", $picPos[0], $picPos[1] + 10)
EndFunc   ;==>down

Func up()
    $picPos = WinGetPos($pic)
    WinMove($pic, "", $picPos[0], $picPos[1] - 10)
EndFunc   ;==>up

I'm very sorry for not being clear. ;)

What I tend to code is not a totally "fake" mouse; it's "fake", but it does have all the properties of a real mouse does. Well, I'll try to describe what I mean a little bit clearer.

Say, if you hover the real mouse over some button in this forum, that button will change color, right? But if that's a "fake" mouse, made up by some GUI, then nothing'll happen, when it's over the button. i.e, I want the Window to recognize the "fake" mouse as a mouse too, although it's just some extra mouse, and it'll disappear as I close my programme. Is there any algorithm to do it? :P

Thanks. :)

Edited by eEniquEe
Link to comment
Share on other sites

This is true.. is there a reason you cant use a WinActivate? Then capture then hide?

Well, I just want to improve my script a little bit. It can now run properly, when the Window is totally visual. But it's not very convenient, because I must have that Window to be on top all the times, and it takes up like 1/3 of the whole screen, so I can barely do any other tasks.

I just want to make that Window run in the background, so I don't have to AFK every time I run the script. :)

---------------------

About my second problem, the "fake mouse" one. The ControlSend() function can send a string to a Minimized Window, the ControlClick() function, can perform a moseclick to a Minimize/Overlapped Window, without moving my mouse. So I wonder if there's anything like a ControlMouseMove() function around there? :-?

Edited by eEniquEe
Link to comment
Share on other sites

Bump.. Can anybody help me pls.. :)

I'm finding another way round the first problem, since I don't think capturing overlapped/hidden part of a Window is really possible. But how about the second problem? Does it exist some command, which is the same as ControlClick() but instead of clicking, it'll generate a moving of the mouse?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...