Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/30/2015 in all areas

  1. Ok, here is what i came up with after 3-4 hours of scripting well ok, it has been long time since then, so... after an year or so of hard scripting/testing!!! (inspired by this topic)... GUICtrlSetOnHover UDF... Syntax: _GUICtrl_OnHoverRegister(ControlID [, OnHoverFunc [, OnLeaveHoverFunc [, PrimaryDownFunc [, PrimaryUpFunc [, KeepCall_PrDn_Func [, KeepCall_Hover_Func]]]]]]) ControlID can be -1 as in Build-In functions! Example: #include "GUICtrlOnHover.au3" Opt("GUIOnEventMode", 1) $Btn_Color = 0x7A9DD8 $Hover_Color = 0xFF0000 ;0x7AC5D8 $GUIMain = GUICreate("Letters Hovering Example", 570, 200) GUISetOnEvent(-3, "Quit") _CreateLetters_Proc(10, 60, 18, 20) GUICtrlCreateButton("Close", 30, 120, 100, 30) GUICtrlSetOnEvent(-1, "Quit") GUICtrlSetFont(GUICtrlCreateLabel("Letter: ", 35, 170, 200, 20), 9, 800) $Status_Label = GUICtrlCreateLabel("", 80, 171, 200, 20) GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetFont(-1, 8.5, 800) GUISetState() While 1 Sleep(100) WEnd Func _CreateLetters_Proc($iLeft, $Top, $Width=15, $Height=15) Local $iLeft_Begin = $iLeft Local $iAsc_Char = 64 For $i = 0 To 25 $iLeft_Begin += 20 $iAsc_Char += 1 GUICtrlCreateButton(Chr($iAsc_Char), $iLeft_Begin, $Top, $Width, $Height) _GUICtrl_OnHoverRegister(-1, "_Hover_Func", "_Leave_Hover_Func") GUICtrlSetOnEvent(-1, "_Letter_Events") GUICtrlSetBkColor(-1, $Btn_Color) GUICtrlSetFont(-1, 6) Next EndFunc Func _Letter_Events() MsgBox(64, "Pressed", "Letter = " & GUICtrlRead(@GUI_CtrlId)) EndFunc Func _Hover_Func($iCtrlID) GUICtrlSetBkColor($iCtrlID, $Hover_Color) GUICtrlSetData($Status_Label, GUICtrlRead($iCtrlID)) Beep(1000, 20) EndFunc Func _Leave_Hover_Func($iCtrlID) GUICtrlSetBkColor($iCtrlID, $Btn_Color) GUICtrlSetData($Status_Label, "") EndFunc Func Quit() Exit EndFunc Attachments: [The archive include few nice examples, and the UDF itself of course .] * New (v2.1) (Redirection to Zip-file, 159 kb) _GUICtrlSetOnHover.html GUICtrlSetOnHover.zip GUICtrlSetOnHover_UDF.au3 GuiCtrlSetOnHover.zip GUICtrlSetOnHover_UDF_For_3.2.10.0.au3 Old Beta - GUICtrlSetOnHover_UDF_beta.zip Enjoy! P.S Thanks to piccaso for the greatest CallBack tool! Without it, this UDF would never been created! ============================================ History version:
    1 point
  2. DllCall is a powerful way to use AutoIt code to run functions that were created in other languages and are stored in shared libraries outside of AutoIt. With DllCall, you can call Windows APIs directly, execute pieces of code that shipped with another vendor's product, and pass information between that code and your own script. However, DllCall is intended for the advanced user who is already familiar with how that stuff works. That definitely isn't me, and I find the process of converting variable types, handling ByRefs with odd syntax, and keeping track of return values in an array cumbersome. So I wrote a script to help me with it. It should help beginners get started with DllCall too. I was a little surprised that I didn't find something like this on the forum already. Maybe the intended audience doesn't have the same trouble that I do, or maybe those who don't "get" it don't care enough to. I'm hoping to bridge that gap a little. With this script, you can input the information from the MSDN documentation on a DLL function straight into the GUI and it will generate AutoIt code to call it and return its data. You can choose whether to report debugging information via ConsoleWrite or MsgBox or neither. It doesn't handle fancy things like DllStructs and callbacks, but it may help you get started. A great tutorial I used when I was starting to learn this stuff myself is Dealing with DLLs in AutoIt by Andreas Karlsson. My script is intended as a programmatic approximation of the concepts on pages 1 to 8 of that document. It is not a replacement for a good tutorial and self-learning. I wrote it as a shortcut for my own future use because I only wanted to learn it once. :-) Here it is. I'm curious to know what you all think. #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Library\Repositories #NO BACKUP#\Google Drive - Toastyking\Development\Snippet Library\AutoIt\CodeWizards\DllCallCodegen\FormMain.kxf $FormMain = GUICreate("DllCall Code Generator", 825, 421) $Label1 = GUICtrlCreateLabel("DLL Name", 16, 32, 55, 17) $InputDll = GUICtrlCreateInput("user32.dll", 120, 29, 121, 21) $Label2 = GUICtrlCreateLabel("Function Name", 16, 59, 76, 17) $InputFunc = GUICtrlCreateInput("", 120, 56, 121, 21) $RadioFuncAnsi = GUICtrlCreateRadio("ANSI", 256, 57, 49, 17) $RadioFuncUnicode = GUICtrlCreateRadio("Unicode", 312, 56, 73, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Label3 = GUICtrlCreateLabel("Return Type", 16, 85, 63, 17) $InputReturnType = GUICtrlCreateInput("int", 120, 82, 121, 21) $ComboCallConv = GUICtrlCreateCombo("", 120, 110, 121, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "stdcall|cdecl") $ListViewParams = GUICtrlCreateListView("#|Type|Value|Method", 16, 245, 362, 126, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_NOSORTHEADER)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 50) $Label4 = GUICtrlCreateLabel("For all types, use the type name specified on MSDN.", 16, 8, 251, 17) $Label5 = GUICtrlCreateLabel("Parameters:", 16, 136, 60, 17) $Label6 = GUICtrlCreateLabel("Type", 24, 157, 28, 17) $Label7 = GUICtrlCreateLabel("Value (0 for null)", 152, 157, 80, 17) $Label8 = GUICtrlCreateLabel("Method", 280, 157, 39, 17) $InputParamType = GUICtrlCreateInput("", 24, 176, 121, 21) $InputParamValue = GUICtrlCreateInput("", 152, 176, 121, 21) $ComboParamByref = GUICtrlCreateCombo("", 280, 176, 89, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Input/ByVal|Output/ByRef") $ButtonParamAdd = GUICtrlCreateButton("Add Parameter", 24, 213, 91, 25) $ButtonParamDelete = GUICtrlCreateButton("Clear All", 128, 213, 107, 25) $Label9 = GUICtrlCreateLabel("Calling convention", 16, 112, 91, 17) $Label10 = GUICtrlCreateLabel("Generated AutoIt code:", 409, 8, 115, 17) $EditCode = GUICtrlCreateEdit("", 408, 29, 401, 342, BitOR($ES_READONLY,$WS_HSCROLL,$WS_VSCROLL)) $ButtonTest = GUICtrlCreateButton("Test Code", 344, 381, 107, 25) $ButtonCopy = GUICtrlCreateButton("Copy to Clipboard", 464, 381, 107, 25) $ButtonInsert = GUICtrlCreateButton("Insert in SciTE", 586, 381, 107, 25) $ButtonGenonly = GUICtrlCreateButton("Nothing Else", 704, 381, 107, 25) $ComboOutput = GUICtrlCreateCombo("", 98, 383, 121, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "ConsoleWrite|MsgBox|$vDllCallReturn only") $Label11 = GUICtrlCreateLabel("Output method:", 16, 387, 77, 17) $Label12 = GUICtrlCreateLabel("Generate code and:", 232, 387, 99, 17) ;~ GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $aParams[1][3] GUICtrlSetData($ComboParamByref,"Input/ByVal") GUICtrlSetData($ComboOutput,"ConsoleWrite") GUICtrlSetData($ComboCallConv,"stdcall") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $ButtonParamAdd _ConvertType(GUICtrlRead($InputParamType)) ; Use the parameter type selected If @error Then If MsgBox(49,"Unrecognized Type","Unrecognized parameter type """ & GUICtrlRead($InputParamType) & """. Make sure you are using an MSDN return type." & @CRLF & @CRLF & "If you are certain that the parameter type is correct and you happen to know the equivalent AutoIt parameter type, click OK. You will be prompted later for the AutoIt parameter type.",0,$FormMain) = 2 Then ContinueLoop EndIf If GUICtrlRead($ComboParamByref) = "Output/ByRef" And StringLeft(GUICtrlRead($InputParamValue),1) <> "$" Then MsgBox(48,"Error","To use this parameter value as a ByRef, you must specify the name of a variable used in your AutoIt script, which must begin with a '$' symbol.",0,$FormMain) ContinueLoop EndIf ; Input seems okay; proceed. ReDim $aParams[UBound($aParams) + 1][3] ; Add a "row" to the array $aParams[UBound($aParams) - 1][0] = GUICtrlRead($InputParamType) $aParams[UBound($aParams) - 1][1] = GUICtrlRead($InputParamValue) $aParams[UBound($aParams) - 1][2] = GUICtrlRead($ComboParamByref) ; Clear input fields and refocus GUICtrlSetData($InputParamType,"") GUICtrlSetData($InputParamValue,"") GUICtrlSetData($ComboParamByref,"Input/ByVal") GUICtrlCreateListViewItem(UBound($aParams) - 1 & "|" & $aParams[UBound($aParams) - 1][0] & "|" & $aParams[UBound($aParams) - 1][1] & "|" & $aParams[UBound($aParams) - 1][2],$ListViewParams) ControlFocus($FormMain,"",$InputParamType) Case $ButtonParamDelete ; Delete all items _GUICtrlListView_DeleteAllItems($ListViewParams) ReDim $aParams[1][3] Case $ButtonTest $sDllCallOut = _GenerateCode("MsgBox") ; Always use MsgBox for output when generating for testing. GUICtrlSetData($EditCode,$sDllCallOut) If $sDllCallOut <> "" Then GUISetState(@SW_DISABLE,$FormMain) GUICtrlSetData($ButtonTest,"Executing...") FileDelete(@TempDir & "\DllCallExec.au3") FileWrite(@TempDir & "\DllCallExec.au3",$sDllCallOut); Write code to temporary file to be executed. $nExit = RunWait(@AutoItExe & ' /AutoIt3ExecuteScript "' & @TempDir & '\DllCallExec.au3"',@TempDir) ; Execute the temporary file. If $nExit <> 0 Then Switch $nExit Case 1 MsgBox(16,"DLL Code Generator","The AutoIt interpreter encountered an error while parsing or executing the generated code." & @CRLF & "Exit code: " & $nExit,0,$FormMain) Case Else MsgBox(16,"DLL Code Generator","There was a problem with the DllCall (possibly incorrect parameters). The AutoIt interpreter ended unexpectedly." & @CRLF & "Exit code: " & $nExit,0,$FormMain) EndSwitch EndIf GUICtrlSetData($ButtonTest,"Test Code") GUISetState(@SW_ENABLE,$FormMain) FileDelete(@TempDir & "\DllCallExec.au3") WinActivate($FormMain) EndIf Case $ButtonGenonly $sDllCallOut = _GenerateCode(GUICtrlRead($ComboOutput)) GUICtrlSetData($EditCode,$sDllCallOut) Case $ButtonCopy $sDllCallOut = _GenerateCode(GUICtrlRead($ComboOutput)) GUICtrlSetData($EditCode,$sDllCallOut) If ClipPut($sDllCallOut) Then ToolTip("Copied!") Else ToolTip("Copy failed!") EndIf Sleep(1000) ToolTip("") Case $ButtonInsert $sDllCallOut = _GenerateCode(GUICtrlRead($ComboOutput)) GUICtrlSetData($EditCode,$sDllCallOut) If ClipPut($sDllCallOut) Then ControlSend("[CLASS:SciTEWindow]","","Scintilla1","^v") Case $InputFunc If StringRight(GUICtrlRead($InputFunc),1) == "W" Then ; Check if last character of entered function name is a capital "W" GUICtrlSetState($RadioFuncUnicode,$GUI_CHECKED) Else GUICtrlSetState($RadioFuncAnsi,$GUI_CHECKED) EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _GenerateCode($sOutputType = "") Local $sArch, $sReturnTypeOut, $sParamTypeOut, $sDllFuncName, $sDllCallOut, $sCmdOutStart, $sCmdOutEnd, $fOutputGen Switch $sOutputType Case "ConsoleWrite" $sCmdOutStart = 'ConsoleWrite(' $sCmdOutEnd = ' & @CRLF)' $fOutputGen = 1 Case "MsgBox" $sCmdOutStart = 'MsgBox(0,"DllCall Code Generator",' $sCmdOutEnd = ')' $fOutputGen = 1 Case Else $sCmdOutStart = "" $sCmdOutEnd = "" $fOutputGen = 0 EndSwitch If GUICtrlRead($RadioFuncAnsi) = $GUI_CHECKED Then $sArch = "a" If GUICtrlRead($RadioFuncUnicode) = $GUI_CHECKED Then $sArch = "w" $sDllFuncName = GUICtrlRead($InputDll) & "/" & GUICtrlRead($InputFunc) $sReturnTypeOut = _ConvertType(GUICtrlRead($InputReturnType)) If @error Then $sReturnTypeOut = InputBox("Unrecognized Type","Unrecognized return type """ & GUICtrlRead($InputReturnType) & """. Make sure you are using an MSDN return type." & @CRLF & @CRLF & "If you are certain that the return type is correct and you happen to know the equivalent AutoIt return type, you may enter the AutoIt return type here.","","",Default,220,Default,Default,0,$FormMain) If $sReturnTypeOut = "" Then Return SetError(1,0,"") EndIf $sReturnTypeOut = _ConvertTypeArch($sReturnTypeOut,$sArch) If GUICtrlRead($ComboCallConv) <> "stdcall" Then $sReturnTypeOut &= ':' & GUICtrlRead($ComboCallConv) $sDllCallOut = 'Local $aDllCallReturn,$vDllCallReturn' $sDllCallOut = '$aDllCallReturn = DllCall("' & GUICtrlRead($InputDll) & '","' & $sReturnTypeOut & '","' & GUICtrlRead($InputFunc) & '"' If UBound($aParams) > 1 Then For $x = 1 To UBound($aParams) - 1 $sParamTypeOut = '' $sParamTypeOut = _ConvertTypeArch(_ConvertType($aParams[$x][0]),$sArch) If $sParamTypeOut = '' Then $sParamTypeOut = InputBox("Unrecognized Type","Unrecognized parameter type """ & $aParams[$x][0] & """. Make sure you are using an MSDN parameter type." & @CRLF & @CRLF & "If you are certain that the parameter type is correct and you happen to know the equivalent AutoIt parameter type, you may enter the AutoIt parameter type here.","","",Default,220,Default,Default,0,$FormMain) If $sParamTypeOut = "" Then Return(SetError(1,0,"")) If StringRight($sParamTypeOut,1) = "*" Then $sParamTypeOut = StringTrimRight($sParamTypeOut,1) ; If the user added an asterisk to the end of the parameter type, remove it; it will be added back later if necessary. EndIf $sDllCallOut &= ',"' & $sParamTypeOut If $aParams[$x][2] = "Output/ByRef" Then $sDllCallOut &= '*' $sDllCallOut &= '","' & $aParams[$x][1] & '"' Next EndIf $sDllCallOut &= ')' & @CRLF ; Generate code to check for DllCall execution error. If $fOutputGen = 1 Then $sDllCallOut &= _ 'If @error Then' & @CRLF & _ ' Switch @error' & @CRLF & _ ' Case 1' & @CRLF & _ ' ' & $sCmdOutStart & '"DllCall error (' & $sDllFuncName & '): Unable to use the DLL file. Possibly a problem with the parameters."' & $sCmdOutEnd & @CRLF & _ ' Case 2' & @CRLF & _ ' ' & $sCmdOutStart & '"DllCall error (' & $sDllFuncName & '): Unknown return type."' & $sCmdOutEnd & @CRLF & _ ' Case 3' & @CRLF & _ ' ' & $sCmdOutStart & '"DllCall error (' & $sDllFuncName & '): Function not found in DLL file. Remember that function names are case sensitive."' & $sCmdOutEnd & @CRLF & _ ' Case 4' & @CRLF & _ ' ' & $sCmdOutStart & '"DllCall error (' & $sDllFuncName & '): Incorrect number of parameters."' & $sCmdOutEnd & @CRLF & _ ' Case 5' & @CRLF & _ ' ' & $sCmdOutStart & '"DllCall error (' & $sDllFuncName & '): Bad parameter."' & $sCmdOutEnd & @CRLF & _ ' Case Else' & @CRLF & _ ' ' & $sCmdOutStart & '"DllCall error (' & $sDllFuncName & '): Unknown/unspecified error."' & $sCmdOutEnd & @CRLF & _ ' EndSwitch' & @CRLF & _ ' $vDllCallReturn = ""' & @CRLF & _ 'Else' & @CRLF If $fOutputGen = 1 Then $sDllCallOut &= ' ' $sDllCallOut &= '$vDllCallReturn = $aDllCallReturn[0]' & @CRLF ; Generate code to assign returned ByRef values back to their AutoIt variables. If UBound($aParams) > 1 Then For $x = 1 To UBound($aParams) - 1 If $aParams[$x][2] = "Output/ByRef" Then If $fOutputGen = 1 Then $sDllCallOut &= ' ' $sDllCallOut &= $aParams[$x][1] & ' = $aDllCallReturn[' & $x & ']' & @CRLF EndIf Next EndIf ; Generate code to output values of the variables passed to the DllCall via ByRef. If $fOutputGen = 1 Then $sDllCallOut &= ' ' & $sCmdOutStart If UBound($aParams) > 1 Then For $x = 1 To UBound($aParams) - 1 If $aParams[$x][2] = "Output/ByRef" Then $sDllCallOut &= '"' & $aParams[$x][1] & ' = " & ' & $aParams[$x][1] & ' & @CRLF & ' EndIf Next EndIf $sDllCallOut &= '"DllCall return value: " & $vDllCallReturn' & $sCmdOutEnd & @CRLF $sDllCallOut &= "EndIf" & @CRLF EndIf Return $sDllCallOut EndFunc ; Convert the MSDN variable type to AutoIt variable type Func _ConvertType($MSDN_Type) Switch $MSDN_Type Case 'ATOM' Return 'WORD' Case 'BOOL' Return 'BOOL' Case 'BOOLEAN' Return 'BOOLEAN' Case 'BYTE' Return 'BYTE' Case 'CHAR' Return 'str' Case 'COLORREF' Return 'DWORD' Case 'CONST' Return 'const' Case 'DWORD' Return 'DWORD' Case 'DWORDLONG' Return 'ULONG' Case 'DWORD_PTR' Return 'DWORD_PTR' Case 'DWORD32' Return 'UINT' Case 'DWORD64' Return 'INT64' Case 'FLOAT' Return 'FLOAT' Case 'HACCEL' Return 'HANDLE' Case 'HALF_PTR' Return 'ptr' Case 'HANDLE' Return 'HANDLE' Case 'HBITMAP' Return 'HANDLE' Case 'HBRUSH' Return 'HANDLE' Case 'HCONV' Return 'HANDLE' Case 'HCONVLIST' Return 'HANDLE' Case 'HCURSOR' Return 'HICON' Case 'HDC' Return 'HANDLE' Case 'HDDEDATA' Return 'HANDLE' Case 'HDESK' Return 'HANDLE' Case 'HDROP' Return 'HANDLE' Case 'HDWP' Return 'HANDLE' Case 'HENHMETAFILE' Return 'HANDLE' Case 'HFILE' Return 'int' Case 'HFONT' Return 'HANDLE' Case 'HGIDOBJ' Return 'HANDLE' Case 'HGLOBAL' Return 'HANDLE' Case 'HHOOK' Return 'HANDLE' Case 'HICON' Return 'HANDLE' Case 'HINSTANCE' Return 'HANDLE' Case 'HKEY' Return 'HANDLE' Case 'HKL' Return 'HANDLE' Case 'HLOCAL' Return 'HANDLE' Case 'HMENU' Return 'HANDLE' Case 'HMETAFILE' Return 'HANDLE' Case 'HMODULE' Return 'HANDLE' Case 'HMONITOR' Return 'HANDLE' Case 'HPALETTE' Return 'HANDLE' Case 'HPEN' Return 'HANDLE' Case 'HRESULT' Return 'LONG' Case 'HRGN' Return 'HANDLE' Case 'HRSRC' Return 'HANDLE' Case 'HSZ' Return 'HANDLE' Case 'HWINSTA' Return 'HANDLE' Case 'HWND' Return 'HWND' Case 'INT_PTR' Return 'INT_PTR' Case 'INT32' Return 'int' Case 'INT' Return 'int' Case 'INT64' Return 'INT64' Case 'LANGID' Return 'WORD' Case 'LARGE_INTEGER' Return 'INT64' Case 'LCID' Return 'DWORD' Case 'LGRPID' Return 'DWORD' Case 'LONG' Return 'LONG' Case 'LONGLONG' Return 'INT64' Case 'LONG_PTR' Return 'LONG_PTR' Case 'LONG32' Return 'int' Case 'LONG64' Return 'INT64' Case 'LPARAM' Return 'LPARAM' Case 'LPBOOL' Return 'int' Case 'LPBYTE' Return 'int' Case 'LPCOLORREF' Return 'DWORD' Case 'LPCSTR' Return 'str' Case 'LPCTSTR' Return 'str' Case 'LPCWSTR' Return 'wstr' Case 'LPDWORD' Return 'DWORD' Case 'LPHANDLE' Return 'HANDLE' Case 'LPINT' Return 'int' Case 'LPLONG' Return 'long' Case 'LPSTR' Return 'str' Case 'LPTSTR' Return 'str' Case 'LPVOID' Return 'ptr' Case 'LPWORD' Return 'WORD' Case 'LPWSTR' Return 'wstr' Case 'LRESULT' Return 'LRESULT' Case 'PBOOL' Return 'BOOL' Case 'PBOOLEAN' Return 'BOOLEAN' Case 'PBYTE' Return 'BYTE' Case 'PCHAR' Return 'str' Case 'PCSTR' Return 'str' Case 'PCTSTR' Return 'str' Case 'PCWSTR' Return 'wstr' Case 'PDWORD' Return 'DWORD' Case 'PDWORDLONG' Return 'UINT64' Case 'PDWORD_PTR' Return 'DWORD_PTR' Case 'PDWORD32' Return 'UINT' Case 'PDWORD64' Return 'INT64' Case 'PFLOAT' Return 'FLOAT' Case 'PHALF_PTR' Return 'ptr' Case 'PHANDLE' Return 'HANDLE' Case 'PHKEY' Return 'HANDLE' Case 'PINT' Return 'int' Case 'PINT_PTR' Return 'INT_PTR' Case 'PINT32' Return 'int' Case 'PINT64' Return 'INT64' Case 'PLCID' Return 'DWORD' Case 'PLONG' Return 'LONG' Case 'PLONGLONG' Return 'INT64' Case 'PLONG_PTR' Return 'LONG_PTR' Case 'PLONG32' Return 'long' Case 'PLONG64' Return 'INT64' Case 'POINTER_32' Return 'ptr' Case 'POINTER_64' Return 'ptr' Case 'POINTER_SIGNED' Return 'ptr' Case 'POINTER_UNSIGNED' Return 'ULONG_PTR' Case 'PSHORT' Return 'SHORT' Case 'PSIZE_T' Return 'ULONG_PTR' Case 'PSSIZE_T' Return 'LONG_PTR' Case 'PSTR' Return 'str' Case 'PTBYTE' Return 'BYTE' Case 'PTCHAR' Return 'wstr' Case 'PTSTR' Return 'wstr' Case 'PUCHAR' Return 'BYTE' Case 'PUHALF_PTR' Return 'ptr' Case 'PUINT' Return 'UINT' Case 'PUINT_PTR' Return 'UINT_PTR' Case 'PUINT32' Return 'UINT' Case 'PUINT64' Return 'UINT64' Case 'PULARGE_INTEGER' Return 'UINT64' Case 'PULONG' Return 'ULONG' Case 'PULONGLONG' Return 'UINT64' Case 'PULONG_PTR' Return 'ULONG_PTR' Case 'PULONG32' Return 'ULONG' Case 'PULONG64' Return 'UINT64' Case 'PUSHORT' Return 'USHORT' Case 'PVOID' Return 'ptr' Case 'PWCHAR' Return 'wstr' Case 'PWORD' Return 'WORD' Case 'PWSTR' Return 'wstr' Case 'SC_HANDLE' Return 'HANDLE' Case 'SC_LOCK' Return 'ptr' Case 'SERVICE_STATUS_HANDLE' Return 'HANDLE' Case 'SHORT' Return 'SHORT' Case 'SIZE_T' Return 'ULONG_PTR' Case 'SSIZE_T' Return 'LONG_PTR' Case 'TBYTE' Return 'wstr' Case 'TCHAR' Return 'wstr' Case 'UCHAR' Return 'BYTE' Case 'UHALF_PTR' Return 'ptr' Case 'UINT' Return 'UINT' Case 'UINT_PTR' Return 'UINT_PTR' Case 'UINT32' Return 'UINT' Case 'UINT64' Return 'UINT64' Case 'ULARGE_INTEGER' Return 'UINT64' Case 'ULONG' Return 'ULONG' Case 'ULONGLONG' Return 'UINT64' Case 'ULONG_PTR' Return 'ULONG_PTR' Case 'ULONG32' Return 'ULONG' Case 'ULONG64' Return 'UINT64' Case 'UNICODE_STRING' Return 'ptr' Case 'USHORT' Return 'USHORT' Case 'USN' Return 'INT64' Case 'VOID' Return 'none' Case 'WCHAR' Return 'wstr' Case 'WORD' Return 'WORD' Case 'WPARAM' Return 'WPARAM' Case Else SetError(1) Return "" EndSwitch EndFunc ;==> ; Some variable types should be converted from their ANSI to Unicode types or vice versa. Func _ConvertTypeArch($MSDN_Type,$sArch) Switch $MSDN_Type Case 'STR' If $sArch = "a" Then Return "str" If $sArch = "w" Then Return "wstr" Case 'WSTR' If $sArch = "a" Then Return "str" If $sArch = "w" Then Return "wstr" Case Else Return $MSDN_Type EndSwitch EndFunc Here is an example: Function: GetDiskFreeSpaceW (MSDN page: http://msdn.microsoft.com/en-us/library/aa364935(VS.85).aspx) Input this: Click Test Code, and get this: Click Insert in SciTE to insert the code into your script. Updated 2014/01/28: Edit 2015/11/25: Fixed broken link
    1 point
  3. Turtlix21, What have spaces got to do with it? #include <GUIConstantsEx.au3> #include <Array.au3> #include <StringConstants.au3> $sText = "Line 1" & @CRLF & _ "Line 2 with lots of spaces" & @CRLF & _ "Line 3" $hGUI = GUICreate("Test", 500, 500) $cEdit = GUICtrlCreateEdit($sText, 10, 10, 480, 300) $cButton = GUICtrlCreateButton("Read", 10, 400, 80, 30) GUICtrlSetState($cButton, $GUI_FOCUS) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton $sRead = GUICtrlRead($cEdit) $aLines = StringSplit($sRead, @CRLF, $STR_ENTIRESPLIT) _ArrayDisplay($aLines, "Edit Content", Default, 8) EndSwitch WEndM23
    1 point
  4. Older version of the language doesn't know about "struct*". If you want it to work there replace: ...'struct*', $tGTI...with: ...'ptr', DllStructGetPtr($tGTI)
    1 point
  5. Or this one.
    1 point
  6. Please have a look at this thread.
    1 point
  7. jchd

    Dealing with time

    AdLibRegister ?
    1 point
  8. jchd

    SQLITE progress handler

    Skysnake, The call doesn't return a value. Also you don't explain why and how this can be useful. The name $Timer is misleading, since it doesn't refer to any notion of time. This integer represents the number of "JUMP" instructions in the VDBE (the bytecode generated by a given query being executed) between invokations of the user-supplied function. This number may greatly vary between different versions of sqlite3.dll for a given schema, data and query and it doesn't represent a measurable duration nor a percentage of the progress of the query to completion. The user-supplied function cannot issue SQLite calls on the same DB connection, or an application crash may occur. The only legitimate purpose of the user-supplied function should be to keep a GUI alive or something similar. But before using it, the question of why one needs it must be carefully examined. It's quite possible that a long-running query is in fact largely sub-optimal due to inadequate schema or badly written query. Most of the times the running time can see order(s) of magnitude improvements by relatively simple optimizations or schema change. I'm not critisizing, just drawing attention.
    1 point
  9. Not sure what your problem is. Compile as an EXE, place it in the Startup folder and it will run on boot... Put a Sleep() at the top, to avoid clashing with the actual boot procedure, so when the boot is complete, your script will run. On Windows 8+ go press the Windows key+R then type shell:startup, it should open the Startup folder.
    1 point
  10. ​Use GUICtrlRead with 'advanced' mode Func _Font_Size() MsgBox(0,"",GUICtrlRead(@GUI_CtrlId, 1)) EndFunc
    1 point
  11. For things that I have a control, but then want data attached to that control, I create a 2d array... So $x[0] [0] is the control handle $x[0][1] is data (like the font name) Then when the use clicks a control, I loop through my array matching to clicked control to index 0, and return the value of index 1
    1 point
  12. Go here: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\Performance\Boot setting the bootminorthreshold and/or postbootminorthreshold to something like 1 sec. Would think every boot after that would log as a warning. Totally untested, but i assume that is what snotrag is for.
    1 point
  13. Jon

    Forum Upgrade Status

    Added a plugin to show recently updated files in the Downloads section.
    1 point
  14. junkew

    Android UDF

    It looks all possible to directly talk to android phone with ADB daemon/server running (lot of work to extend in udf), easy testable on cmldine with ADB <command> and in previous example shown in code that you can start ADB.EXE / Server/Shell in an interactive way (removing overhead of starting adb over and over again) XML snapshot to identify elements can be done with Store an xml dump on the phone adb shell uiautomator.dump Get it to your local directory adb shell pull /storage/sdcard0/window_dump.xml test.xml Interpret the xml TODO ;-) Sending events Sending events (key, mouse, tap etc.) to your android phone is based on the linux event model and can be done with adb shell sendevent http://ktnr74.blogspot.nl/2013/06/emulating-touchscreen-interaction-with.html background reading https://source.android.com/devices/input/overview.html https://www.kernel.org/doc/Documentation/input/event-codes.txt https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt
    1 point
  15. Why are you even picking on me BrewManNH? I feel like I've helped more than hurt! I was just expressing a quick opinion! I've re-written this response like 5 times and I'm just going to leave it at this; My post did provide some relevant information that you have either ignored or overlooked. I have edited my previous post to better represent the relevant material. However, nothing was added or removed. Your post, ultimately, served only as a Personal Message to me, indicating that you'd prefer to keep opinions to a minimum... ​I completely thought you goofed! Getting the version number of an app that returns the version number?! After some testing, though... I can see that the version output of WinVer.exe reflects the actual version of WinVer.exe itself, which is the OS Kernel version. No difference appears to exist in collecting the version from WinVer, ntoskrnl.exe, and Kernel32.dll. They should all report the exact same Kernel version #, up to Major.Minor.Build... The 4th attribute may be some-sort of build variant, but doesn't seem to cause any issues. The 4th attribute may vary between ntoskrnl.exe and Kernel32.dll, but everything else should be the same. *Ahem, all of the below is related to Windows 10, ignore if unneeded...
    1 point
  16. Maybe with GetTickCount? Call it when your PC is finished with booting. Maybe in with Startup or Logonscript. Since I never test it this way, I can not say when GetTickCount start to count.
    1 point
  17. reb

    Shift key stuck plz help me!

    check the help file for send. especially this part "To hold a key down Send("{a down}") ;Holds the A key down Send("{a up}") ;Releases the A key" send(" {ENTER up}") might do. your link test - Copy - Copy.au3 is not working for me so this is just a guess. good luck
    1 point
  18. jvanegmond

    WinHTTP functions

    Hey Raizeno, try this: #include "WinHttp.au3" $sAddress = "https://api.pushover.net/1/messages.json" $sApiToken = "av26ac2nAXLyPKg2QMy4zf9YcUjz2G" ; <-yours here $sUserKey = "uMQf396GvMgrsDroaryKEvVyWkgfkw" ; <-yours here $sMessage = "hello world" ; Construct the form Const $sForm = '<form action="' & $sAddress & '" method="post">' & _ '<input name="token" value="' & $sApiToken & '"/>' & _ '<input name="user" value="' & $sUserKey & '"/>' & _ '<input name="message" value="' & $sMessage & '"/>' & _ '</form>' ; Open session $hOpen = _WinHttpOpen() ; To collect connection handle (because the form is inlined) $hConnect = $sForm ; Fill the form $sRead = _WinHttpSimpleFormFill($hConnect, $hOpen) ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Tada mtfk! MsgBox(4096, "Simon says", $sRead)
    1 point
  19. May be some of you know the shareware VectorMagic who permit to easily convert bitmap Images to clean Vector Art ! Pic2Vector 1.0.1.4 is free, and can give similar effects ! I was interested by some effects added to a photo. I'm not using gdi for the vectorization, but 2 command line tools : Autotrace 0.27 with ILDA file support for converting bitmap to vector graphics Custom Version at : http://www.raycomposer.de/en/ressources/autotrace/ More general infos : http://autotrace.sourceforge.net/ GPL Ghostscript 9.07 use here for converting vector graphics to Jpeg. More infos : http://www.ghostscript.com/doc/9.07/Use.htm# example 1 example 2 example 3 example 4 example 5 example 6 example 7 example 8 Free to you to play with settings for see changes.(Infos with tooltip added to each type of setting) If UAC Enable, use right click, execute as Admin. Click on vectorized Pic for display it in fullscreen with Windows picture Viewer. You can save result to jpg, png, bmp or gif format. Changes Version 1.0.1.4 Settings can be saved by creating a profil. No more appcrash window for autotrace.exe. New buttons for display compatibility with xp. Externals files are embedded, no more downloads needed. Some minor improvements. Added new examples to topic. Tested with WinXp, Win7 and Win 8.1. previous downloads : 666 source and executable are available in the Download Section Hope you like it !
    1 point
×
×
  • Create New...