AutoHotkey Community

It is currently May 27th, 2012, 1:12 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1000 posts ]  Go to page Previous  1 ... 27, 28, 29, 30, 31, 32, 33 ... 67  Next
Author Message
 Post subject:
PostPosted: September 1st, 2010, 2:30 am 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
Big Digger wrote:
tic
it is possible to make this library compatible with AHK_L x64?


I'll have to take a look when I get a chance. What alterations are needed?

Lucid_Method:

In case you or anyone else is interested....super fast ImageSearch using machine code:

Code removed as it is updated later on

It runs a few thousand times faster than the ahk version I posted on the previous page and 6 times faster than the built in ImageSearch (mainly because it doesnt need to read from disk) :)


Last edited by tic on March 8th, 2011, 5:30 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 1st, 2010, 4:18 am 
Offline

Joined: July 30th, 2007, 11:32 pm
Posts: 581
tic wrote:
What alterations are needed?

Mostly:

- Change UInt to Ptr in DllCalls where applicable (including return type).
- Offset calculations in data structures.
- Add UInt to NumPut/NumGet where applicable since Ptr is the default.

Read more here.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 1st, 2010, 11:18 am 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
Thanks TheGood I'll take a look.

I have updated imagesearch code. it runs faster now (and uses stride padding):

Code:
#SingleInstance, Force
#NoEnv
SetBatchLines, -1

If !pToken := Gdip_Startup()
{
   MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
   ExitApp
}
OnExit, Exit

pBitmapHayStack := Gdip_CreateBitmapFromFile("ImageHayStack.png")
pBitmapNeedle := Gdip_CreateBitmapFromFile("ImageNeedle.png")

Width1 := Gdip_GetImageWidth(pBitmapHayStack), Height1 := Gdip_GetImageHeight(pBitmapHayStack)
Width2 := Gdip_GetImageWidth(pBitmapNeedle), Height2 := Gdip_GetImageHeight(pBitmapNeedle)
E1 := Gdip_LockBits(pBitmapHayStack, 0, 0, Width1, Height1, Stride1, Scan01)
E2 := Gdip_LockBits(pBitmapNeedle, 0, 0, Width2, Height2, Stride2, Scan02)

MCode(Gdip_ImageSearch, "83EC148B4424309983E20303C28BC88B442434995383E2035503C2C1F80256C1F902837C24"
. "30005789442420C7442410000000000F8EBE0000008B5C24288B7C24388D048D00000000894424188B442430895C241CE"
. "B098DA424000000008BFFC74424440000000085C07E6D895C24148B6C242CC7442440000000008D6424008B4C24403B4C"
. "243C0F8D8600000033C985FF7E158BD58BF38B063B02751F4183C20483C6043BCF7CEF8B442420035C2418FF44244003C"
. "003C003E8EBC38B4C24448B5C24148B4424304183C3043BC8894C2444895C24147C978B4C24108B5C241C035C2418413B"
. "4C2434894C2410895C241C0F8C68FFFFFF8B5424488B44244C5F5E5DC702FFFFFFFFC700FFFFFFFF5B83C414C38B4C244"
. "48B5424488B44244C5F495E890A8B4C24085D89085B83C414C3")

Time1 := A_TickCount
VarSetCapacity(x, 8, 0), VarSetCapacity(y, 8, 0)
Loop, 100
   DllCall(&Gdip_ImageSearch, "uint", Scan01, "uint", Scan02, "int", Width1, "int", Height1, "int", Width2, "int", Height2, "int", Stride1, "int", Stride2, "int*", x, "int*", y)
MsgBox, % "Time for 100 searches: " A_TickCount-Time1 "ms`nx: " x "`ny: " y      ;%

Gdip_UnlockBits(pBitmapHayStack), Gdip_UnlockBits(pBitmapNeedle)
Gdip_DisposeImage(pBitmapHayStack), Gdip_DisposeImage(pBitmapNeedle)
return

;#######################################################################

