Jump to content

3x3 grid


Recommended Posts

hello to all,

i'm here with 3x3 grid question again.

Change need from first request, but take some code for a new script.

post script that draw little trasparent 3x3 grid on screen:

Opt('MustDeclareVars', 1)

Global $GuiW = 120, $GuiH = 120

Example()

Func Example()
    Local $msg, $hGui, $aMPos, $XSquare, $YSquare, $aWinPos
    $hGui = GUICreate("My Main", $GuiW, $GuiH, -1, -1, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
    WinSetTrans("My Main", "", 40)
    GUICtrlCreateGraphic(0, 0, $GuiW, $GuiH)
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $GuiH / 3)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, $GuiW, $GuiH / 3)
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $GuiH * 2 / 3)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, $GuiW, $GuiH * 2 / 3)
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $GuiW / 3, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, $GuiW / 3, $GuiH)
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $GuiW * 2 / 3, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, $GuiW * 2 / 3, $GuiH)
    GUISetState()
    Opt("MouseCoordMode", 2);1=absolute, 0=relative, 2=client
   
    Do
        Local $sWinRect = _WinAPI_GetWindowRect(WinGetHandle("My Main"))
        Local $MP = _WinAPI_GetMousePos()
        If _WinAPI_PtInRect($sWinRect, $MP) Then
            $aMPos = MouseGetPos()
            $XSquare = Int($aMPos[0] / ($GuiW / 3)) + 1 ; ($GuiW / 3) = Width of each square
            $YSquare = Int($aMPos[1] / ($GuiH / 3))  ; ($GuiH / 3) = Height of each square
            $aWinPos = WinGetPos("My Main")
            ToolTip("Square Number: " & $XSquare + $YSquare * 3, $aMPos[0] + $aWinPos[0] + 15, $aMPos[1] + $aWinPos[1] + 5)
        EndIf
        $msg = GUIGetMsg()
        Sleep(10)
    Until $msg = $GUI_EVENT_CLOSE
EndFunc  ;==>Example

I need trasparent 3x3 grid, capable to change color on single square when event occours

(eg: when i press keypad 7, only up-left square change color)

Any idea ?

m.

Link to comment
Share on other sites

some step forward but too flikering :

#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#include <misc.au3>
#include <ScreenCapture.au3>
 
Const $DIB_RGB_COLORS = 0
Global $GUI, $CopyWin, $PixelArray, $CopyWin, $e, $d, $PixelsReady = 0, $Start = 0
Global Const $WM_LBUTTONDOWN = 0x0201; Drag Window 1 of 3 addin

While Not _IsPressed("1B");Esc to Exit
            if _IsPressed("67") Then
                GUISetState(@SW_hide, $GUI)
                $GUI = GUICreate("Right_Pad_selector", 18, 18, 200, -1, BitOR($WS_POPUP, $WS_CLIPCHILDREN), $WS_EX_TOPMOST)
                WinSetTrans("Right_Pad_selector", "", 100)
                GUISetState(@SW_SHOW, $GUI)
            elseif  _IsPressed("68") Then
                GUISetState(@SW_hide, $GUI)
                $GUI = GUICreate("Right_Pad_selector", 18, 18, 230, -1, BitOR($WS_POPUP, $WS_CLIPCHILDREN), $WS_EX_TOPMOST)
                WinSetTrans("Right_Pad_selector", "", 100)
                GUISetState(@SW_SHOW, $GUI)
            elseif  _IsPressed("69") Then
                GUISetState(@SW_hide, $GUI)
                $GUI = GUICreate("Right_Pad_selector", 18, 18, 260, -1, BitOR($WS_POPUP, $WS_CLIPCHILDREN), $WS_EX_TOPMOST)
                WinSetTrans("Right_Pad_selector", "", 100)
                GUISetState(@SW_SHOW, $GUI)
            EndIf
            
            $CopyWin = WinGetPos("Right_Pad_selector")

            Sleep(10)
 
    Sleep(10)
WEnd

;Return :   $GuisInfo[0] = Window Text
;        $GuisInfo[1] = Class Name
;        $GuisInfo[2] = Handle of windowWnd
;        $GuisInfo[3] = Owner Class Name
;        $GuisInfo[4] = Handle of Owner Window
; A modified Siao Function
Func _WinInfoFromPoint($nX, $nY)
    Local $tStrBuff, $pStrBuff, $aRet, $hWnd, $Info[5]
    $tStrBuff = DllStructCreate("char[150]")
    $pStrBuff = DllStructGetPtr($tStrBuff)
    $aRet = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", $nX, "uint", $nY)
    $Info[2] = $aRet[0];$hWnd
    $aRet = DllCall("user32.dll", "int", "GetClassName", "hwnd", $Info[2], "ptr", $pStrBuff, "int", 100)
    $Info[1] = DllStructGetData($tStrBuff, 1); ClassName
    DllStructSetData($tStrBuff, 1, "")
    DllCall("user32.dll", "int", "GetWindowText", "hwnd", $Info[2], "ptr", $pStrBuff, "int", 100)
    $Info[0] = DllStructGetData($tStrBuff, 1); Window Text
    DllStructSetData($tStrBuff, 1, "")
    $aRet = DllCall("user32.dll", "hwnd", "GetAncestor", "hwnd", $Info[2], "uint", 2);$GA_ROOT = 2
    $Info[4] = $aRet[0]; Handle of Owner Window
    $aRet = DllCall("user32.dll", "int", "GetClassName", "hwnd", $Info[4], "ptr", $pStrBuff, "int", 100)
    $Info[3] = DllStructGetData($tStrBuff, 1);Owner ClassName
    DllStructSetData($tStrBuff, 1, "")
   ;ConsoleWrite("text= " &$Info[0] & @CRLF)
    Return $Info
EndFunc  ;==>_WinInfoFromPoint

Press 7 8 9 from keypad to draw first 3 of 9 little trasparent windows,

m.

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...