Leaderboard
Popular Content
Showing content with the highest reputation on 01/10/2015 in all areas
-
[NEW RELEASE] - 11 Jan 15 Added: A new function (_GUITreeViewEx_SaveTV) to save the current TreeView (and checkbox state). Changed: A number of function names have been altered to reflect that at present the UDF is mainly oriented towards checkbox management (but stick around... ). This is script breaking so please do look at the new names if you have already used the UDF in a script. New zip below. A recent thread dealt with getting TreeViews with checkboxes to automatically check/clear associated items when a checkbox was actioned. It seemed like a good idea for a UDF and so here it is. I think the examples are pretty self-explanatory: initialise a TreeView once it is filled, register the UDF NOTIFY handler and then check/clear some checkboxes! Additional functionalities are the ability to check/clear ALL checkboxes in the TreeView and to stop the UDF acting on a previously initialised TreeView. There are also functions to fill/save a TreeView using a text string to define the item titles and the levels at which they should be created which has no link to the other UDF functions but seemeduseful to add. Here is a zip containing the UDF and examples in both MessageLoop & OnEvent mode: GUITreeViewEx.zip As always, comments, compliments and criticisms welcomed. M231 point
-
Get All Window's Controls
vergil250493 reacted to jdelaney for a topic
I've wanted to post this for a while. It's a great script to help debug control data....perfect scenario, when you have a 'Button' grouping, and spy tools cannot focus on those controls within the button bounds (groups). I also use it to verify that a given ID is not present more than once...if not, that's how I identify the control in future scripts. Output can be filtered by: 1) Filter by IsVisible 2) Filter by matching class (ex Button, Label, Static) 3) Filter by containing text #include <Array.au3> #include <WinAPI.au3> ConsoleWrite("Make your window active!" & @CRLF) Sleep(5000) GetAllWindowsControls(WinGetHandle("[ACTIVE]")) Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default) If Not IsHWnd($hCallersWindow) Then ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF) Return False EndIf ; Get all list of controls If $bOnlyVisible = Default Then $bOnlyVisible = False If $sStringIncludes = Default Then $sStringIncludes = "" If $sClass = Default Then $sClass = "" $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 If StringLen($sClass)>0 Then For $i = UBound($aClassList)-1 To 0 Step - 1 If $aClassList[$i]<>$sClass Then _ArrayDelete($aClassList,$i) EndIf Next EndIf For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible") If $bOnlyVisible And Not $bIsVisible Then $iTotalCounter += 1 ContinueLoop EndIf If StringLen($sStringIncludes) > 0 Then If Not StringInStr($text, $sStringIncludes) Then $iTotalCounter += 1 ContinueLoop EndIf EndIf If IsArray($aPos) Then ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>GetAllWindowsControls1 point -
it is possible to do something like this $Test1 = "WIFI,g,b,n,etc" then later use stringsplit() by commas to create an array of the values needed 8)1 point
-
LOL. I looked at "$serwer" and saw "$sewer". I guess it shows where my thoughts are! Anyway, I hope that helped.1 point
-
Mousemove using a single variable - Mousemove($coord, 1, 0)
VVind0wM4ker reacted to Melba23 for a topic
VVind0wM4ker, Welcome to the AutoIt forums. Just create your own function to wrap the standard MouseClick: $theplace = "123|456" _MyMouseClick($theplace, 1, 0) Func _MyMouseClick($sPos, $iNumber = 1, $iSpeed = 0) ; Split the value $aPos = StringSplit($sPos, "|") ; Call the normal function MouseClick($aPos[1], $aPos[2], $iNumber, $iSpeed) EndFunc Please ask if you have any questions. M231 point -
* Aug 22 - Update to TimeMakeStamp function, now accepts default keyword for last param. So, a while ago I asked Valik what the possibilty to implement some of the functions I'm used to in PHP might be. He pointed out that they were available through some Dll calls, and so I created these UDFs. Big thanks to him for the pointers and the help he provided. The zip has the include file, examples for each function, and the text files for creating help documents for each function. I'm in the process of duplicating PHP's date function as well. Like Valik pointed out, it's mostly just a wrapper for strftime anyway. Anyway, enjoy, hope somebody finds these useful. ----- Edit: The broken URL was brought to my attention via email. I don't have it in a zip with examples, but the .au3 file is available at the above link. Edit 2: Again the URL has been broken for a while, and again brought to my attention via email. The URL has been updated. Edit 3: Broken URL called to my attention again. Adding the file to this thread. Don't know why I didn't do this sooner. UnixTime.au31 point
-
Hi All! Hope this UDF someday be useful for yours greats scripts UDF: #include-once #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Global Const $HH_DISPLAY_TEXT_POPUP = 0xE Global Const $HH_CLOSE_ALL = 0x12 Global $HH_POPUP Global $DllHandle = DllOpen("HHCtrl.ocx") Global $aControls[1] = [0] Global $aText[1] = [0] Global $aTextColor[1] = [0] Global $aBkColor[1] = [0] Global $aFontFormat[1] = [0] $HH_POPUP = DllStructCreate("int cbStruct;hwnd hinst;uint idString;ptr pszText;long pt[2];dword clrForeground;" & _ "dword clrBackground;long rcMargins[4];ptr pszFont") DllStructSetData($HH_POPUP, "cbStruct", DllStructGetSize($HH_POPUP)) DllStructSetData($HH_POPUP, "idString", 0) DllStructSetData($HH_POPUP, "rcMargins", -1, 1) DllStructSetData($HH_POPUP, "rcMargins", -1, 2) DllStructSetData($HH_POPUP, "rcMargins", -1, 3) DllStructSetData($HH_POPUP, "rcMargins", -1, 4) GUIRegisterMsg($WM_HELP, "WM_HELP") ; #FUNCTION# ============================================================= ; Name............: _ContextHelp_SetText ; Description.....: Sets context help text for control ; Syntax..........: _ContextHelp_SetText($hControl, $sText) ; Parameter(s)....: $hControl - Handle or ID to the control ; $sText - Text which be showed ; Return value(s).: Success - None ; Failure - Sets @error to 1 ; Requirement(s)..: AutoIt 3.2.12.0 ; Note(s).........: Tested on Windows XP SP2 ; Author(s).......: R.Gilman (a.k.a. rasim) ; ======================================================================== Func _ContextHelp_SetText($hControl, $sText) If Not $hControl Then Return SetError(1, 0, 0) If Not IsHWnd($hControl) Then $hControl = GUICtrlGetHandle($hControl) Local $iElement = _CheckControl($hControl) $aText[$iElement] = $sText EndFunc ;==>_ContextHelp_SetText ; #FUNCTION# ============================================================= ; Name............: _ContextHelp_SetTextColor ; Description.....: Sets color for context help text ; Syntax..........: _ContextHelp_SetTextColor($hControl, $sTextColor) ; Parameter(s)....: $hControl - Handle or ID to the control ; $sTextColor - Color in HEX value ; Return value(s).: Success - None ; Failure - Sets @error to 1 ; Requirement(s)..: AutoIt 3.2.12.0 ; Note(s).........: Tested on Windows XP SP2 ; Author(s).......: R.Gilman (a.k.a. rasim) ; ======================================================================== Func _ContextHelp_SetTextColor($hControl, $sTextColor) If Not $hControl Then Return SetError(1, 0, 0) If Not IsHWnd($hControl) Then $hControl = GUICtrlGetHandle($hControl) Local $iElement = _CheckControl($hControl) $aTextColor[$iElement] = RGB2BGR($sTextColor) EndFunc ;==>_ContextHelp_SetTextColor ; #FUNCTION# ============================================================= ; Name............: _ContextHelp_SetBkColor ; Description.....: Sets the background color for a context help window ; Syntax..........: _ContextHelp_SetBkColor($hControl, $sBkColor) ; Parameter(s)....: $hControl - Handle or ID to the control ; $sBkColor - Color in HEX value ; Return value(s).: Success - None ; Failure - Sets @error to 1 ; Requirement(s)..: AutoIt 3.2.12.0 ; Note(s).........: Tested on Windows XP SP2 ; Author(s).......: R.Gilman (a.k.a. rasim) ; ======================================================================== Func _ContextHelp_SetBkColor($hControl, $sBkColor) If Not $hControl Then Return SetError(1, 0, 0) If Not IsHWnd($hControl) Then $hControl = GUICtrlGetHandle($hControl) Local $iElement = _CheckControl($hControl) $aBkColor[$iElement] = RGB2BGR($sBkColor) EndFunc ;==>_ContextHelp_SetBkColor ; #FUNCTION# ============================================================= ; Name............: _ContextHelp_SetFont ; Description.....: Sets the font, font size and font attributes for a context help text ; Syntax..........: _ContextHelp_SetFont($hControl, $sFontName [, $sFontSize = 8.5 [, $sFontFormat = "NORMAL"]]]) ; Parameter(s)....: $hControl - Handle or ID to the control ; $sFontName - The name of the font ; $sFontSize - [optional] Font size (default is 8.5) ; $sFontFormat - [optional] Font attributes e.g.: BOLD, ITALIC, UNDERLINED ; +you can use a several font attributes, just indicate theirs via space ; Return value(s).: Success - None ; Failure - Sets @error to 1 ; Requirement(s)..: AutoIt 3.2.12.0 ; Note(s).........: Tested on Windows XP SP2 ; Author(s).......: R.Gilman (a.k.a. rasim) ; ======================================================================== Func _ContextHelp_SetFont($hControl, $sFontName, $sFontSize = 8.5, $sFontFormat = "NORMAL") If Not $hControl Then Return SetError(1, 0, 0) If Not IsHWnd($hControl) Then $hControl = GUICtrlGetHandle($hControl) Local $iElement = _CheckControl($hControl) $aFontFormat[$iElement] = $sFontName & ", " & $sFontSize & ", , " & $sFontFormat EndFunc ;==>_ContextHelp_SetFont ; #FUNCTION# ============================================================= ; Name............: _CheckControl ; Description.....: Finds the control handle in the array contains a controls handles ; Syntax..........: _CheckControl($hControl) ; Parameter(s)....: $hControl - Handle to the control ; Return value(s).: Last element number from the array contains a controls handles ; Requirement(s)..: AutoIt 3.2.12.0 ; Note(s).........: Only for internal use ; Author(s).......: R.Gilman (a.k.a. rasim) ; ======================================================================== Func _CheckControl($hControl) Local $i If $aControls[0] = 0 Then Return _ContextHelp_Create($hControl) EndIf For $i = 1 To $aControls[0] If $hControl = $aControls[$i] Then Return $i EndIf Next Return _ContextHelp_Create($hControl) EndFunc ;==>_CheckControl ; #FUNCTION# ============================================================= ; Name............: _ContextHelp_Create ; Description.....: Redims arrays with parameters and sets default parameters ; Syntax..........: _ContextHelp_Create($hControl) ; Parameter(s)....: $hControl - Handle to the control ; Return value(s).: Last element number from the array contains a controls handles ; Requirement(s)..: AutoIt 3.2.12.0 ; Note(s).........: Only for internal use ; Author(s).......: R.Gilman (a.k.a. rasim) ; ======================================================================== Func _ContextHelp_Create($hControl) $aControls[0] += 1 ReDim $aControls[$aControls[0] + 1] $aControls[$aControls[0]] = $hControl $aText[0] += 1 ReDim $aText[$aText[0] + 1] $aText[$aText[0]] = "What's that?" $aTextColor[0] += 1 ReDim $aTextColor[$aTextColor[0] + 1] $aTextColor[$aTextColor[0]] = -1 $aBkColor[0] += 1 ReDim $aBkColor[$aBkColor[0] + 1] $aBkColor[$aBkColor[0]] = -1 $aFontFormat[0] += 1 ReDim $aFontFormat[$aFontFormat[0] + 1] $aFontFormat[$aFontFormat[0]] = "MS Sans Serif, 8.5, , NORMAL" Return $aControls[0] EndFunc ;==>_ContextHelp_Create ; #FUNCTION# ============================================================= ; Name............: _ContextHelp_Popup ; Description.....: Displaying a context help for controls ; Syntax..........: _ContextHelp_Popup() ; Parameter(s)....: None ; Return value(s).: None ; Requirement(s)..: AutoIt 3.2.12.0 ; Note(s).........: Only for internal use ; Author(s).......: R.Gilman (a.k.a. rasim) ; ======================================================================== Func _ContextHelp_Popup() DllCall($DllHandle, "hwnd", "HtmlHelp", "hwnd", 0, "str", 0, _ "int", $HH_DISPLAY_TEXT_POPUP, "dword", DllStructGetPtr($HH_POPUP)) EndFunc ;==>_ContextHelp_Popup ; #FUNCTION# ============================================================= ; Name............: RGB2BGR ; Description.....: Convert a RGB color mode to a BGR color mode ; Syntax..........: RGB2BGR($sColor) ; Parameter(s)....: $sColor - The color in HEX value ; Return value(s).: Converted color in HEX value ; Requirement(s)..: ; Note(s).........: ; Author(s).......: Siao ; ======================================================================== Func RGB2BGR($sColor) Return BitAND(BitShift(String(Binary($sColor)), 8), 0xFFFFFF) EndFunc ;==>RGB2BGR Func WM_HELP($hWnd, $Msg, $wParam, $lParam) Local $HELPINFO, $hControl, $tFont, $tText, $i $HELPINFO = DllStructCreate("int cbSize;int iContextType;int iCtrlId;hwnd hItemHandle;" & _ "dword dwContextId;long MousePos[2]", $lParam) $hControl = DllStructGetData($HELPINFO, "hItemHandle") $tFont = DllStructCreate("char Font[256]") $tText = DllStructCreate("char Text[256]") For $i = 1 To $aControls[0] If $hControl = $aControls[$i] Then DllStructSetData($tText, "Text", $aText[$i]) DllStructSetData($tFont, "Font", $aFontFormat[$i]) DllStructSetData($HH_POPUP, "pszText", DllStructGetPtr($tText)) DllStructSetData($HH_POPUP, "pszFont", DllStructGetPtr($tFont)) DllStructSetData($HH_POPUP, "clrForeground", $aTextColor[$i]) DllStructSetData($HH_POPUP, "clrBackground", $aBkColor[$i]) DllStructSetData($HH_POPUP, "pt", DllStructGetData($HELPINFO, "MousePos", 1), 1) DllStructSetData($HH_POPUP, "pt", DllStructGetData($HELPINFO, "MousePos", 2), 2) _ContextHelp_Popup() EndIf Next Return $GUI_RUNDEFMSG EndFunc ;==>WM_HELP Func OnAutoitExit() DllCall($DllHandle, "hwnd", "HtmlHelp", "hwnd", 0, "str", 0, "uint", $HH_CLOSE_ALL, "dword", 0) $HH_POPUP = 0 DllClose($DllHandle) EndFunc ;==>OnAutoitExitoÝ÷ ÙÊ%¢ºç¬¥©ì·)^ Note: Works correctly in the AutoIt latest version 3.2.12.01 point