MCode(ByRef code, hex)
{
   VarSetCapacity(code, StrLen(hex)//2)
   Loop % StrLen(hex)//2      ;%
      NumPut("0x" SubStr(hex, 2*A_Index-1, 2), code, A_Index-1, "char")
}

;#######################################################################

CreateRect(ByRef Rect, x, y, w, h)
{
   VarSetCapacity(Rect, 16)
   NumPut(x, Rect, 0, "uint"), NumPut(y, Rect, 4, "uint"), NumPut(w, Rect, 8, "uint"), NumPut(h, Rect, 12, "uint")
}

;#######################################################################

Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, LockMode = 3, PixelFormat = 0x26200a)
{   
   CreateRect(Rect, x, y, w, h)
   VarSetCapacity(BitmapData, 21, 0)
   E := DllCall("Gdiplus\GdipBitmapLockBits", "uint", pBitmap, "uint", &Rect, "uint", LockMode, "int", PixelFormat, "uint", &BitmapData)
   Stride := NumGet(BitmapData, 8)
   Scan0 := NumGet(BitmapData, 16)
   return E
}

;#######################################################################

Gdip_UnlockBits(pBitmap)
{
   return DllCall("Gdiplus\GdipBitmapUnlockBits", "uint", pBitmap, "uint", &BitmapData)
}

;#######################################################################

Exit:
Gdip_Shutdown(pToken)
ExitApp
return


Code:
void Gdip_ImageSearch(unsigned int * HayStack, unsigned int * Needle, int w1, int h1, int w2, int h2, int Stride1, int Stride2, int * x, int * y)
{
   int tx, ty;
   int offset1 = Stride1/4, offset2 = Stride2/4;
   for (int y1 = 0; y1 < h1; ++y1)
   {
      for (int x1 = 0; x1 < w1; ++x1)
      {
         ty = y1;
         for (int y2 = 0; y2 < h2; ++y2)
         {
            tx = x1;
            for (int x2 = 0; x2 < w2; ++x2)
            {
            if (HayStack[tx+(ty*offset1)] != Needle[x2+(y2*offset2)])
               goto NoMatch;
            tx++;
            }
            ty++;
         }
         x[0] = x1-1; y[0] = y1;
         return;
         NoMatch:
            continue;
      }
   }
   x[0] = -1; y[0] = -1;
   return;
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 1st, 2010, 6:34 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
Library updated to 1.38

Thank you very much to Learning one for pointing out an incorrect version number in 1.37 and also that Gdip_SaveBitmapToFile didnt work with AHK_L and for providing very clear examples of the error


Testing out more machine code, I have also added a box blur function (obviously thanks to Laszlo for adding the ability for me to write this into ahk):

Image

The image is taken from a few pages back:

http://d.lanrentuku.com/down/png/0904/3 ... OS_002.png

Both code to save to disk or add to a gui:

Code:
#SingleInstance, Force
#NoEnv
SetBatchLines, -1

If !pToken := Gdip_Startup()
{
   MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
   ExitApp
}
OnExit, Exit

Gui, 1: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui, 1: Show, NA
hwnd1 := WinExist()

pBitmap1 := Gdip_CreateBitmapFromFile("Main_OS_002.png")
Width := Gdip_GetImageWidth(pBitmap1), Height := Gdip_GetImageHeight(pBitmap1)
pBitmap2 := Gdip_CloneBitmapArea(pBitmap1, 0, 0, Width, Height)

;hbm := CreateDIBSection(Width+20, Height+20), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
;G := Gdip_GraphicsFromHDC(hdc)
pBitmap := Gdip_CreateBitmap(Width+20, Height+20), G := Gdip_GraphicsFromImage(pBitmap)

E1 := Gdip_LockBits(pBitmap1, 0, 0, Width, Height, Stride1, Scan01)

MCode(Gdip_BoxBlurBitmap, MCode_BoxBlurBitmap())

DllCall(&Gdip_BoxBlurBitmap, "uint", Scan01, "int", Width, "int", Height, "int", Stride1, "int", 15)

Gdip_UnlockBits(pBitmap1)
Matrix = 0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.7|0|0|0|0|0|1
Gdip_DrawImage(G, pBitmap1, 20, 20, Width, Height, 0, 0, Width, Height, Matrix)
Gdip_DisposeImage(pBitmap1)

Gdip_DrawImage(G, pBitmap2, 0, 0, Width, Height, 0, 0, Width, Height)
Gdip_DisposeImage(pBitmap2)

;UpdateLayeredWindow(hwnd1, hdc, (A_ScreenWidth-Width-20)//2, (A_ScreenHeight-Height-20)//2, Width+20, Height+20)
;SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)

Gdip_SaveBitmapToFile(pBitmap, "BoxBlurShadow.png")
Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap)

