Jump to content

Leaderboard

Popular Content

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

  1. I was looking for some examples of custom drawn TreeViews. I didn't find any so here is two. I have made the examples for ListViews too. The first example shows some named colors from the MS HTML documentation. The colors are sorted in different ways in five text files in the zipfile. The forecolor, backcolor, color name and RGB value is shown in the GUI's. Remark that the forecolor in the first column in the ListView is bold. Click on the colors in the TreeView to see some of the effects of custom drawing. The second example enumerates the fonts for the character sets in FontConstants.au3 and shows the fonts in the GUI's. Click on the fonts in the TreeView to see the name of the fonts. The zipfile contains 5 text files with color definitions and 4 au3-files with GUI's. CustDrawTvLv.zip 2016-03-22: For colors and fonts in listviews take a look at Colors and fonts in custom drawn ListViews - UDF version.
    1 point
  2. Finally I am getting familiar with assembly. I got it working with 64bit and 32bit: #include <windowsconstants.au3> #include <WinAPI.au3> #include <Memory.au3> Global Const $WM_TRAYNOTIFY = $WM_USER + 1 Global Const $NIN_BALLOONSHOW = $WM_USER + 2 Global Const $NIN_BALLOONHIDE = $WM_USER + 3 Global Const $NIN_BALLOONUSERCLICK = $WM_USER + 5 Global Const $NIN_BALLOONTIMEOUT = $WM_USER + 4 Global Const $__gpTrayNotifySubclassProc = __TrayNotify_CreateSubclassProc() Func __TrayNotify_CreateSubclassProc() ; ASM by ProgAndy Local $aCall = DllCall("kernel32.dll", "ptr", "GetProcAddress", "handle", _WinAPI_GetModuleHandle("user32.dll"), "str", "PostMessageW") Local $pPostMessageW = $aCall[0] $aCall = DllCall("kernel32.dll", "ptr", "GetProcAddress", "handle", _WinAPI_GetModuleHandle("Comctl32.dll"), "str", "DefSubclassProc") Local $pDefSubclassProc = $aCall[0] ; dwRefData (parameter #6) will be target window If @AutoItX64 Then; x64 #cs use64 push rbp mov rbp, rsp sub rsp, 32 ; shadow space for api calls CMP RDX, 401h ; WM_TRAYNOTIFY jnz after_notify notify: mov [rbp+10h], RCX ; save registers to own shadow space mov [rbp+18h], RDX mov [rbp+20h], R8 mov [rbp+28h], R9 mov rcx, [rbp+38h] ; hWndRedirect mov rax, 22FF22FF22FF22FFh ; DUMMY 2 call rax ; call PostMessageW mov R9, qword[ebp+28h] ; lparam ; restore registers for next call mov R8, qword[ebp+20h] ; wparam mov RDX, qword[ebp+18h] ; uMsg mov RCX, qword[ebp+10h] ; hWnd after_notify: mov rax, 33FF33FF33FF33FFh ; DUMMY 3 call rax ; call DefSubclassProc add rsp, 32 pop rbp ret ; x64 MS-FASTCALL #ce Local $b = Binary("0x554889e54883ec204881fa01040000753448894d10488955184c8945204c894d28488b4d3848b8")&Binary($pPostMessageW)&Binary("0xffd0674c8b4d28674c8b452067488b551867488b4d1048b8")&Binary($pDefSubclassProc)&Binary("0xffd04883c4205dc3") Else; x86 #cs use32 push ebp mov ebp, esp CMP dword[ebp+12], 401h ; WM_TRAYNOTIFY jnz after_notify notify: push dword[ebp+20] ; lparam push dword[ebp+16] ; wparam push dword[ebp+12] ; uMsg push dword[ebp+28] ; hWndRedirect mov eax, 22FF22FFh ; DUMMY 2 call eax ; call PostMessageW after_notify: push dword[ebp+20] ; lparam push dword[ebp+16] ; wparam push dword[ebp+12] ; uMsg push dword[ebp+8] ; hWnd mov eax, 33FF33FFh ; DUMMY 3 call eax ; call DefSubclassProc pop ebp ret 24 ; 6 parameters stdcall #ce Local $b = Binary("0x5589e5817d0c010400007513ff7514ff7510ff750cff751cb8")&Binary($pPostMessageW)&Binary("0xffd0ff7514ff7510ff750cff7508b8")&Binary($pDefSubclassProc)&Binary("0xffd05dc21800") EndIf Local $pMem = _MemVirtualAlloc(0, BinaryLen($b), $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) Local $t = DllStructCreate("byte[" & BinaryLen($b) & "]", $pMem) DllStructSetData($t, 1, $b) Return $pMem EndFunc Func _TrayNotify_Redirect($hWndRedirect) DllCall("comctl32.dll", "bool", "SetWindowSubclass", "hwnd", __TrayNotify_AutoItWinGetHandle(), "ptr", $__gpTrayNotifySubclassProc, "uint_ptr", $hWndRedirect, "dword_ptr", $hWndRedirect) EndFunc Func _TrayNotify_RemoveRedirect($hWndRedirect) DllCall("comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", __TrayNotify_AutoItWinGetHandle(), "ptr", $__gpTrayNotifySubclassProc, "uint_ptr", $hWndRedirect) EndFunc Func __TrayNotify_AutoItWinGetHandle() Local Static $h If IsHWnd($h) Then Return $h Local $t = AutoItWinGetTitle() AutoItWinSetTitle("096c7d2e-4d24-4103-9503-66748fa96cc7#" & @AutoItPID) $h = WinGetHandle("096c7d2e-4d24-4103-9503-66748fa96cc7#" & @AutoItPID) AutoItWinSetTitle($t) Return $h EndFunc Opt('TrayAutoPause', 0) Opt('WinTitleMatchMode', 3) Opt('WinWaitDelay', 0) Opt('TrayMenuMode', 3) Global $iTip = 2 Global $hForm = GUICreate('') DllOpen("comctrl32.dll") _TrayNotify_Redirect($hForm) GUIRegisterMsg($WM_TRAYNOTIFY, 'WM_TRAYNOTIFY') Global $iShow = TrayCreateItem("Show New Tip") TrayCreateItem("") Global $iExit = TrayCreateItem("Exit") TrayTip('Tip', 'This is a tray tip, click here.', 10, 1) While 1 Switch TrayGetMsg() Case $iShow TrayTip('Tip', 'This is a tray tip, click here. [ ' & $iTip & ' ]', 10, 1) $iTip += 1 Case $iExit ExitLoop EndSwitch WEnd _TrayNotify_RemoveRedirect($hForm) Func WM_TRAYNOTIFY($hWnd, $iMsg, $wParam, $lParam) Switch $hWnd Case $hForm Switch $lParam Case $NIN_BALLOONSHOW ConsoleWrite('Balloon tip show.' & @CR) Case $NIN_BALLOONHIDE ConsoleWrite('Balloon tip hide.' & @CR) Case $NIN_BALLOONUSERCLICK ConsoleWrite('Balloon tip click.' & @CR) Case $NIN_BALLOONTIMEOUT ConsoleWrite('Balloon tip close.' & @CR) EndSwitch EndSwitch EndFunc ;==>WM_TRAYNOTIFY
    1 point
  3. Zedna

    Encription

    Yes. There is standard Crypt UDF. See helpfile for details.
    1 point
  4. BrewManNH

    AdlibRegister

    There's a bug report on the Tracker reporting that the option for TCPTimeout doesn't seem to do anything, looks like it takes about 20 seconds before it times out and throws an error message back. EDIT: I found that JScript started, and ProgAndy added to, that has an alternate TCPConnect that includes a timeout parameter that might work better for you than the built-in TCPConnect.
    1 point
  5. spudw2k

    get tree path/value

    $selection = _GUICtrlTreeView_GetSelection($hWnd) $txt = _TreePath($hWnd,$selection) Func _TreePath($hWnd, $item) ;Determine full path of selected item in TreeView $txt = _GUICtrlTreeView_GetText($hWnd, $item) Do $parent = _GUICtrlTreeView_GetParentHandle($hWnd, $item) If $parent > 0 Then $txt = _GUICtrlTreeView_GetText($hWnd, $parent) & "" & $txt $item = $parent EndIf Until $parent = 0 Return StringTrimLeft($txt,StringInstr($txt,"")) EndFunc ;==>;_TreePath edit: 1000th post.
    1 point
  6. Pure AutoIt works for me... #include <windowsconstants.au3> Opt('TrayAutoPause', 0) Opt('WinTitleMatchMode', 3) Opt('WinWaitDelay', 0) Opt('TrayMenuMode', 3) Global Const $WM_TRAYNOTIFY = $WM_USER + 1 Global Const $NIN_BALLOONSHOW = $WM_USER + 2 Global Const $NIN_BALLOONHIDE = $WM_USER + 3 Global Const $NIN_BALLOONUSERCLICK = $WM_USER + 5 Global Const $NIN_BALLOONTIMEOUT = $WM_USER + 4 Global Const $subID = 1234 Global $iTip = 2 Global $psub = DllCallbackRegister("_subclass", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") Global $hForm = GUICreate('') DllCall("comctl32.dll", "bool", "SetWindowSubclass", "hwnd", WinGetHandle(AutoItWinGetTitle()), "ptr", DllCallbackGetPtr($psub), "uint_ptr", $subID, "dword_ptr", 0) GUIRegisterMsg($WM_TRAYNOTIFY, 'WM_TRAYNOTIFY') Global $iShow = TrayCreateItem("Show New Tip") TrayCreateItem("") Global $iExit = TrayCreateItem("Exit") TrayTip('Tip', 'This is a tray tip, click here.', 10, 1) While 1 Switch TrayGetMsg() Case $iShow TrayTip('Tip', 'This is a tray tip, click here. [ ' & $iTip & ' ]', 10, 1) $iTip += 1 Case $iExit ExitLoop EndSwitch WEnd DllCall("comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", WinGetHandle(AutoItWinGetTitle()), "ptr", DllCallbackGetPtr($psub), "uint_ptr", $subID) DllCallbackFree($psub) Func WM_TRAYNOTIFY($hWnd, $iMsg, $wParam, $lParam) Switch $hWnd Case $hForm Switch $lParam Case $NIN_BALLOONSHOW ConsoleWrite('Balloon tip show.' & @CR) Case $NIN_BALLOONHIDE ConsoleWrite('Balloon tip hide.' & @CR) Case $NIN_BALLOONUSERCLICK ConsoleWrite('Balloon tip click.' & @CR) Case $NIN_BALLOONTIMEOUT ConsoleWrite('Balloon tip close.' & @CR) EndSwitch EndSwitch EndFunc ;==>WM_TRAYNOTIFY Func _subclass($hwnd, $uMsg, $wParam, $lParam, $uIdSubclass, $dwRefData) #forceref $hwnd, $uMsg, $wParam, $lParam, $uIdSubclass, $dwRefData Switch $uMsg Case $WM_TRAYNOTIFY Switch $uIdSubclass Case $subID Switch $lParam Case $NIN_BALLOONSHOW, $NIN_BALLOONHIDE, $NIN_BALLOONUSERCLICK, $NIN_BALLOONTIMEOUT If $hForm Then DllCall("user32.dll", "bool", "PostMessageW", "hwnd", $hForm, "uint", $uMsg, "wparam", $wParam, "lparam", $lParam) EndIf EndSwitch EndSwitch EndSwitch Local $ret = DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hwnd, "uint", $uMsg, "wparam", $wParam, "lparam", $lParam) Return $ret[0] EndFunc However as noted in MSDN in the comments, there is no differentiation between a timeout and a close event. Seems like a Windows bug.
    1 point
  7. water

    Choose variable value

    Sure. Please have a look at FileReadLine or if it is an INI file look at the Ini* functions.
    1 point
  8. PhoenixXL

    Choose variable value

    Choice is Yours Water has also Given You the Answer of Your Question If dont like Complex Things dont Try my Code But The Input Style Looks Cool this Way I love it this Way If Cancel Button is Pressed The Function will Return -1 as an Integer Note if you type -1 and Press OK it will Return as a String Code: Global $ghGDIPBrush = 0 Global $ghGDIPDll = 0 Global $ghGDIPPen = 0 Global $giGDIPRef = 0 Global $giGDIPToken = 0 Global Const $tagGDIPSTARTUPINPUT = "int Version;ptr Callback;int NoThread;int NoCodecs" $variable=_GetInput('Title Goes Here....',100,'Type Your Text','Fields Empty') ConsoleWrite($variable) Func _GetInput($sTitle,$sBig=100,$sText='PassWord',$sSecondaryText='Please Enter Some Text',$sFirstButton='Ok',$sSecondButton='Cancel') Local $sPrevious=Opt('GUIOnEventMode',0) $hGui= GUICreate($sTitle, 350, $sBig, -1, -1 , 0x80000000, BITOR(0x00000080,0x00000008)) GUISetBkColor(0) Local $sLabel[3]=[GUICtrlCreateLabel($sText,20,10,200,15),GUICtrlCreateLabel($sFirstButton,150,$sBig-30,50,12),GUICtrlCreateLabel($sSecondButton,200,$sBig-30,50,12)] For $i=0 To 2 GUICtrlSetColor($sLabel[$i],0xffffff) GUICtrlSetBkColor($sLabel[$i],-2) If $i=0 Then ContinueLoop GUICtrlSetCursor($sLabel[$i],0) Next Local $sInput=GUICtrlCreateEdit('',20,30,260,$sBig-65,64);$ES_AUTOVSCROLL+$WS_VSCROLL Local $sPos=ControlGetPos($hGui,'',$sInput) ;ConsoleWrite('X:'&$sPos[0]&@TAB&'Y:'&$sPos[1]&@TAB&'Width:'&$sPos[2]&@TAB&'Height:'&$sPos[3]&@CRLF) ;_ScrollBar_Create($hGui,$sInput) WinSetTrans($hGui, "", 0) GUISetBkColor(0) GUISetState(@SW_SHOW, $hGui) _DrawLine($hGui,10, $sBig-25,90,$sBig-25) _DrawLine($hGui,10, $sBig-15,70, $sBig-15) _DrawLine($hGui,15, 10,15, $sBig-10) _DrawLine($hGui,200, 10,290, 10) _DrawLine($hGui,240, 20,290, 20) _DrawLine($hGui,285, 7,285, $sBig-10) GUICtrlCreatePic('',0,0,350,$sBig,-1,0x00100000) For $I = 0 To 207 Step 0.02 WinSetTrans($hGui, "", $I) Next Local $sMsg While $sMsg<>-3 $sMsg=GUIGetMsg() Switch $sMsg Case $sLabel[1] Switch GUICtrlRead($sInput) Case '' GUICtrlSetData($sLabel[0],$sSecondaryText) ContinueLoop EndSwitch Opt('GUIOnEventMode',$sPrevious) Return GUICtrlRead($sInput) Case $sLabel[2] ExitLoop EndSwitch WEnd For $I = 207 To 0 Step -0.02 WinSetTrans($hGui, "", $I) Next GUIDelete($hGui) Opt('GUIOnEventMode',$sPrevious) Return -1 EndFunc Func _DrawLine($Gui,$x1,$y1,$x2,$y2,$sChannel='80FFD700') Local $hGraphic, $hPen ; Draw line _GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($Gui) $hPen = _GDIPlus_PenCreate ('0x'&$sChannel) If Not _GDIPlus_GraphicsDrawLine ($hGraphic, $x1,$y1,$x2,$y2, $hPen) Then ConsoleWrite('Error:'&@error&@CRLF) ; Clean up resources _GDIPlus_PenDispose ($hPen) _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_ShutDown () ;Done..... EndFunc ;==>_Main #region -GDI + Func _GDIPlus_Startup() $giGDIPRef += 1 If $giGDIPRef > 1 Then Return True $ghGDIPDll = DllOpen("GDIPlus.dll") If $ghGDIPDll = -1 Then Return SetError(1, 2, False) Local $tInput = DllStructCreate($tagGDIPSTARTUPINPUT) Local $pInput = DllStructGetPtr($tInput) Local $tToken = DllStructCreate("ulong_ptr Data") Local $pToken = DllStructGetPtr($tToken) DllStructSetData($tInput, "Version", 1) Local $aResult = DllCall($ghGDIPDll, "int", "GdiplusStartup", "ptr", $pToken, "ptr", $pInput, "ptr", 0) If @error Then Return SetError(@error, @extended, False) $giGDIPToken = DllStructGetData($tToken, "Data") Return $aResult[0] = 0 EndFunc ;==>_GDIPlus_Startup Func _GDIPlus_GraphicsCreateFromHWND($hWnd) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateFromHWND", "hwnd", $hWnd, "ptr*", 0) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $aResult[2]) EndFunc ;==>_GDIPlus_GraphicsCreateFromHWND Func _GDIPlus_PenCreate($iARGB = 0xFF000000, $fWidth = 1, $iUnit = 2) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePen1", "dword", $iARGB, "float", $fWidth, "int", $iUnit, "ptr*", 0) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $aResult[4]) EndFunc ;==>_GDIPlus_PenCreate Func _GDIPlus_GraphicsDrawLine($hGraphics, $iX1, $iY1, $iX2, $iY2, $hPen = 0) __GDIPlus_PenDefCreate($hPen) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawLineI", "handle", $hGraphics, "handle", $hPen, "int", $iX1, "int", $iY1, _ "int", $iX2, "int", $iY2) Local $tmpError = @error, $tmpExtended = @extended __GDIPlus_PenDefDispose() If $tmpError Then Return SetError($tmpError, $tmpExtended, False) Return $aResult[0] = 0 EndFunc ;==>_GDIPlus_GraphicsDrawLine Func __GDIPlus_PenDefCreate(ByRef $hPen) If $hPen = 0 Then $ghGDIPPen = _GDIPlus_PenCreate() $hPen = $ghGDIPPen EndIf EndFunc ;==>__GDIPlus_PenDefCreate Func __GDIPlus_PenDefDispose() If $ghGDIPPen <> 0 Then _GDIPlus_PenDispose($ghGDIPPen) $ghGDIPPen = 0 EndIf EndFunc ;==>__GDIPlus_PenDefDispose Func _GDIPlus_PenDispose($hPen) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDeletePen", "handle", $hPen) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] = 0 EndFunc ;==>_GDIPlus_PenDispose Func _GDIPlus_Shutdown() If $ghGDIPDll = 0 Then Return SetError(-1, -1, False) $giGDIPRef -= 1 If $giGDIPRef = 0 Then DllCall($ghGDIPDll, "none", "GdiplusShutdown", "ptr", $giGDIPToken) DllClose($ghGDIPDll) $ghGDIPDll = 0 EndIf Return True EndFunc ;==>_GDIPlus_Shutdown Func _GDIPlus_GraphicsDispose($hGraphics) Local $aResult = DllCall($ghGDIPDll, "int", "GdipDeleteGraphics", "handle", $hGraphics) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] = 0 EndFunc ;==>_GDIPlus_GraphicsDispose #endregion -GDI + Regards Phoenix XL
    1 point
  9. Hey Positive Results.............. I got that 2147483647 is the Maximum Value that a Edit Control Can Hold Using This Code #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiEdit.au3> #include <GuiConstantsEx.au3> Opt('MustDeclareVars', 1) $Debug_Ed = False ; Check ClassName being passed to Edit functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hEdit ; Create GUI GUICreate("Edit Set Limit Text", 400, 300) $hEdit = GUICtrlCreateEdit("This is a test" & @CRLF & "Another Line", 2, 2, 394, 268) GUISetState() MsgBox(4160, "Information", "Text Limit: " & _GUICtrlEdit_GetLimitText($hEdit)) MsgBox(4160, "Information", "Setting Text Limit") Local $x=2147483630,$sdata While 1 _GUICtrlEdit_SetLimitText($hEdit,$x) $sdata=_GUICtrlEdit_GetLimitText($hEdit) ConsoleWrite("Information"&@TAB&"Text Limit: " &$sdata &@CRLF) If $sdata<=0 Then ExitLoop $x+=1 WEnd GUIDelete() EndFunc ;==>_Main Thumbs Up If it Helped Regards Phoenix XL
    1 point
  10. water

    Choose variable value

    $variable = InputBox(....)
    1 point
  11. Javascript detect if it's clicked, so the xml radio must be clicked instead of the method you use. Try this #include <IE.au3> $oIE = _IECreate("http://www.ncbi.nlm.nih.gov/pubmed/22561075") _IELoadWait($oIE) ; get pointers to the login form and username and password fields $oform = _IEFormGetObjByName($oIE, "EntrezForm") $radio = _IEFormElementGetObjByName($oform, "EntrezSystem2.PEntrez.Pubmed.Pubmed_ResultsPanel.Pubmed_DisplayBar.sPresentation") _IELinkClickByText ($oIE, "Display Settings:") ; <label for="xmltext">XML</label> Local $oSubmit = _IEGetObjByName ( $oIE, 'xmltext' ) _IEAction ( $oSubmit, 'click' ) _IELoadWait($oIE) ;~ <button name="EntrezSystem2.PEntrez.Pubmed.Pubmed_ResultsPanel.Pubmed_DisplayBar.SetDisplay" sid="1" class="button_apply ncbipopper-close-button">Apply</button> Sleep ( 1000 ) Local $oSubmit = _IEGetObjByName ( $oIE, 'EntrezSystem2.PEntrez.Pubmed.Pubmed_ResultsPanel.Pubmed_DisplayBar.SetDisplay' ) _IEAction ( $oSubmit, 'click' ) _IELoadWait ( $oIE )
    1 point
  12. water

    Create Excel and Run Macro

    Can't test at the moment but I think this should work:Func Query() Local $sqlstring = "select * from stockitems" Local $connstring = "ODBC;Driver={SQL Server};Server=sqlserver;Database=testdb;Uid=sa; Pwd=sa;" Local $oQuery = $oExcel.ActiveSheet.QueryTables.Add($connstring, $oExcel.ActiveSheet.Range("A1"), $sqlstring) $oQuery.Refresh() End Func
    1 point
×
×
  • Create New...