Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/29/2012 in all areas

  1. Ok, so this has probably been posted before, but I was looking through the MSDN library randomly just a bit ago, and decided to play around a bit with some of the console-related functions. AutoIt can make basic console applications to provide users with some basic output (which is generally more efficient than outputting to a GUI), but wouldn't it be cool to be able to name your console windows just like you can name your GUI windows? Instead of it being called "C:\Users\Foobar\Desktop\MyEchoServer.exe" for instance, you could make your program call itself just "My Echo Server" and such. Here is the simple UDF on it's own, and below this is a nice little example detailing how you can use the function. ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_SetConsoleTitle ; Description ...: Change the AutoIt process's attached console title. ; Syntax ........: _WinAPI_SetConsoleTitle($sTitle[, $hDLL = "Kernel32.dll"]) ; Parameters ....: $sTitle - A string value. ; $hDLL - [optional] A handle value. Default is "Kernel32.dll". ; Return values .: True if the title was able to be changed, False if it was not able to be changed. ; Author ........: Ken "Kealper" Piper ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _WinAPI_SetConsoleTitle($sTitle, $hDLL = "Kernel32.dll") Local $iRet = DllCall($hDLL, "bool", "SetConsoleTitle", "str", $sTitle) If $iRet[0] < 1 Then Return False Return True EndFunc And here is the example... For best results, save this to a file and compile it as a console application. If it isn't compiled as a console application, there is a quick and dirty DllCall in there to create a "dummy" console if it doesn't exist already which can serve to demonstrate the function anyways (but without any textual output). #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;Create a new console window if it does not already exist, even if it is not compiled as a console executable. ;This DllCall is not part of the example, it only serves to ensure the example works correctly. ;Don't run through SciTE, the example will fail, and even this DllCall can't fix that. DllCall("Kernel32.dll", "bool", "AllocConsole") ;Don't just rely on this though, to get the most from this, compile as a console app! ;Begin actual example. ConsoleWrite("Keep an eye on the console's window title!" & @CRLF) Sleep(3000) ;First: Setting the title of your console window is as easy as this! _WinAPI_SetConsoleTitle("This is some custom text!") ;A simple count-down, so the first title change is visible for a few seconds before proceeding to the next example. For $i = 5 To 1 Step -1 ConsoleWrite("Proceeding in " & $i & "..." & @CRLF) Sleep(1000) Next ConsoleWrite("On to example two! This'll count to 50 and then exit." & @CRLF) ;Second: Something a bit more advanced. Changing the console's title rapidly. ;When changing the console's title rapidly, you should first open Kernel32.dll and then pass that handle ;as a second parameter to the function. This makes it use the open handle instead of having to open and ;close Kernel32.dll each time the function is called. This ends up making it more efficient. $Kernel32 = DllOpen("Kernel32.dll") ;Open Kernel32.dll. $Kernel32 now holds a handle to the opened file. For $i = 1 To 50 ;Count to 50 _WinAPI_SetConsoleTitle("Counting..." & $i, $Kernel32) ;Set the new title, and tell the function to use the open handle instead. Sleep(100) ;Wait 100ms, so the change can be easily seen by everyone. Without this, the change would happen too fast to notice. Next DllClose($Kernel32) ;Finally, because we like our resources, close the open handle since we no longer need it. ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_SetConsoleTitle ; Description ...: Change the AutoIt process's attached console title. ; Syntax ........: _WinAPI_SetConsoleTitle($sTitle[, $hDLL = "Kernel32.dll"]) ; Parameters ....: $sTitle - A string value. ; $hDLL - [optional] A handle value. Default is "Kernel32.dll". ; Return values .: True if the title was able to be changed, False if it was not able to be changed. ; Author ........: Ken "Kealper" Piper ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _WinAPI_SetConsoleTitle($sTitle, $hDLL = "Kernel32.dll") Local $iRet = DllCall($hDLL, "bool", "SetConsoleTitle", "str", $sTitle) If $iRet[0] < 1 Then Return False Return True EndFunc
    2 points
  2. Yashied

    DLL Helper

    LAST VERSION - 1.0 28-May-12 This small utility designed for viewing the exported DLL functions and is written specifically for AutoIt community. Nothing excess, just the tools you need. Especially useful are Drag-and-Drop and support for command line that allows you to add DLL Helper in the Windows Explorer context menu. To do this, you can use the following .reg file. Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\dllfile\shell\View] @="View exported function" [HKEY_CLASSES_ROOT\dllfile\shell\View\command] @=""C:\Program Files\DLLHelper\DLLHelper.exe" "%1""Also worth noting is fairly fast enumeration of exported DLL functions and the ability to export the function list into a text or HTML document. As usualy, I will be glad to any feedback and suggestions. Major program features Support for both x86 and x64 DLL files.Fast enumeration of exported DLL functions.Support for command line (use the full path in the first parameter).Support Drag-and-Drop.Web search for functions with the ability to add user-defined services (up to 10, via registry).Ability to view the undecorated names of DLL function.Ability to specify a filter to display the functions of interest.Sort the function list by any column.Copying any data (by column) from the list to the clipboard.Export list of function to the .txt or .html file.List of recently opened files (up to 10).Simple and intuitive interface. License Supported operating systems Windows XP, Vista, 7 Files to download Binary Redirection to DLLHelper_bin.zip, 475 KB DLLHelper_bin.html Source Redirection to DLLHelper_source.zip, 657 KB DLLHelper_source.html
    1 point
  3. Yashied

    GetTabbedStringSizeEx()

    Many people on the forum wrote a functions to calculate the dimensions of a string, but I have not found a solution if the string contains one or more tab characters (at best, replaced @TAB by 4 or more other characters). All use the GetTextExtentPoint32() function, but there is GetTabbedTextExtent() that supports the tabbed strings. There's only one problem using it in AutoIt. We need to specify the tab-stop positions in pixels (see "nTabPositions" and "lpnTabStopPositions" parameters). If it is incorrect then the result will be wrong. The value of tab-stop position should be strictly the same that use AutoIt to draw the tabbed strings. But the difficulty is that this value depends on the typeface and size of the used font. After some experimentation, I came to the conclusion that the value of tab-stop position can be calculated as follows: 8 * TEXTMETRIC("tmAveCharWidth")So, the following function returns the dimensions of a tabbed or non-tabbed string. Moreover, the string can contain carriage returns (@CR or @CRLF). Additionally, you can align the string through a tab characters to display it as a table in the Label control (see screenshot). I tested the example which is shown below with a few fonts and it works fine. #Include <GUIConstants.au3> #Include <WindowsConstants.au3> Opt('MouseCoordMode', 2) Global $Text = '#1' & @TAB & '0B7' & @TAB & '#2' & @TAB & '01F' & @TAB & '#3' & @TAB & '2FF' & @TAB & '#4' & @TAB & '077' & @CRLF & _ 'COMPRESS_COPY' & @TAB & '+' & @TAB & 'PREFIX_PLATFORM' & @TAB & '+' & @TAB & 'TEST' & @TAB & '+' & @TAB & 'WIN7_PROGRESSBAR' & @TAB & '+' & @CRLF & _ 'COMPRESS_BCJ' & @TAB & '+' & @TAB & 'PREFIX_WAITALL' & @TAB & '+' & @TAB & 'LANG' & @TAB & '+' & @TAB & 'RTF_CONTROL' & @TAB & '+' & @CRLF & _ 'COMPRESS_BCJ2' & @TAB & '+' & @TAB & 'PREFIX_HIDCON' & @TAB & '+' & @TAB & 'ELEVATION' & @TAB & '+' & @TAB & 'IMAGES' & @TAB & '+' & @CRLF & _ 'COMPRESS_DEFLATE' & @TAB & '-' & @TAB & 'PREFIX_NOWAIT' & @TAB & '+' & @TAB & 'CHECK_RAM' & @TAB & '+' & @CRLF & _ 'COMPRESS_LZMA' & @TAB & '+' & @TAB & 'PREFIX_FORCENOWAIT' & @TAB & '+' & @TAB & 'CHECK_FREE_SPACE' & @TAB & '+' & @CRLF & _ 'COMPRESS_LZMA2' & @TAB & '+' & @TAB & '' & @TAB & '' & @TAB & 'BEGINPROMPTTIMEOUT' & @TAB & '+' & @CRLF & _ 'COMPRESS_PPMD' & @TAB & '-' & @TAB & '' & @TAB & '' & @TAB & 'CONFIG_PLATFORM' & @TAB & '+' & @CRLF & _ 'CRYPTO' & @TAB & '+' & @TAB & '' & @TAB & '' & @TAB & 'EARLY_PASSWORD' & @TAB & '+' & @CRLF & _ 'VOLUMES' & @TAB & '-' & @TAB & '' & @TAB & '' & @TAB & 'VOLUME_NAME_STYLE' & @TAB & '-' & @CRLF & _ 'PROTECT' & @TAB & '-' & @TAB & '' & @TAB & '' & @TAB & 'ENVIRONMENT_VARS' & @TAB & '+' Global $Font[20] = [1.5, 2.3, 3.0, 3.8, 4.5, 5.3, 6.0, 6.8, 7.5, 8.3, 9.0, 9.8, 10.5, 11.3, 12.0, 12.8, 13.5, 14.3, 15.0, 15.8] For $i = 0 To UBound($Font) - 1 _Form($Text, 'Segoe UI', $Font[$i]) Next Func _Form($sText, $sFont, $nFont) Local $hForm, $Button, $Pos, $Size $hForm = GUICreate(StringFormat('%s - %.1f', $sFont, $nFont), 0, 0) GUISetFont(9.0, 400, 0, 'Segoe UI') GUISetBkColor(0xF0F0F0) GUICtrlCreateLabel('', 10, 10) GUICtrlSetFont(-1, $nFont, 400, 0, $sFont) GUICtrlSetBkColor(-1, 0xFFFFFF) $Size = _GetTabbedStringSizeEx(-1, $sText, 1) If Not @Error Then GUICtrlSetPos(-1, -1, -1, $Size[0], $Size[1]) GUICtrlSetData(-1, $sText) EndIf $Pos = WinGetPos($hForm) WinMove($hForm, '', (@DesktopWidth - ($Pos[2] + $Size[0] + 20)) / 2, (@DesktopHeight - ($Pos[3] + $Size[1] + 70)) / 2, $Pos[2] + $Size[0] + 20, $Pos[3] + $Size[1] + 70) GUICtrlCreateGraphic(0, 0, $Size[0] + 20, $Size[1] + 20) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGraphic(0, $Size[1] + 20, $Size[0] + 20, 1) GUICtrlSetBkColor(-1, 0xDFDFDF) GUICtrlSetState(-1, $GUI_DISABLE) $Button = GUICtrlCreateButton('OK', ($Size[0] + 20) / 2 - 37, $Size[1] + 32, 88, 27) GUICtrlSetState(-1, BitOR($GUI_DEFBUTTON, $GUI_FOCUS)) GUISetState() MouseMove(($Size[0] + 20) / 2 + 7, $Size[1] + 46, 0) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button ExitLoop EndSwitch WEnd GUIDelete($hForm) EndFunc ;==>_Form Func _GetTabbedStringSizeEx($CtrlID, ByRef $sString, $fAlignment = False) Local $W = 0, $H, $tTM, $pTM, $hDC = 0, $hSv = 0, $aTemp, $aSize, $aData, $aTabs, $aText, $sText = '', $Error, $Tab, $Ret Local $tTM = DllStructCreate('long;long;long;long;long;long;long;long;long;long;long;wchar;wchar;wchar;wchar;byte;byte;byte;byte;byte') ;~ Local $tTM = DllStructCreate($tagTEXTMETRIC) Local $pTM = DllStructGetPtr($tTM) Local $tData = DllStructCreate('long;long') Local $pData = DllStructGetPtr($tData) Local $aResult[2] = [0, 0] If Not IsHWnd($CtrlID) Then $CtrlID = GUICtrlGetHandle($CtrlID) If Not $CtrlID Then Return SetError(1, 0, 0) EndIf EndIf Do $Error = 1 $Ret = DllCall('user32.dll', 'ptr', 'GetDC', 'hwnd', $CtrlID) If (@Error) Or (Not $Ret[0]) Then ExitLoop EndIf $hDC = $Ret[0] $Ret = DllCall('user32.dll', 'ptr', 'SendMessageW', 'hwnd', $CtrlID, 'uint', 0x0031, 'wparam', 0, 'lparam', 0) If (@Error) Or (Not $Ret[0]) Then ExitLoop EndIf $Ret = DllCall('gdi32.dll', 'ptr', 'SelectObject', 'hwnd', $hDC, 'ptr', $Ret[0]) If (@Error) Or (Not $Ret[0]) Then ExitLoop EndIf $hSv = $Ret[0] $Ret = DllCall('gdi32.dll', 'int', 'GetTextMetricsW', 'hwnd', $hDC, 'ptr', $pTM) If (@Error) Or (Not $Ret[0]) Then ExitLoop EndIf $Tab = 8 * DllStructGetData($tTM, 6) If Not $Tab Then ExitLoop EndIf $aData = StringSplit(StringReplace($sString, @CRLF, @CR), @CR, 2) $H = UBound($aData) If ($H > 1) And ($fAlignment) Then For $i = 0 To $H - 1 $aTemp = StringSplit($aData[$i], @TAB) If $W < $aTemp[0] Then $W = $aTemp[0] EndIf Next Dim $aText[$H][$W] Dim $aSize[$H][$W] For $i = 0 To $H - 1 $aTemp = StringSplit($aData[$i], @TAB) For $j = 0 To $W - 1 Select Case $aTemp[0] < $j + 1 $aText[$i][$j] = 0 $aSize[$i][$j] = -1 Case $aTemp[0] = $j + 1 $aText[$i][$j] = $aTemp[$j + 1] $aSize[$i][$j] = -1 Case Else $aText[$i][$j] = $aTemp[$j + 1] $Ret = DllCall('gdi32.dll', 'int', 'GetTextExtentPoint32W', 'hwnd', $hDC, 'wstr', $aTemp[$j + 1], 'int', StringLen($aTemp[$j + 1]), 'ptr', $pData) If (Not @Error) And ($Ret[0]) Then $aSize[$i][$j] = DllStructGetData($tData, 1) Else $aSize[$i][$j] = 0 EndIf EndSelect Next Next Dim $aTabs[$W] For $j = 0 To $W - 1 $aTabs[$j] = 1 For $i = 0 To $H - 1 If $aSize[$i][$j] <> -1 Then If $aSize[$i][$j] < $Tab Then $aSize[$i][$j] = 1 Else $aSize[$i][$j] = Floor($aSize[$i][$j] / $Tab) + 1 If $aTabs[$j] < $aSize[$i][$j] Then $aTabs[$j] = $aSize[$i][$j] EndIf EndIf EndIf Next Next Dim $aData[$H] For $i = 0 To $H - 1 $aData[$i] = '' For $j = 0 To $W - 1 If IsString($aText[$i][$j]) Then $aData[$i] &= $aText[$i][$j] If $aSize[$i][$j] <> -1 Then $aSize[$i][$j] = $aTabs[$j] - $aSize[$i][$j] EndIf For $k = 1 To $aSize[$i][$j] + 1 $aData[$i] &= @TAB Next Else ExitLoop EndIf Next $sText &= $aData[$i] & @CRLF Next EndIf $Error = 1 DllStructSetData($tData, 1, $Tab) For $i = 0 To $H - 1 $Ret = DllCall('user32.dll', 'dword', 'GetTabbedTextExtentW', 'hwnd', $hDC, 'wstr', $aData[$i], 'int', StringLen($aData[$i]), 'int', 1, 'ptr', $pData) If (Not @Error) And ($Ret[0]) Then $aResult[1] += BitShift($Ret[0], 16) $Ret = BitAND($Ret[0], 0xFFFF) If $aResult[0] < $Ret Then $aResult[0] = $Ret EndIf Else ExitLoop 2 EndIf Next $Error = 0 Until 1 If $hSv Then DllCall('gdi32.dll', 'ptr', 'SelectObject', 'hwnd', $hDC, 'ptr', $hSv) EndIf If $hDC Then DllCall('user32.dll', 'int', 'ReleaseDC', 'hwnd', $CtrlID, 'hwnd', $hDC) EndIf If $Error Then Return SetError(1, 0, 0) EndIf If $fAlignment Then $sString = StringTrimRight($sText, 2) EndIf Return $aResult EndFunc ;==>_GetTabbedStringSizeEx
    1 point
  4. Armag3ddon, This has come up a couple of times recently. AutoIt uses the Item Parameters in natively created ListViews and TreeViews to hold the ControlID of the particular item. You are setting the parameter to numbers used by the ControlIDs of other controls and so confusing AutoIt. The solution is to add a suitably high number ot the parameter so that the value does not repeat a ControlID - I have used 1000 in this example: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) $Debug_TV = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work Global Const $TVSORTCB = "ptr Parent;ptr Compare;lparam SortParam;" Global $Data[500] Global $operation = False Global $hWnd_GUI, $hTreeView, $contextmenu _Main() While 1 Sleep(10) WEnd Func _Main() Local $hItem[10], $hChildItem[30], $hGrandChildItem[90], $hGrandGrantChildItem[180] Local $iCItem = 0, $iGCItem = 0, $IGGCItem = 0, $i1 = 10, $i2 = 30, $i3 = 90, $i4 = 180 Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS) ; Create GUI $hWnd_GUI = GUICreate("TreeView Sort", 400, 300) GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $hWnd_GUI) $hTreeView = _GUICtrlTreeView_Create($hWnd_GUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) _GUICtrlTreeView_SetUnicodeFormat($hTreeView, True) GUISetState() ; Create treeview and fill with some items _GUICtrlTreeView_BeginUpdate($hTreeView) Local $Count = 0 For $a = 0 To 9 $Data[$Count] = StringFormat("[%02d] New Item", $i1) $hItem[$a] = _GUICtrlTreeView_Add($hTreeView, $hTreeView, $Data[$Count]) _GUICtrlTreeView_SetItemParam($hTreeView, $hItem[$a], 1000 + $Count) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $Count += 1 For $b = 1 To 3 $Data[$Count] = StringFormat("[%02d] New Child", $i2) $hChildItem[$iCItem] = _GUICtrlTreeView_AddChild($hTreeView, $hItem[$a], $Data[$Count]) _GUICtrlTreeView_SetItemParam($hTreeView, $hChildItem[$iCItem], 1000 + $Count) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $Count += 1 For $c = 1 To 3 $Data[$Count] = StringFormat("[%02d] New Grandchild", $i3) $hGrandChildItem[$iGCItem] = _GUICtrlTreeView_AddChild($hTreeView, $hChildItem[$iCItem], $Data[$Count]) _GUICtrlTreeView_SetItemParam($hTreeView, $hGrandChildItem[$iGCItem], 1000 + $Count) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $Count += 1 For $d = 1 To 2 $Data[$Count] = StringFormat("[%02d] New GrandGrandChild", $i4) $hGrandGrantChildItem[$IGGCItem] = _GUICtrlTreeView_AddChild($hTreeView, $hGrandChildItem[$iGCItem], $Data[$Count]) _GUICtrlTreeView_SetItemParam($hTreeView, $hGrandGrantChildItem[$IGGCItem], 1000 + $Count) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $Count += 1 $IGGCItem += 1 $i4 -= 1 Next $iGCItem += 1 $i3 -= 1 Next $iCItem += 1 $i2 -= 1 Next $i1 -= 1 Next _GUICtrlTreeView_EndUpdate($hTreeView) ; Context menu Local $dummy = GUICtrlCreateDummy() Local $ctxmenu = GUICtrlCreateContextMenu($dummy) $contextmenu = GUICtrlGetHandle($ctxmenu) GUICtrlSetOnEvent(GUICtrlCreateMenuItem("New", $ctxmenu), "Dummy") GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Cut", $ctxmenu), "Dummy") GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Copy", $ctxmenu), "Dummy") GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Paste", $ctxmenu), "Dummy") GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Delete", $ctxmenu), "Dummy") GUICtrlCreateMenuItem("", $ctxmenu) GUICtrlSetOnEvent(GUICtrlCreateMenuItem("Refresh", $ctxmenu), "Dummy") EndFunc ;==>_Main Func Close() GUIDelete($hWnd_GUI) Exit EndFunc ;==>Close Func Dummy() ConsoleWrite("Clicked on either New, Copy, Delete or Refresh" & @CRLF) EndFunc ;==>DummyNo "ghost" firings now when I run it - and the sorting should still work as you have suitably differentiated parameters to work with. M23
    1 point
  5. Try ControlFocus() and use the handle returned by the UDF Create function as the title parameter.
    1 point
  6. I was board and decided to do it with my all time favorite UDF, winhttp. SO you'll need to download that before running this. #include <Array.au3> #include ".incWinHttp.au3" $HTML = _GetSource("http://fakenamegenerator.com/advanced.php") If @error Then ConsoleWrite("@Error: " & @error & @CR & _ "@Extended: " & @extended & @CR & _ "Return: "&$HTML&@CR) $Stuff = StringRegExp($HTML,"(?i)<spanb[^>]*>(.*?)</span>",3) _ArrayDisplay($stuff) $NAme = StringRegExp(StringStripCR($HTML),'<span class="given-name">(.*?)</span> <span class="additional-name">(.*?)</span> <span class="family-name">(.*?)</span>',3) If Not @error Then MsgBox(0,"Name",$NAme[0]&" "&$NAme[1]&" "&$NAme[2]) Func _GetSource($url, $Hwnd = '', $Agent = 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)') Local $Error, $CloseHwnd Local $aUrl = _WinHttpCrackUrl($url) If @error Then Return SetError(1, @error, False) If Not $Hwnd Then $CloseHwnd = 1 $Hwnd = _WinHttpOpen($Agent) If @error Then Return SetError(2, @error, False) _WinHttpSetTimeouts($Hwnd, 0, 10000, 8000, 5000) EndIf Local $hConnect = _WinHttpConnect($Hwnd, $aUrl[2]) If @error Then $Error = @error _WinHttpCloseHandle($hConnect) If $CloseHwnd Then _WinHttpCloseHandle($Hwnd) Return SetError(3, $Error, False) EndIf Local $hRequest = _WinHttpSimpleSEndRequest($hConnect, Default, $aUrl[6] & $aUrl[7]) If @error Then $Error = @error _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) If $CloseHwnd Then _WinHttpCloseHandle($Hwnd) Return SetError(4, $Error, False) EndIf If $hRequest Then Local $html = _WinHttpSimpleReadData($hRequest) If @error Then $Error = @error _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) If $CloseHwnd Then _WinHttpCloseHandle($Hwnd) Return SetError(5, $Error, False) EndIf Else _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) If $CloseHwnd Then _WinHttpCloseHandle($Hwnd) Return SetError(6, 0, False) EndIf _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) If $CloseHwnd Then _WinHttpCloseHandle($Hwnd) Return SetError(0, 0, $html) EndFunc ;==>_GetSource
    1 point
  7. It depends on the GUI element you are talking about. A lot of these UDFs have functions to set the focus.
    1 point
  8. I've stumbled into this kind of problem many times, what you need to do is use the respective UDF functions that exist to manipulate the controls. This is because autoit supposedly uses pseudo handles internally.
    1 point
  9. danielkza

    C struct with array

    First of all, your code is invalid: you're passing a structure as the first parameter to printf() while it is expecting a float. printf() works by looking at the string specifier and pulling the appropriate amount of data from the stack, which you wrongly populated with the contents of the structure *twice*. Remember that in the default C calling convention arguments are passed in reverse order, so they can be popped in left-to-right order by the callee, and that you passed the structure *as a single piece*. This is how the stack will look, from top to bottom, right before control is passed to printf(): // top test.val[0] test.val[1] test test.val[2] / test.val[3] / test.val[0] <= test.val[0] test.val[1] <= test.val[1] test.val[2] <= test.val[2] test.val[3] <= test.val[3] printf() will then pop 5 floats from the stack and print them, which explains the behavior you are seeing. The lesson to take is *don't pass printf() anything but exactly what it is expecting*, which *is not* a struct and 4 floats, but *exactly 5 floats*.
    1 point
×
×
  • Create New...