OnMessage(0x201, "WM_LBUTTONDOWN")
return

;#######################################################################

MCode(ByRef code, hex)
{
   VarSetCapacity(code, StrLen(hex)//2)
   Loop % StrLen(hex)//2      ;%
      NumPut("0x" SubStr(hex, 2*A_Index-1, 2), code, A_Index-1, "char")
}

;#######################################################################

WM_LBUTTONDOWN()
{
   PostMessage, 0xA1, 2
}

;#######################################################################

CreateRect(ByRef Rect, x, y, w, h)
{
   VarSetCapacity(Rect, 16)
   NumPut(x, Rect, 0, "uint"), NumPut(y, Rect, 4, "uint"), NumPut(w, Rect, 8, "uint"), NumPut(h, Rect, 12, "uint")
}

;#######################################################################

Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, LockMode = 3, PixelFormat = 0x26200a)
{   
   CreateRect(Rect, x, y, w, h)
   VarSetCapacity(BitmapData, 21, 0)
   E := DllCall("Gdiplus\GdipBitmapLockBits", "uint", pBitmap, "uint", &Rect, "uint", LockMode, "int", PixelFormat, "uint", &BitmapData)
   Stride := NumGet(BitmapData, 8)
   Scan0 := NumGet(BitmapData, 16)
   return E
}

;#######################################################################

Gdip_UnlockBits(pBitmap)
{
   return DllCall("Gdiplus\GdipBitmapUnlockBits", "uint", pBitmap, "uint", &BitmapData)
}

;#######################################################################

MCode_BoxBlurBitmap()
{
   return "8B4C241433C083EC2C3BC80F8E4A0400008B5424385355568B7424480FAFD6578954242C894C2438EB06"
   . "8D9B000000003BD0894424280F8EFE0100008B4C244083C102894C24308B54244433ED33DB33FF33F63BD08944241489442410894424"
   . "500F8EBF0000008B4C243089542434900FB65101895424180FB6118954241C0FB651FF895424200FB651FE895424248B54241803D603"
   . "D0B856555555F7EA8BC2C1E81F03C28B54241C88410103D703542450B856555555F7EA8BC2C1E81F03C28B542420880103D303542410"
   . "B856555555F7EA8BC2C1E81F03C28B5424248841FF03D503542414B856555555F7EA8BC2C1E81F03C28841FE83C104836C2434018BC6"
   . "8B742418897C24508B7C241C895C24108B5C2420896C24148B6C24240F854CFFFFFF33C08B4C24444933ED33DB33FF33F63BC8894424"
   . "148944241089442450894C24340F8CD10000008B5424288D0C8A8B5424408D4C11028D9B000000000FB65101895424180FB611895424"
   . "1C0FB651FF895424200FB651FE895424248B54241803D603D0B856555555F7EA8BC2C1E81F03C28B54241C88410103D703542450B856"
   . "555555F7EA8BC2C1E81F03C28B542420880103D303542410B856555555F7EA8BC2C1E81F03C28B54242403D5035424148841FFB85655"
   . "5555F7EA8BC2C1E81F03C28B5424348841FE4A83E9048BC68B742418897C24508B7C241C895C24108B5C2420896C24148B6C24248954"
   . "243485D20F8D46FFFFFF33C08B4C24288B74244C8B54242C0174243003CE3BCA894C24280F8C0DFEFFFF8B7C24443BF80F8E06020000"
   . "8B4C2448490FAFCE894C24308B4C244083C102897C24348D490033ED33DB33FF33F68944242889442414894424108944245085D20F8E"
   . "C80000000FB6543101895424180FB614318954241C0FB65431FF895424200FB65431FE895424248B54241803D703D0B856555555F7EA"
   . "8BC2C1E81F03C28B54241C8844310103D303542450B856555555F7EA8BC2C1E81F03C28B54242088043103D503542410B856555555F7"
   . "EA8BC2C1E81F03C28B542424884431FF8B44242803D003542414B856555555F7EA8BC2C1E81F03C28B542428884431FE0374244C8954"
   . "24143B74242C8B5424248BC78B7C2418895C24508B5C241C896C24108B6C2420895424280F8C38FFFFFF8B74243033C033ED33DB33FF"
   . "3BF0894424288944241489442410894424500F8CCA0000008D6424000FB6543101895424180FB614318954241C0FB65431FF89542420"
   . "0FB65431FE895424248B54241803D703D0B856555555F7EA8BC2C1E81F03C28B54241C8844310103D303542450B856555555F7EA8BC2"
   . "C1E81F03C28B54242088043103D503542410B856555555F7EA8BC2C1E81F03C28B542424884431FF8B44242803D003542414B8565555"
   . "55F7EA8BC2C1E81F03C28B542428884431FE2B74244C895424148B5424248BC78B7C2418895C24508B5C241C896C24108B6C24208954"
   . "24280F893CFFFFFF33C08B54242C83C104836C2434010F8518FEFFFF8B74244C836C2438010F85D9FBFFFF5F5E5D5B83C42CC3"
}

