Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/01/2022 in all areas

  1. I used AdlibRegister() for that in the past. The great advantage of the TImers is, that they work even if a blocking function is called 😉. #include <GUIConstantsEx.au3> #include <Misc.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> ToolTip("1a53da04-c3d6-48fb-819f-6cf3dbe01c4c") Global $hWnd_ToolTip = WinGetHandle("1a53da04-c3d6-48fb-819f-6cf3dbe01c4c") ToolTip("") Sleep(1000) ; Tooltip doesn't flash! ToolTip("AdlibRegister") AdlibRegister("_Move_Tooltip", 10) ; Does move Tooltip Do Sleep(100) Until _IsPressed('1B') AdlibUnRegister("_Move_Tooltip") AdlibRegister("_Move_Tooltip", 10) ; Does NOT move Tooltip because of blocking function MsgBox(262144, "", "Blocks") AdlibUnRegister("_Move_Tooltip") ToolTip("_WinAPI_SetTimer") Local $hTimerProc = DllCallbackRegister('_TimerProc', 'none', 'hwnd;uint;uint_ptr;dword') Local $iTimerID = _WinAPI_SetTimer(0, 0, 10, DllCallbackGetPtr($hTimerProc)) ; Does move Tooltip, even with blocking function Do Sleep(100) Until _IsPressed('1B') MsgBox(262144, "", "Does not block") _WinAPI_KillTimer(0, $iTimerID) DllCallbackFree($hTimerProc) Func _TimerProc($hWnd, $iMsg, $iTimerID, $iTime) #forceref $hWnd, $iMsg, $iTimerId, $iTime _Move_Tooltip() EndFunc ;==>_TimerProc Func _Move_Tooltip() Local $aMousePos = MouseGetPos() If Not @error Then WinMove($hWnd_ToolTip, "", $aMousePos[0] + 20, $aMousePos[1] + 20) EndIf EndFunc ;==>_Move_Tooltip
    1 point
  2. @TimRude I wondered if there was a way to display a tooltip while hovering over the Edit control. This tooltip should constantly be updated and display the complete text of the Edit Control (e.g. 1 line) without having the user scroll right or left inside the Edit control. The problem is that the dialog box displayed by _WinAPI_BrowseForFolderDlg() isn't created by the user, nor the treeview + edit control + 2 buttons + label found in this dialog box, so I didn't know exactly how to create the tooltip in this script where there is no While... WEnd loop. Then I thought of Kafu's interesting script and the use of _WinAPI_SetTimer() helped me to achieve this. As there is no GUI created by the user in your script (TimRude) then I choosed the callback function associated to _WinAPI_SetTimer() rather than the impossible WM_TIMER registration when there is no GUI created by the user (if I'm not mistaken) #include <WinAPIDlg.au3> #include <WinAPISysWin.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $g_hEdit = 0, $g_aSize[2] ; width & height of edit control (client area) Local $hTimerProc = DllCallbackRegister('_TimerProc', 'none', 'hwnd;uint;uint_ptr;dword') Local $iTimerID = _WinAPI_SetTimer(0, 0, 200, DllCallbackGetPtr($hTimerProc)) ; 200ms ConsoleWrite('Returned Path = ' & _BrowseForFolder(@ScriptDir, 'Custom Title', 'Custom Prompt') & @TAB & '@extended = ' & @extended & @CRLF) _WinAPI_KillTimer(0, $iTimerID) DllCallbackFree($hTimerProc) ;=================================================================================================================================== Func _BrowseForFolder($sInitDir, $sTitle = 'Browse For Folder', $sPrompt = 'Select a folder from the list below.', $hParent_hWnd = 0) Global $s_BFF_Dialog_Title = $sTitle Local $hBrowseProc = DllCallbackRegister('_BrowseProc', 'int', 'hwnd;uint;lparam;ptr') Local $pBrowseProc = DllCallbackGetPtr($hBrowseProc) Local $pText = _WinAPI_CreateString($sInitDir) Local $sPath = _WinAPI_BrowseForFolderDlg('', $sPrompt, BitOR($BIF_RETURNONLYFSDIRS, $BIF_EDITBOX, $BIF_VALIDATE), $pBrowseProc, $pText, $hParent_hWnd) _WinAPI_FreeMemory($pText) DllCallbackFree($hBrowseProc) If $sPath = '' Then Return SetExtended(-1, '') Else Return $sPath EndIf EndFunc ;==>_BrowseForFolder ;=============================================== Func _BrowseProc($hWnd, $iMsg, $wParam, $lParam) Local $sPath Switch $iMsg Case $BFFM_INITIALIZED _WinAPI_SetWindowText($hWnd, $s_BFF_Dialog_Title) _SendMessage($hWnd, $BFFM_SETSELECTIONW, 1, $lParam) $g_hEdit = ControlGetHandle($hWnd, "", "Edit1") _SendMessage($g_hEdit, 0x00CF, 1, 0) ; $EM_SETREADONLY = 0x00CF $g_aSize = WinGetClientSize($g_hEdit) Case $BFFM_SELCHANGED $sPath = _WinAPI_ShellGetPathFromIDList($wParam) If @error Or ($sPath = '') Then ControlDisable($hWnd, '', 'Button1') ; disable OK button for non-folder selections Else ControlSetText($hWnd, '', 'Edit1', $sPath) ; update Edit control to show full path ControlEnable($hWnd, '', 'Button1') ; enable OK button EndIf Case $BFFM_VALIDATEFAILED MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Error', _WinAPI_GetString($wParam) & ' is invalid.', 0, $hWnd) Return 1 EndSwitch Return 0 EndFunc ;==>_BrowseProc ;=============================================== Func _TimerProc($hWnd, $iMsg, $iTimerID, $iTime) #forceref $hWnd, $iMsg, $iTimerID, $iTime Local Static $tPoint = DllStructCreate("int X;int Y"), $bToolTip = False Local $aMPos = MouseGetPos() DllStructSetData($tPoint, "X", $aMPos[0]) DllStructSetData($tPoint, "Y", $aMPos[1]) _WinAPI_ScreenToClient($g_hEdit, $tPoint) If $tPoint.X > - 1 And $tPoint.X < $g_aSize[0] And $tPoint.Y > -1 And $tPoint.Y < $g_aSize[1] Then ;~ If Not $bToolTip Then ; keep this test commented out for an accurate tooltip display ToolTip(_WinAPI_GetWindowText($g_hEdit)) $bToolTip = True ;~ EndIf Else If $bToolTip Then ToolTip("") $bToolTip = False EndIf EndIf EndFunc ;==>_TimerProc If anyone thinks of an easier way to achieve the tooltip part, please indicate it here, thanks
    1 point
  3. @KaFu this topic you created here was inspiring so thanks for that, especially I never used _WinAPI_SetTimer() until now. It helped me to add a functionality in TimRude's script (a tooltip constantly updated in a script when there is no GUI created by the user)
    1 point
  4. Just important note: If you use directive #AutoIt3Wrapper_Change2CUI=y then you must compile such script with FULL Scite4Autoit3 and not only in standard Scite editor included in base Autoit instalator. EDIT: and of course you must use ConsoleWrite(...) 🙂
    1 point
×
×
  • Create New...