Is there a code that can detect google's control find text 0/0 (indicating search failed to match anything)

Need Help

Hi, I've managed to zombie cobble a script that can look to see if a certain string of text appears on the screen using malcev's OCR script, then have it perform different actions based on what comes out using

  String := Clipboard

  If (Pos:=InStr(String,"example"))
    Do this,

however when i try to get the program to look at the coordinates where the 0/0 from control find appears (top right corner of the screen) it doesn't register anything.

Does anyone know of a way to get ahk to recognize that the find failed, and if it doesn't involve puting 0/0 into the clipboard, how to write the IF else statement afterwards?

separate question is does anyone know why the coordinates picture up by HBitmapFromScreen(X, Y, W, H) pictures up a much bigger area than input? only the first paragraph has some edits, everything else is straight from malcev and teadrinker

~::
hBitmap := HBitmapFromScreen(749, 360, 894, 394)
pIRandomAccessStream := HBitmapToRandomAccessStream(hBitmap)
DllCall("DeleteObject", "Ptr", hBitmap)
text := ocr(pIRandomAccessStream, "en")
MsgBox, % text
Clipboard := text
Return

HBitmapFromScreen(X, Y, W, H) 
{
   HDC := DllCall("GetDC", "Ptr", 0, "UPtr")
   HBM := DllCall("CreateCompatibleBitmap", "Ptr", HDC, "Int", W, "Int", H, "UPtr")
   PDC := DllCall("CreateCompatibleDC", "Ptr", HDC, "UPtr")
   DllCall("SelectObject", "Ptr", PDC, "Ptr", HBM)
   DllCall("BitBlt", "Ptr", PDC, "Int", 0, "Int", 0, "Int", W, "Int", H
                   , "Ptr", HDC, "Int", X, "Int", Y, "UInt", 0x00CC0020)
   DllCall("DeleteDC", "Ptr", PDC)
   DllCall("ReleaseDC", "Ptr", 0, "Ptr", HDC)
   Return HBM
}

HBitmapToRandomAccessStream(hBitmap) 
{
   static IID_IRandomAccessStream := "{905A0FE1-BC53-11DF-8C49-001E4FC686DA}"
        , IID_IPicture            := "{7BF80980-BF32-101A-8BBB-00AA00300CAB}"
        , PICTYPE_BITMAP := 1
        , BSOS_DEFAULT   := 0
        
   DllCall("Ole32\CreateStreamOnHGlobal", "Ptr", 0, "UInt", true, "PtrP", pIStream, "UInt")
   
   VarSetCapacity(PICTDESC, sz := 8 + A_PtrSize*2, 0)
   NumPut(sz, PICTDESC)
   NumPut(PICTYPE_BITMAP, PICTDESC, 4)
   NumPut(hBitmap, PICTDESC, 8)
   riid := CLSIDFromString(IID_IPicture, GUID1)
   DllCall("OleAut32\OleCreatePictureIndirect", "Ptr", &PICTDESC, "Ptr", riid, "UInt", false, "PtrP", pIPicture, "UInt")
   ; IPicture::SaveAsFile
   DllCall(NumGet(NumGet(pIPicture+0) + A_PtrSize*15), "Ptr", pIPicture, "Ptr", pIStream, "UInt", true, "UIntP", size, "UInt")
   riid := CLSIDFromString(IID_IRandomAccessStream, GUID2)
   DllCall("ShCore\CreateRandomAccessStreamOverStream", "Ptr", pIStream, "UInt", BSOS_DEFAULT, "Ptr", riid, "PtrP", pIRandomAccessStream, "UInt")
   ObjRelease(pIPicture)
   ObjRelease(pIStream)
   Return pIRandomAccessStream
}

Posted Sep 17, 2020, 12:56 AM UTC

11
axleprogramOP•

Commenting here because i'm also very interested in this, but i dont know either >.>,

I've been using a super janky variation that detects a color at a point in the mouse (the highlight color when control find is successful)

sleep 200
send, ^f
sleep 200
send, ^v
sleep 500

PixelGetColor, color, 722, 339, RGB ; checking the color at this mouse point
 If (color!=0xFFFFFF)
     ;If (color=0xFF9632 or color=0xD29632 or color=0xA39632)
{
q::

click 887, 262, 2 sleep 200

1