;#######################################################################

Exit:
Gdip_Shutdown(pToken)
ExitApp
return


and c++ (it is written in a non-condensed way for speed improvements):

Code:
void Gdip_BoxBlurBitmap(unsigned char * Bitmap, int w, int h, int Stride, int Passes)
{
   int A1, R1, G1, B1, A2, R2, G2, B2, A3, R3, G3, B3;
   for (int i = 0; i < Passes; ++i)
   {
      for (int y = 0; y < h*Stride; y += Stride)
      {
         A1 = R1 = G1 = B1 = A2 = R2 = G2 = B2 = 0;
         for (int x = 0 ; x < w; ++x)
         {
            A3 = Bitmap[3+(4*x)+y];
            R3 = Bitmap[2+(4*x)+y];
            G3 = Bitmap[1+(4*x)+y];
            B3 = Bitmap[(4*x)+y];
            
            Bitmap[3+(4*x)+y] = (A1+A2+A3)/3;
            Bitmap[2+(4*x)+y] = (R1+R2+R3)/3;
            Bitmap[1+(4*x)+y] = (G1+G2+G3)/3;
            Bitmap[(4*x)+y] = (B1+B2+B3)/3;
            
            A1 = A2; R1 = R2; G1 = G2; B1 = B2; A2 = A3; R2 = R3; G2 = G3; B2 = B3;
         }

         A1 = R1 = G1 = B1 = A2 = R2 = G2 = B2 = 0;
         for (int x = w-1 ; x >= 0; --x)
         {
            A3 = Bitmap[3+(4*x)+y];
            R3 = Bitmap[2+(4*x)+y];
            G3 = Bitmap[1+(4*x)+y];
            B3 = Bitmap[(4*x)+y];
            
            Bitmap[3+(4*x)+y] = (A1+A2+A3)/3;
            Bitmap[2+(4*x)+y] = (R1+R2+R3)/3;
            Bitmap[1+(4*x)+y] = (G1+G2+G3)/3;
            Bitmap[(4*x)+y] = (B1+B2+B3)/3;
            
            A1 = A2; R1 = R2; G1 = G2; B1 = B2; A2 = A3; R2 = R3; G2 = G3; B2 = B3;
         }
      }
      
      for (int x = 0; x < w; ++x)
      {
         A1 = R1 = G1 = B1 = A2 = R2 = G2 = B2 = 0;
         for (int y = 0; y < h*Stride; y += Stride)
         {
            A3 = Bitmap[3+(4*x)+y];
            R3 = Bitmap[2+(4*x)+y];
            G3 = Bitmap[1+(4*x)+y];
            B3 = Bitmap[(4*x)+y];
            
            Bitmap[3+(4*x)+y] = (A1+A2+A3)/3;
            Bitmap[2+(4*x)+y] = (R1+R2+R3)/3;
            Bitmap[1+(4*x)+y] = (G1+G2+G3)/3;
            Bitmap[(4*x)+y] = (B1+B2+B3)/3;
            
            A1 = A2; R1 = R2; G1 = G2; B1 = B2; A2 = A3; R2 = R3; G2 = G3; B2 = B3;
         }

         A1 = R1 = G1 = B1 = A2 = R2 = G2 = B2 = 0;
         for (int y = (h-1)*Stride; y >= 0; y -= Stride)
         {
            A3 = Bitmap[3+(4*x)+y];
            R3 = Bitmap[2+(4*x)+y];
            G3 = Bitmap[1+(4*x)+y];
            B3 = Bitmap[(4*x)+y];
            
            Bitmap[3+(4*x)+y] = (A1+A2+A3)/3;
            Bitmap[2+(4*x)+y] = (R1+R2+R3)/3;
            Bitmap[1+(4*x)+y] = (G1+G2+G3)/3;
            Bitmap[(4*x)+y] = (B1+B2+B3)/3;
            
            A1 = A2; R1 = R2; G1 = G2; B1 = B2; A2 = A3; R2 = R3; G2 = G3; B2 = B3;
         }
      }
   }
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2010, 1:00 pm 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
tic wrote:
super fast ImageSearch using machine code:
Could this be done on the active window? There has to be a faster way than using the current ImageSearch command. Posibly using every odd pixel on the screen (or the image) for almost double speed.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2010, 1:34 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
Frankie wrote:
tic wrote:
super fast ImageSearch using machine code:
Could this be done on the active window? There has to be a faster way than using the current ImageSearch command. Posibly using every odd pixel on the screen (or the image) for almost double speed.


You mean to search for an existing image on disk inside the active window? using my function over the inbuilt ahk one, you would also have the possibility to search a window when it is offscreen or behind another window 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2010, 1:44 pm 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
I'm sorry, I wasn't very clear at all in my question. How do you set the haystack to the active window? Is there a way to quickly capture a window or an area of the screen and make it a bitmap for Gdi+?

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2010, 1:50 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
Code:
pBitmap := Gdip_BitmapFromHWND(hwnd)


So for example:

Code:
pBitmapNotepad := Gdip_BitmapFromHWND(WinExist("Notepad"))


Note:

Gdip_BitmapFromHWND() uses printwindow. if you dont wish to do this then use wingetpos to get the x,y,w,h of the window you wish to use and pass that to:

Code:
Gdip_BitmapFromScreen(x "|" y "|" w "|" h)


although this method wont work if the window is offscreen or covered


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2010, 2:27 pm 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Thank you, this works.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2010, 8:16 pm 
Offline

Joined: December 29th, 2009, 12:48 am
Posts: 43
Good day, ladies and gentlemen.

I'll try to spell this out as clear as possible.
I am here to ask about GDIplus's so called "GUI from image"-technique used in tutorial #3. How can I add buttons, edits, images and other GUI related stuff to GUI made from image (obviously with GDI+). That's all I want to know. :)

