Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/15/2015 in all areas

  1. Code updated: work fine (until now) with arrays. ;~ https://en.wikipedia.org/wiki/Connected-component_labeling ;~ #AutoIt3Wrapper_AU3Check_Parameters= -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ;~ #Tidy_Parameters=/sf #include-once #include <WinAPI.au3> #include <Array.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <object_dump.au3> OnAutoItExitRegister("_on_exit") Opt("GUIOnEventMode", 1) Opt("GUIEventOptions", 1) Opt("MustDeclareVars", 1) Global Const $SEP = "#" Global $aGuiSize[2] = [800, 600] Global $sGuiTitle = "GuiTitle" Global $hGui Global $ax[2], $ay[2] Global $iSize = 32 Global $ALL[1][5] = [[0]] Global $iChield, $aPos Global $POS, $iNext, $iSearch, $color ; grid or image ; 0 is transparency ; non-zero (value does not matter) is any color Global $aGrid[][12] = [ _ [0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0], _ [0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1], _ [0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0], _ [0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0], _ [1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0], _ [0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], _ [0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1], _ [0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1], _ [0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0], _ [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0] _ ] ; array to analise Global $aMax[4] = [UBound($aGrid, 1), UBound($aGrid, 2)] $aMax[2] = $aMax[0] - 1 $aMax[3] = $aMax[1] - 1 Global $hArr[$aMax[0]][$aMax[1]] $hGui = GUICreate($sGuiTitle, $aGuiSize[0], $aGuiSize[1]) GUISetOnEvent($GUI_EVENT_CLOSE, "_quit") GUISetState(@SW_SHOW, $hGui) For $LIN = 0 To $aMax[2] For $COL = 0 To $aMax[3] $hArr[$LIN][$COL] = GUICtrlCreateLabel($aGrid[$LIN][$COL], $iSize + $COL * $iSize, $iSize + $LIN * $iSize, $iSize, $iSize, BitOR($SS_SUNKEN, $SS_CENTER)) $color = Color() GUICtrlSetBkColor($hArr[$LIN][$COL], $aGrid[$LIN][$COL] ? $color : 0xFFFFCC) GUICtrlSetTip($hArr[$LIN][$COL], $LIN & "," & $COL) If $aGrid[$LIN][$COL] Then Populate($ALL, $LIN, $COL, $LIN & $SEP & $COL, $color) Next Next Colorate() ;~ _ArrayDisplay($ALL, "Neighbors pixels", 0, 0, Default, "$LIN|$COL|$POS|$COLOR|$parent") Func Populate(ByRef $aInput, $LIN, $COL, $POS, $color, $parent = 0) $iSearch = _ArraySearch($ALL, $POS, 1, Default, 0, 0, 2, 2) Local $viz If Not @error Then Return $LIN = Number($LIN) $COL = Number($COL) If $parent Then Local $iRedim = UBound($aInput, 1) ReDim $aInput[$iRedim + 1][5] $aInput[0][0] = $iRedim $aInput[$iRedim][0] = $LIN $aInput[$iRedim][1] = $COL $aInput[$iRedim][2] = $POS $aInput[$iRedim][3] = $color $aInput[$iRedim][4] = $parent $viz = __GetNeighbor($aGrid, $LIN, $COL) For $ii = 1 To $viz[0] $aPos = StringSplit($viz[$ii], $SEP, 2) Populate($ALL, $aPos[0], $aPos[1], $viz[$ii], $color, $parent) Next Else Local $iRedim = UBound($aInput, 1) ReDim $aInput[$iRedim + 1][5] $aInput[0][0] = $iRedim $aInput[$iRedim][0] = $LIN $aInput[$iRedim][1] = $COL $aInput[$iRedim][2] = $POS $aInput[$iRedim][3] = $color $aInput[$iRedim][4] = $iRedim $viz = __GetNeighbor($aGrid, $LIN, $COL) If $viz[0] >= 1 Then For $ii = 1 To $viz[0] $aPos = StringSplit($viz[$ii], $SEP, 2) Populate($ALL, $aPos[0], $aPos[1], $viz[$ii], $color, $iRedim) Next EndIf EndIf Return $iRedim EndFunc ;==>Populate Func Colorate() For $ii = 1 To $ALL[0][0] If Not ($ii = $ALL[$ii][4]) Then GUICtrlSetBkColor($hArr[$ALL[$ii][0]][$ALL[$ii][1]], $ALL[$ii][3]) EndIf Next EndFunc ;==>Colorate While Sleep(25) WEnd Func _on_exit() GUISetState($hGui, @SW_HIDE) GUIDelete($hGui) EndFunc ;==>_on_exit Func _quit() Exit EndFunc ;==>_quit Func __GetNeighbor($aInput, $LIN, $COL) Local $aRet[1] = [0] $ax[0] = $LIN - 1 $ax[0] = $ax[0] < 0 ? 0 : $ax[0] $ax[1] = $LIN + 1 $ax[1] = $ax[1] > UBound($aInput, 1) - 1 ? UBound($aInput, 1) - 1 : $ax[1] $ay[0] = $COL - 1 $ay[0] = $ay[0] < 0 ? 0 : $ay[0] $ay[1] = $COL + 1 $ay[1] = $ay[1] > UBound($aInput, 2) - 1 ? UBound($aInput, 2) - 1 : $ay[1] For $yy = $ax[0] To $ax[1] For $xx = $ay[0] To $ay[1] If $aInput[$yy][$xx] And Not ($yy = $LIN And $xx = $COL) Then _ArrayAdd($aRet, $yy & $SEP & $xx) Next Next If UBound($aRet, 1) - 1 > 0 Then $aRet[0] = UBound($aRet, 1) - 1 ;~ If $LIN = 3 And $COL = 7 Then _ArrayDisplay($aRet) Return $aRet EndFunc ;==>__GetNeighbor Func Color() Return "0x" & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) EndFunc ;==>Color
    1 point
  2. Please change the following line and give it a try: Global Const $iOptions = 512 ; adCmdTableDirect - Return all rows from the specified table
    1 point
  3. The dot means 'any char', so the regex engine begins to read the text, finds the first <source src=", then grabs all - including the next <source src=" which can be matched by the dot - up to 'mp3' Being selective using [^"] make it fail when after <source src=" it encounters a quote, so it captures nothing and then goes on, finds the next <source src=" etc
    1 point
  4. Hum sorry I was not awake enough... The regex needs to be more selective "keep all non-quote chars..." '<source src="([^"]+mp3)'It can be even more selective using '<source src="([/\w.]+mp3)'= Keep all chars which are only a slash, or a dot, or a word char up to 'mp3' included
    1 point
  5. Here is an example The easier way is to choose 'mp3' as end mark for the part to match, while including it in the capture group $s = '<source src="//wowimg.zamimg.com/hearthhead/sounds/VO_EX1_298_Play_01.ogg" type="audio/ogg; codecs=&quot;vorbis&quot;">' & @crlf & _ '<source src="//wowimg.zamimg.com/hearthhead/sounds/VO_EX1_134_Attack_02.mp3" type="audio/mpeg">' $res = StringRegExp($s, '(?s)<source src="(.*?mp3)', 3) msgbox(0,"", $res[0])=> Keep all chars after a ' <source src=" ', up to a sequence 'mp3', included If you don't make the .*? lazy, you will get all chars between the first <source src=" and 'mp3'
    1 point
  6. I was thinking why not use collision detection so a wrote this: #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <APISysConstants.au3> #include <WinAPI.au3> #include <GUIMenu.au3> #include <WinAPIProc.au3> #include <WinAPISys.au3> #include <Array.au3> ; https://www.autoitscript.com/forum/topic/164271-detect-when-any-and-all-windows-have-moved/?do=findComment&comment=1198129 Global $hEventProc = DllCallbackRegister(_EventProc, "none", "ptr;dword;hwnd;long;long;dword;dword") Global $hEventHook = _WinAPI_SetWinEventHook($EVENT_MIN, $EVENT_MAX, DllCallbackGetPtr($hEventProc)) OnAutoItExitRegister(OnAutoItExit) ; clear the hook on exit Global $hMainWin = GUICreate('My main GUI', 400, 400, 50, 50) GUISetState(@SW_SHOW) $hGUI_Child0 = GUICreate('hand', 100, 100, 10, 0, $WS_POPUPWINDOW, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)) $aHostDim = WinGetClientSize($hGUI_Child0) ; a 2-element array containing Width and Height of window's client area (inner area excluding borders). GUICtrlCreatePic("", 0, 0, $aHostDim[0], $aHostDim[1], -1, $GUI_WS_EX_PARENTDRAG) ; this allow dragging of the "card" by click on "card" and drag. GUICtrlCreateIcon("shell32.dll", 29, 0, 0, $aHostDim[0], $aHostDim[1]) ; put something to see on the card GUISetState(@SW_SHOW, $hGUI_Child0) _WinAPI_SetParent($hGUI_Child0, $hMainWin) ; trap this child gui within the main gui ; $hGUI_Child1 = GUICreate('tree', 100, 100, 25, 15, $WS_POPUPWINDOW, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)) $aHostDim = WinGetClientSize($hGUI_Child1) GUICtrlCreatePic("", 0, 0, $aHostDim[0], $aHostDim[1], -1, $GUI_WS_EX_PARENTDRAG) GUICtrlCreateIcon("shell32.dll", 42, 0, 0, $aHostDim[0], $aHostDim[1]) GUISetState(@SW_SHOW, $hGUI_Child1) _WinAPI_SetParent($hGUI_Child1, $hMainWin) ; $hGUI_Child2 = GUICreate('star', 100, 100, 40, 30, $WS_POPUPWINDOW, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)) GUICtrlCreatePic("", 0, 0, $aHostDim[0], $aHostDim[1], -1, $GUI_WS_EX_PARENTDRAG) GUICtrlCreateIcon("shell32.dll", 44, 0, 0, $aHostDim[0], $aHostDim[1]) GUISetState(@SW_SHOW, $hGUI_Child2) _WinAPI_SetParent($hGUI_Child2, $hMainWin) $hGUI_Child3 = GUICreate('folder', 100, 100, 55, 45, $WS_POPUPWINDOW, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)) GUICtrlCreatePic("", 0, 0, $aHostDim[0], $aHostDim[1], -1, $GUI_WS_EX_PARENTDRAG) GUICtrlCreateIcon("shell32.dll", 39, 0, 0, $aHostDim[0], $aHostDim[1]) GUISetState(@SW_SHOW, $hGUI_Child3) _WinAPI_SetParent($hGUI_Child3, $hMainWin) $hGUI_Child4 = GUICreate('key', 100, 100, 70, 60, $WS_POPUPWINDOW, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)) GUICtrlCreatePic("", 0, 0, $aHostDim[0], $aHostDim[1], -1, $GUI_WS_EX_PARENTDRAG) GUICtrlCreateIcon("shell32.dll", 45, 0, 0, $aHostDim[0], $aHostDim[1]) GUISetState(@SW_SHOW, $hGUI_Child4) _WinAPI_SetParent($hGUI_Child4, $hMainWin) $hGUI_Child5 = GUICreate('locker', 100, 100, 85, 75, $WS_POPUPWINDOW, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)) GUICtrlCreatePic("", 0, 0, $aHostDim[0], $aHostDim[1], -1, $GUI_WS_EX_PARENTDRAG) GUICtrlCreateIcon("shell32.dll", 48, 0, 0, $aHostDim[0], $aHostDim[1]) GUISetState(@SW_SHOW, $hGUI_Child5) _WinAPI_SetParent($hGUI_Child5, $hMainWin) MsgBox(0, "Pause", "Drag images on the Main GUI" & @CRLF & "Click OK to end") Func _EventProc($hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadId, $iEventTime) #forceref $hEventHook, $iObjectID, $iChildID, $iThreadId, $iEventTime ; Static $lastevent ; https://msdn.microsoft.com/en-us/library/windows/desktop/dd318066(v=vs.85).aspx Local $aAllChildWindows = 0 Local $aChildWindows = 0 Local $sWindows = "" Switch $iEvent Case $EVENT_SYSTEM_MOVESIZESTART ; ConsoleWrite("Start:" & @TAB & $iEvent & @TAB & $hWnd & @TAB & $iObjectID & @TAB & $iChildID & @CRLF) Case $EVENT_SYSTEM_MOVESIZEEND ; to be used as drop If _WinAPI_GetAncestor($hWnd) = $hMainWin Then $aAllChildWindows = _WinAPI_EnumChildWindows($hMainWin) $aChildWindows = _GetJustChildWindow($aAllChildWindows, $hMainWin, $hWnd) If IsArray($aChildWindows) Then $sWindows = _GetWindowBycollision($aChildWindows, $hWnd) ConsoleWrite(WinGetTitle($hWnd) & " dropped on " & $sWindows & @CRLF) EndIf EndIf Case Else #cs If $iEvent <> $lastevent Then ConsoleWrite("event:" & @TAB & $iEvent & @CRLF) $lastevent = $iEvent #ce EndIf EndSwitch EndFunc ;==>_EventProc Func _GetWindowBycollision($aWindow, $hWinMoving) Local $aWin1 = WinGetPos($hWinMoving) Local $aWin2 = 0 Local $sWindows = "" For $i = 0 To UBound($aWindow) - 1 $aWin2 = WinGetPos($aWindow[$i]) If $aWin1[0] < $aWin2[0] + $aWin2[2] And $aWin1[0] + $aWin1[2] > $aWin2[0] And $aWin1[1] < $aWin2[1] + $aWin2[3] And $aWin1[3] + $aWin1[1] > $aWin2[1] Then $sWindows &= (($sWindows <> "") ? ", " : "") & WinGetTitle($aWindow[$i]) EndIf Next If $sWindows = "" Then $sWindows = WinGetTitle($hMainWin) if StringInStr($sWindows,",",0,-1) Then $sWindows=StringReplace($sWindows,StringMid($sWindows,StringInStr($sWindows,",",0,-1))," and" & StringMid($sWindows,StringInStr($sWindows,",",0,-1)+1)) EndIf Return $sWindows EndFunc ;==>_GetWindowBycollision Func _GetJustChildWindow($aArray, $hParentWindow, $hWinToAvoid) Local $aNewArray[0] If IsArray($aArray) Then For $i = 1 To $aArray[0][0] If $aArray[$i][1] = _WinAPI_GetClassName($hParentWindow) And $hWinToAvoid <> $aArray[$i][0] Then ReDim $aNewArray[UBound($aNewArray) + 1] $aNewArray[UBound($aNewArray) - 1] = $aArray[$i][0] ConsoleWrite($i & $aNewArray[UBound($aNewArray) - 1] & @CRLF) EndIf Next Return $aNewArray EndIf Return 0 EndFunc ;==>_GetJustChildWindow Func OnAutoItExit() _WinAPI_UnhookWinEvent($hEventHook) DllCallbackFree($hEventProc) EndFunc ;==>OnAutoItExit Saludos
    1 point
  7. Not sure if I am getting it right. Wouldn't this be just a https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_WindowFromPoint.htm Then define what the definition is of dropping a card on another one. 1. Its the mouse cursor position where you release the moved card 2. Its any of the boundarypoints of the moved card 3. ...... and maybe this gives another solution direction it looks easy over here ;-) but to difficult for me https://msdn.microsoft.com/en-us/library/windows/desktop/ms678405(v=vs.85).aspx
    1 point
  8. You can try this Case $EVENT_SYSTEM_MOVESIZEEND ; to be used as drop If _WinAPI_GetAncestor($hWnd) = $hMainWin Then Local $hTop = _WinAPI_GetWindow($hMainWin, $GW_CHILD) Local $hNext = _WinAPI_GetWindow ($hTop, $GW_HWNDNEXT) ConsoleWrite(WinGetTitle($hTop) & " dropped on " & WinGetTitle($hNext) & @CRLF) EndIf But it will only display the next on z order!
    1 point
  9. Maybe you can use something like this. It might be necessary to exclude the window being dragged from the list. #include <misc.au3> HotKeySet("{ESC}", "_Exit") Local $aMousePos, $_hWnd_OnPos While 1 Sleep(10) If _IsPressed("01") Then $aMousePos = MouseGetPos() $_hWnd_OnPos = _hWnd_Visible_AtPos($aMousePos[0], $aMousePos[1]) ConsoleWrite($_hWnd_OnPos & @TAB & WinGetTitle($_hWnd_OnPos) & @CRLF) While _IsPressed("01") Sleep(10) WEnd EndIf WEnd Func _hWnd_Visible_AtPos($x, $y) Local $aWinlist = WinList() Local $aWinlist_Final[100][6], $iEnum, $aPos For $i = 1 To $aWinlist[0][0] If BitAND(WinGetState($aWinlist[$i][1]), 2) Then ; is visible $aWinlist_Final[$iEnum][0] = $aWinlist[$i][0] $aWinlist_Final[$iEnum][1] = $aWinlist[$i][1] $aPos = WinGetPos($aWinlist[$i][1]) $aWinlist_Final[$iEnum][2] = $aPos[0] ; x $aWinlist_Final[$iEnum][3] = $aPos[1] ; y $aWinlist_Final[$iEnum][4] = $aPos[2] ; w $aWinlist_Final[$iEnum][5] = $aPos[3] ; h $iEnum += 1 If Not Mod($iEnum, 100) Then ReDim $aWinlist_Final[UBound($aWinlist_Final) + 100][6] EndIf Next ReDim $aWinlist_Final[$iEnum - 1][6] For $i = 0 To $iEnum - 1 If $x >= $aWinlist_Final[$i][2] And $x <= ($aWinlist_Final[$i][2] + $aWinlist_Final[$i][4]) And _ $y >= $aWinlist_Final[$i][3] And $y <= ($aWinlist_Final[$i][3] + $aWinlist_Final[$i][5]) Then Return $aWinlist_Final[$i][1] Next Return 0 EndFunc ;==>_hWnd_Visible_AtPos Func _Exit() Exit EndFunc ;==>_Exit
    1 point
  10. ? _WinAPI_GetWindow($hWnd, $GW_HWNDNEXT)
    1 point
×
×
  • Create New...