Thank you, be kind, give me examples (the more the better).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 9th, 2010, 1:50 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
hi ddk.....the problem with gdi+ windows is that there are no controls that can just be added. everything needs to be controlled and created by you....so any control can be created but you have to make it and handle the way it behaves. I have already shown how simple controls like buttons, labels, images can be created and handled, but more complex controls such as dropdown lists, listviews and even text fields would be hard to recreate.

here is a very old example i created of making your own buttons:

http://www.autohotkey.net/~tic/TextToGraphics.zip

there are workarounds to this if you do not wish to recreate an entire control. you can create a new gui with no margins and then "attach" it to your layered window using WM_WINDOWPOSCHANGING as you can see in my last post here:

http://www.autohotkey.com/forum/viewtopic.php?t=59924

This is quite an inelegant method, but it can save a lot of work attempting to recreate your own complex controls. I would find it quite fun to recreate my own listview controls using gdi+ in machine code but over the last week c++ compiling to unusable machine code has worn me down....


edit:

Ive also added BitmapLockBits to the library. please note that the functions are slightly different to the ones Ive been posting


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Gdi+ colormatrix
PostPosted: September 10th, 2010, 7:49 pm 
Hi tic and everyone else. The gdi+ library's a brilliant thing.

I was trying to figure out the way to use colormatrix for a long time. At last, I got it working, but I was puzzled why the example of the negative colormatrix didn't work. After some random playing with the numbers I figured out there was a tiny error in the example:

the negative matrix:
-1,0,0,0,0
0,-1,0,0,0
0,0,-1,0,0
0,0,0,1,0
1,1,1,1,1

Like I said, I found this by just fiddling around with the numbers, so I could
be wrong. That's at least how I got something close to a negative image.

I'll paste my testing code, in case it's of some amusement or use for someone.

As I'm reading this in a quiet room with my son trying to sleep, I wanted to darken the screen, so it wouldn't light up the whole little room. The following code darkens the screen drawing an overlay gui which is a screenshot (constantly refreshing itself by looping) drawn with something derived from the negative color matrix.

Code:
#Persistent
#SingleInstance force
#Include Gdip.ahk
#NoEnv

pToken := Gdip_StartUp()

W := A_ScreenWidth
H := A_ScreenHeight

;making the gui for the screenshot overlay
;0x80020 makes it click through
Gui, 1: -Caption +E0x80020 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui, 1: Show, NA

;handle for the existing gui. needed later to draw the bitmap (screenshot) on screen.
hwnd1 := WinExist()

;this was here, so if the layer isn't click through, it could be moved
;nMessage(0x201, "WM_LBUTTONDOWN")

;Tried different overlay colours with the BitBln-function and this loop.
;totally useless rave-effect ;)
/*
Loop
{
SetFormat, integer, hex
if (dir=="down")
    i--
else
    i++
if (i>=14) {
    i := 14
    dir := "down"       
}
else if (i<=1) {
    i := 1
    dir := "up"
    }
SetFormat, integer, d
*/
Loop
{
;BITMAP 1 - Screenshot
pBmp1 := Gdip_BitmapFromScreen()

;you can't handle the handle! (I almost get what the heck these do)
hbm := CreateDIBSection(w, h)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)


;I liked this layout. it's closer to the one shown
;on msdn's page.it's in a Red,Green,Blue,Alpha,Dummy -layout.
;from left to right and up to down. so the upper row is somehow
;equivalent to red, the 2nd row to green and so on.. Confusing
;to me. I'd appreciate an explanation on this.

;the last row seems to define how apparent the color matrix'
;effect is.
Matrix := "-1|0|0|0|0|"
Matrix .= "0|-1|0|0|0|"
Matrix .= "0|0|-1|0|0|"
Matrix .= "0|0|0|1|0|"
Matrix .= ".5|.5|.5|1|1"

;not sure if this is needed
Gdip_SetInterpolationMode(G, 7)

;Draw image to graphics layer with the colormatrix
Gdip_DrawImage(G, pBmp1, 0, 0, w, h, 0, 0, w, h, Matrix)

;Update the bitmap to the gui, show it's shown on screen.
UpdateLayeredWindow(hwnd1, hdc, 0, 0, w, h)

;free up memory
Gdip_DisposeImage(pBmp1)

SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
}
Gdip_ShutDown(pToken)
return

;Not used, as the gui is click through
WM_LBUTTONDOWN()
    {
    PostMessage, 0xA1, 2   
    }
;enter::
;Send, ^s
;reload
   
esc::ExitApp


In there there's some extra thingies, that I'm too lazy to erase. basicly they were for testing purposes.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2010, 7:54 pm 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Quote:
I wanted to darken the screen
Why not make a rectangle the size of the screen that is black and partialy transparent? (you may be able to do this without GDI+ fairly simply)

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2010, 8:44 pm 
That would've been too easy ;)

anyways, the win7 looks quite funky in negative. I think the black overlay would've made the contrast worse. this way I can still read the text and all perfectly.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2010, 5:45 am 
Offline

Joined: April 19th, 2010, 10:22 pm
Posts: 145
Location: Mobile, AL
Tic: I just tried out the new imagesearch code you posted - awsome! I had tweaked the first version to take coordinates to limit the search area, but the version you posted is so fast it's easier to search the whole image, great job :-) Chris should consider including this in future releases, I know there have been a number of people on the forum asking for the ability to imagesearch on a saved image. Keep up the good work!

You mentioned that this method is 6x faster than the built in ahk imagesearch, does this mean you could apply this to replace the existing imagesearch when searching the screen for the needle image? Would I need to (1) take a screen shot of the desktop then (2) use your imagesearch from the capture image?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1000 posts ]  Go to page Previous  1 ... 27, 28, 29, 30, 31, 32, 33 ... 67  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bon and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group