Jump to content

Recommended Posts

Posted
On 1/14/2024 at 8:55 AM, ioa747 said:
; Title...........: ShellTrayRefresh.au3

 

I doubt this will work with hidden taskbar.

Some guy's script + some other guy's script = my script!

  • 4 weeks later...
Posted (edited)

Get the binary type for exe / dll file.

;Coded by UEZ build 2024-04-08
#AutoIt3Wrapper_UseX64 = y
#include <WinAPIFiles.au3>
#include <WinAPIProc.au3>

Global $sFile = FileOpenDialog("Select a DLL file", "", "File (*.dll;*.exe)", $FD_FILEMUSTEXIST)
If @error Then Exit
MsgBox($MB_ICONINFORMATION, "File Binary Type", StringRegExpReplace($sFile, ".+\\(.+)", "$1") & " = " & _WinAPI_GetBinaryType2($sFile))

; #FUNCTION# ====================================================================================================================
; Author.........: UEZ
; Modified.......:
; ===============================================================================================================================
Func _WinAPI_GetBinaryType2($sFile)
    Local Const $hFile = _WinAPI_CreateFile($sFile, 2, 2)
    If Not $hFile Or @error Then Return SetError(1, 0, 0)
    Local Const $hMapping = _WinAPI_CreateFileMapping($hFile, 0, Null, $PAGE_READONLY, Null)
    If Not $hMapping Then
        _WinAPI_CloseHandle($hFile)
        Return SetError(2, 0, 0)
    EndIf
    Local Const $pAddress = _WinAPI_MapViewOfFile($hMapping, 0, 0, $FILE_MAP_READ)
    If Not $pAddress Or @error Then __ReturnGBT2($hMapping, $hFile, 3)
    Local $aHeader = DllCall("Dbghelp.dll", "ptr", "ImageNtHeader", "ptr", $pAddress)
    If @error Or IsArray($aHeader) = 0 Then Return __ReturnGBT2($hMapping, $hFile, 4)
    Local $tIMAGE_NT_HEADERS = DllStructCreate("dword Signature;ptr FileHeader;ptr OptionalHeader;", $aHeader[0])
    If @error Or Not IsDllStruct($tIMAGE_NT_HEADERS) Then Return __ReturnGBT2($hMapping, $hFile, 5)
    Local $tIMAGE_FILE_HEADER = DllStructCreate("word Machine;word NumberOfSections;dword TimeDateStamp;dword PointerToSymbolTable;dword NumberOfSymbols;word SizeOfOptionalHeader;word Characteristics;", DllStructGetPtr($tIMAGE_NT_HEADERS) + 4)
    If @error Or Not IsDllStruct($tIMAGE_FILE_HEADER) Then Return __ReturnGBT2($hMapping, $hFile, 6)
    __ReturnGBT2($hMapping, $hFile, 0)
    Switch $tIMAGE_FILE_HEADER.Machine
        Case 0x014c
            Return "x86"
        Case 0x0200
            Return "Intel Itanium"
        Case 0x8664
            Return "x64"
        Case Else
            Return "Error"
    EndSwitch
EndFunc   ;==>_WinAPI_GetBinaryType2

Func __ReturnGBT2($hMapping, $hFile, $iError)
    _WinAPI_CloseHandle($hMapping)
    _WinAPI_CloseHandle($hFile)
    If $iError Then Return SetError($iError, 0, 0)
EndFunc   ;==>__ReturnGBT2

 

Edited by UEZ
small modifications

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

  • 4 months later...
Posted

Expanding on Nine's task bar adventures... The overlay icon and tooltip were the only other interesting task bar things to me, so I added those + examples

#include <GUIConstantsEx.au3>
#include <WinAPIIcons.au3> ; For _WinAPI_DestroyIcon
#include <WinAPIShellEx.au3> ; For _WinAPI_ShellExtractIcon

Global Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}"
Global Const $sIID_ITaskbarList3 = "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}"
Global Const $tagITaskbarList3 = _
    "HrInit hresult();" & _
    "AddTab hresult(hwnd);" & _
    "DeleteTab hresult(hwnd);" & _
    "ActivateTab hresult(hwnd);" & _
    "SetActiveAlt hresult(hwnd);" & _
    "MarkFullscreenWindow hresult(hwnd;boolean);" & _
    "SetProgressValue hresult(hwnd;uint64;uint64);" & _
    "SetProgressState hresult(hwnd;int);" & _
    "RegisterTab hresult(hwnd;hwnd);" & _
    "UnregisterTab hresult(hwnd);" & _
    "SetTabOrder hresult(hwnd;hwnd);" & _
    "SetTabActive hresult(hwnd;hwnd;dword);" & _
    "ThumbBarAddButtons hresult(hwnd;uint;ptr);" & _
    "ThumbBarUpdateButtons hresult(hwnd;uint;ptr);" & _
    "ThumbBarSetImageList hresult(hwnd;ptr);" & _
    "SetOverlayIcon hresult(hwnd;ptr;wstr);" & _
    "SetThumbnailTooltip hresult(hwnd;wstr);" & _
    "SetThumbnailClip hresult(hwnd;ptr);"

Example()

Func Example()
  Local $hGUI = GUICreate("AutoIt v3", 400, 100)
  GUISetState()

  Local $oTaskBar = TB_Init()

  TB_ToolTip($oTaskBar, $hGUI, "Working...")

  ; Load an icon -- this is a blue refresh on Win11
  Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & "\shell32.dll", 238, 32, 32)
  TB_SetOverlayIcon($oTaskBar, $hGUI, $hIcon, "Blue refresh")

  For $i = 1 To 100
    TB_SetProgress($oTaskBar, $hGUI, $i, 100)
    Sleep(25)
  Next
  
  ; Destroy the old icon
  _WinAPI_DestroyIcon($hIcon)
  
  Local $hSecondIcon = _WinAPI_ShellExtractIcon(@SystemDir & "\shell32.dll", 300, 32, 32)
  TB_SetOverlayIcon($oTaskBar, $hGUI, $hSecondIcon, "Green checkmark")

  TB_Flash($oTaskBar, $hGUI, 4, 300)

  TB_ToolTip($oTaskBar, $hGUI, "Waiting for you to close the window")

  While True
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd
  ; Clear the icon overlay
  TB_SetOverlayIcon($oTaskBar, $hGUI, Null)
  _WinAPI_DestroyIcon($hSecondIcon)

EndFunc   ;==>Example

Func TB_Init()
  Local $oTB = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList3, $tagITaskbarList3)
  $oTB.HrInit()
  Return $oTB
EndFunc   ;==>TB_Init

Func TB_SetProgress(ByRef $oTB, $hWnd, $iCurrent, $iCompleted)
  $oTB.SetProgressValue($hWnd, $iCurrent, $iCompleted)
EndFunc   ;==>TB_SetProgress

Func TB_Flash(ByRef $oTB, $hWnd, $iTimes, $iDelay)
  For $i = 1 To $iTimes
    $oTB.SetProgressState($hWnd, 0)
    Sleep($iDelay)
    $oTB.SetProgressValue($hWnd, 100, 100)
    Sleep($iDelay)
  Next
  $oTB.SetProgressState($hWnd, 0)
EndFunc   ;==>TB_Flash

; These are icons added to your taskbar icon, showing status usually. Each window only gets 1. Set $hIcon to NULL to clear. 
; (Win11) Teams uses this to show your status (busy, free, inactive) and Outlook uses it to show if you have an unread email
Func TB_SetOverlayIcon(ByRef $oTB, $hWnd, $hIcon, $sAltText = "")
    $oTB.SetOverlayIcon($hWnd, $hIcon, $sAltText)
EndFunc   ;==>TB_SetOverlayIcon

; Depending on settings and version, this may be difficult to see. On Win11 with taskbar previews, it is only visible after hovering over the preview window.
Func TB_ToolTip(ByRef $oTB, $hWnd, $sTooltip)
    $oTB.SetThumbnailTooltip($hWnd, $sTooltip)
EndFunc   ;==>TB_ToolTip

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted

If you want to modify the appearance of any blocking functions, here one way :

#include <WindowsConstants.au3>
#include <WinAPISys.au3>

OnAutoItExitRegister(OnAutoItExit)

Global $hForm = GUICreate('Example')
GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), WM_SHELLHOOK)
_WinAPI_RegisterShellHookWindow($hForm)

MsgBox($MB_OK, "MsgBox", "Message")
InputBox("InputBox", "Prompt")
FileOpenDialog("FileOpenDialog", @ScriptDir, "au3 (*.au3)")

Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam)
  If $wParam <> $HSHELL_WINDOWCREATED Then Return
  Switch WinGetTitle($lParam)
    Case "MsgBox"
      ControlSetText($lParam, "", "Static1", "Cool Stuff")
      ControlSetText($lParam, "", "Button1", "New")
    Case "InputBox"
      Local $hCtrl = ControlGetHandle($lParam, "", "Edit1")
      Local $hFont = _WinAPI_CreateFont(16, 0, 0, 0, 600)
      _SendMessage($hCtrl, $WM_SETFONT, $hFont, False)
      _WinAPI_DeleteObject($hFont)
    Case "FileOpenDialog"
      ControlHide($lParam, "", "Button2")
  EndSwitch
EndFunc   ;==>WM_SHELLHOOK

Func OnAutoItExit()
  _WinAPI_DeregisterShellHookWindow($hForm)
EndFunc   ;==>OnAutoItExit

 

  • 1 month later...
Posted (edited)
ConsoleWrite('--- ProcessStartDate: ' & ProcessStartDate('SciTE.exe') & @CRLF) ; --- ProcessStartDate: 2024/10/28 09:45:50
Func ProcessStartDate($sProcessOrPID, $iRet_tSYSTEMTIME = 0, $iLocalTime = 0)
    Local $aFT, $tFT, $tST, $iID = ProcessExists($sProcessOrPID)
    If $iID Then ; https://www.autoitscript.com/forum/index.php?showtopic=139260&view=findpost&p=1538034
        $aFT = _WinAPI_GetProcessTimes($iID)
        If @error Or UBound($aFT) <> 3 Then Return SetError(@error, _WinAPI_GetLastError(), "GetProcessTimes FAILED")
        $tST = _Date_Time_FileTimeToSystemTime($iLocalTime ? _Date_Time_FileTimeToLocalFileTime($aFT[0]) : $aFT[0])
        If $iRet_tSYSTEMTIME Then Return $tST
        Return _Date_Time_SystemTimeToDateTimeStr($tST, 1)
    EndIf
    Return SetError(11, 0, "Process does not exist")
EndFunc   ;==>ProcessStartDate

I have a bunch of RDP running and wanted to identify which is which and thought of the Process date and PID, to know that the given process was from X connection because when it disconnects the popup window does not have any info. in regards to what disconnected ... , am working on it. And thought that the function was a good snippet to share.

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

  • 1 month later...
Posted (edited)
Report_GetDriveSpaceFree()
Func Report_GetDriveSpaceFree($sDrive = "C:\", $iLine = @ScriptLineNumber) ; how I use it in my project
    Local $iFree = GetDriveSpaceFree($sDrive), $iTotal = @extended, $iError = @error, $iUsed = $iTotal - $iFree
    ConsoleWriteDebug(($iFree < 10 ? "!" : "+") & " DriveSpaceFree(" & $sDrive & "): " & $iFree & ' GB free of ' & $iTotal & ' GB total (Used: ' & $iUsed & ' GB)(Error: ' & $iError & ').' & @CRLF, $iLine)
EndFunc   ;==>Report_GetDriveSpaceFree

Func GetDriveSpaceFree($sDrive = "C:\") ; in GB
    Local $iError = 0, $iFree = DriveSpaceFree($sDrive)
    $iError += @error ; https://www.autoitscript.com/forum/topic/139260-autoit-snippets/?do=findComment&comment=1538974
    Local $iTotal = DriveSpaceTotal($sDrive)
    $iError += @error
    Return SetError($iError, Int($iTotal / 1024), Int($iFree / 1024))
EndFunc   ;==>GetDriveSpaceFree

Func ConsoleWriteDebug($sStr = @CRLF, $iLine = @ScriptLineNumber, $iError = @error, $iExtended = @extended)
    Local $iRet = ConsoleWrite("@@ Debug (" & $iLine & ") : " & $sStr & (StringRight($sStr, 2) = @CRLF ? "" : @CRLF))
    Return SetError($iError, $iExtended, $iRet) ; https://www.autoitscript.com/forum/topic/139260-autoit-snippets/?do=findComment&comment=1538974
EndFunc   ;==>ConsoleWriteDebug

I needed GetDriveSpaceFree()  for a project and ConsoleWriteDebug() is a good idea.
..and, code to add the @ScriptLineNumber to your main script

Edited by argumentum
more

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

  • 3 weeks later...
Posted

Owner Draw Combo Box with default $CBS_DROPDOWN.  Not so obvious as it seems.

#include <WinAPIConv.au3>
#include <WinAPIGdi.au3>
#include <GUIConstants.au3>
#include <Constants.au3>
#include <GuiComboBox.au3>

Opt("MustDeclareVars", True)

Global Const $tagDRAWITEMSTRUCT = "uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;hwnd hwndItem;handle hDC;dword rcItem[4];ptr itemData"
Global Const $ODA_DRAWENTIRE = 1
Global Const $ODS_SELECTED = 1

Global $idCombo

Example()

Func Example()
  GUICreate("Owner Draw", 300, 200)

  $idCombo = GUICtrlCreateCombo("", 10, 10, 185, 20, BitOR($CBS_HASSTRINGS, $CBS_OWNERDRAWFIXED, $GUI_SS_DEFAULT_COMBO))
  Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

  GUICtrlSetData($idCombo, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17")
  GUISetState()

  Local $aAccelKeys[1][2] = [["{ENTER}", $idCombo]]
  GUISetAccelerators($aAccelKeys)
  GUIRegisterMsg($WM_COMMAND, WM_COMMAND)
  GUIRegisterMsg($WM_DRAWITEM, WM_DRAWITEM)

  While True
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE, $idClose
        ExitLoop
    EndSwitch
  WEnd
EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
  Local $idCtrl = _WinAPI_LoWord($wParam), $iCode = _WinAPI_HiWord($wParam)
  If $idCtrl = $idCombo And ($iCode = $CBN_KILLFOCUS Or $iCode = $CBN_SELCHANGE) Then Validate($idCtrl)
  Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func Validate($idComboBox)
  Local Static $sSelection
  Local $sComboRead = GUICtrlRead($idComboBox)
  If $sSelection = $sComboRead Then Return
  Local $iList = _GUICtrlComboBox_FindStringExact($idComboBox, $sComboRead)
  If $iList = -1 Then
    GUICtrlSendMsg($idComboBox, $CB_SETCURSEL, -1, 0)
    $sSelection = ""
    ConsoleWrite("Invalid data" & @CRLF)
  Else
    $sSelection = $sComboRead
    ConsoleWrite("Currently displaying: " & $sComboRead & @CRLF)
    If _GUICtrlComboBox_GetCurSel($idComboBox) = -1 Then _GUICtrlComboBox_SetCurSel($idComboBox, $iList)
  EndIf
EndFunc   ;==>Validate

Func WM_DRAWITEM($hWnd, $iMsg, $wParam, $lParam)
  If $wParam <> $idCombo Then Return $GUI_RUNDEFMSG
  Local $tDraw = DllStructCreate($tagDRAWITEMSTRUCT, $lParam), $sText
  If $tDraw.itemAction = $ODA_DRAWENTIRE Then
    Local $tRECT = DllStructCreate($tagRECT, DllStructGetPtr($tDraw, "rcItem"))
    Local $hBrush = _WinAPI_CreateSolidBrush(BitAND($tDraw.itemState, $ODS_SELECTED) ? 0xFFCDAD : Mod($tDraw.itemID, 2) ? 0xFFFFFF : 0xE0E0E0)
    _WinAPI_FillRect($tDraw.hDC, $tRECT, $hBrush)
    $tRECT.Left += 5
    $tRECT.Top += 2
    _GUICtrlComboBox_GetLBText($tDraw.hwndItem, $tDraw.itemID, $sText)
    _WinAPI_DrawText($tDraw.hDC, $sText, $tRECT, $DT_LEFT)
    _WinAPI_DeleteObject($hBrush)
  EndIf
  Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_DRAWITEM

Note : you can tab, enter, up arrow, down arrow to validate the combo input field.

Posted (edited)

Hi all - here's a quick example of how you can "hit test" controls under the mouse. 

You can't directly handle WM_NCHITTEST with GuiRegisterMessage()  - controls don't pass this message on to the parent. We can directly grab messages from a control however, as long as we send them to the old handler when we're done.

Note: for buttons I *think* you can use WM_MOUSEHOVER via a traditional GUIRegisterMessage, which is obviously a better option - but this will work with labels etc...

Edit: oops I guess I was a little too hasty here! - this looks to brake stuff. I'll update the post if I find a solution... Fixed!!

#include <guiConstants.au3>
#include <winapi.au3>

Global $hGui = GUICreate("", 200, 100)
Global $hBtn = GUICtrlCreateButton("Test", 4, 4, 80, 80)

Global $hBtnProc = DllCallbackRegister("ButtonProc", "long", "hwnd;uint;wparam;lparam")
Global $pOrigBtnProc = _WinAPI_GetWindowLong(GUICtrlGetHandle($hBtn), $GWL_WNDPROC)
_WinAPI_SetWindowLong(GUICtrlGetHandle($hBtn), $GWL_WNDPROC, DllCallbackGetPtr($hBtnProc))

GUISetState()

while 1
    $Msg = GUIGetMsg(1)
    Switch $Msg[0]
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $hBtn
            ConsoleWrite("Clicked" & @CRLF)

    EndSwitch

wend

Func ButtonProc($hWnd, $uMsg, $wParam, $lParam)

    Switch $uMsg
        Case $WM_NCHITTEST
             ConsoleWrite(StringFormat("Button Hit. Mouse:[%d,%d]\r\n", BitAND($lParam, 0xFFFF), BitShift($lParam, 16)))

    EndSwitch

    Local $aRet = DllCallAddress("long",  $pOrigBtnProc, "hwnd", $hWnd, "uint", $uMsg, "wparam", $wParam, "lparam", $lParam)
    Return $aRet[0]
EndFunc
Edited by MattyD
Posted (edited)
Case $WM_NCHITTEST ; https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-nchittest
    ConsoleWrite(StringFormat("Button Hit. Mouse:[%d,%d]\r\n", BitAND($lParam, 0xFFFF), BitShift($lParam, 16)))
Case $WM_MOUSELEAVE ; https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-mouseleave
    ConsoleWrite(StringFormat("Button Left")

0x02A3 is magic WM_MOUSELEAVE :)
..it was defined :lol:

Edited by argumentum
found it

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

  • 1 month later...
Posted

On Win10, Microsoft had the brilliant idea to link agenda with calendar.  And now it is kind of exhausting to have a simple alarm to get a notification when time comes up.  So I made one :

#NoTrayIcon
#AutoIt3Wrapper_Icon=Alarm.ico

#include <GUIConstants.au3>
#include <Constants.au3>

Opt("MustDeclareVars", True)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)
Opt("TrayAutoPause", 0)

Global Const $DELAY = 5

Local $hGUI = GUICreate("Alarm", 400, 500, -1, -1, $WS_SYSMENU)
GUISetIcon("Alarm.ico")
GUISetFont(12)

Local $idName = GUICtrlCreateInput("Event", 30, 30, 200, 25)
Local $aAccelKeys[1][2] = [["{TAB}", $idName]], $iMsg
GUISetAccelerators($aAccelKeys)
GUISetState()

Do
  $iMsg = GUIGetMsg()
  If $iMsg = $GUI_EVENT_CLOSE Then Exit
Until $iMsg = $idName

Local $sName = GUICtrlRead($idName)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel("⌚", 30, 80, 15, 25, $SS_CENTERIMAGE)
GUICtrlSetColor(-1, 0x0000FF)
Local $vHour = String(Mod(@HOUR + 1, 24)), $vMin = "00"
Local $idTime = GUICtrlCreateLabel("" & $vHour & " : " & $vMin, 60, 80, 58, 25, $SS_SUNKEN + $SS_CENTERIMAGE + $SS_CENTER)
Local $idAccept = GUICtrlCreateLabel("✔", 40, 120, 30, 30)
GUICtrlSetColor(-1, 0x099007)
Local $idExit = GUICtrlCreateLabel("✖", 70, 120, 30, 30)
GUICtrlSetColor(-1, 0xFF0000)
Local $aAccelKeys[2][2] = [["{ENTER}", $idAccept], ["{ESC}", $idExit]]
GUISetAccelerators($aAccelKeys)

Do
  $iMsg = GUIGetMsg()
  If $iMsg = $GUI_EVENT_CLOSE Or $iMsg = $idExit Then Exit
Until $iMsg = $idTime Or $iMsg = $idAccept

If $iMsg = $idTime Then
  Local $idHour = GUICtrlCreateList("", 110, 10, 40, 450, 0)
  GUICtrlSetData(-1, "0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23", $vHour)
  Local $idMin = GUICtrlCreateList("", 150, 100, 40, 230, 0)
  GUICtrlSetData(-1, "00|05|10|15|20|25|30|35|40|45|50|55", $vMin)
  Do
    $iMsg = GUIGetMsg()
    If $iMsg = $GUI_EVENT_CLOSE Or $iMsg = $idExit Then Exit
  Until $iMsg = $idAccept
  $vHour = GUICtrlRead($idHour)
  $vMin = GUICtrlRead($idMin)
EndIf

GUIDelete()

TraySetIcon("Alarm.ico")
TraySetOnEvent($TRAY_EVENT_PRIMARYUP, Terminate)
TraySetState($TRAY_ICONSTATE_SHOW)
TraySetToolTip($sName & " starts at " & $vHour & ":" & $vMin & @CRLF & "Left click to quit")

$vHour = Number($vHour)
$vMin = Number($vMin)

If Mod($vMin + 60 - $DELAY, 60) > $vMin Then
  $vHour = Mod($vHour + 23, 24)
  $vMin = Mod($vMin + 60 - $DELAY, 60)
Else
  $vMin -= $DELAY
EndIf

While Sleep(1000)
  If Number(@HOUR) = $vHour And Number(@MIN) = $vMin Then Exit MsgBox($MB_ICONWARNING + $MB_TOPMOST, "Attention", $sName & " will start in " & $DELAY & " minutes")
WEnd

Func Terminate()
  Exit
EndFunc

 

Alarm.ico

  • 2 weeks later...
Posted

Following this previous snippet, I was playing with the idea of drawing stuff within MsgBox.  So here it is :

#include <WindowsConstants.au3>
#include <WinAPISys.au3>
#include <WinAPIGdi.au3>

Opt("MustDeclareVars", True)

Example()

Func Example()
  Local $hForm = GUICreate("")
  GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), WM_SHELLHOOK)
  _WinAPI_RegisterShellHookWindow($hForm)

  Local $iRet = MsgBox($MB_OK, "MsgBox", "Message")
  ConsoleWrite("Returned = " & $iRet & @CRLF)

  _WinAPI_DeregisterShellHookWindow($hForm)
EndFunc   ;==>Example

Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam)
  If $wParam <> $HSHELL_WINDOWCREATED Then Return
  If _WinAPI_GetClassName($lParam) = "#32770" And _WinAPI_GetDlgItem($lParam, 0xFFFF) Then ; means dialog box
    ControlSetText($lParam, "", "Button1", "Cool")
    Local $aSize = WinGetClientSize($lParam)
    Local $hDC = _WinAPI_GetDC($lParam)
    Local $hPen = _WinAPI_CreatePen($PS_SOLID, 3, 0xFF)
    Local $oCurr = _WinAPI_SelectObject($hDC, $hPen)

    _WinAPI_DrawLine($hDC, 0, 0, $aSize[0], 0)     ; top
    _WinAPI_DrawLine($hDC, 0, 0, 0, $aSize[1])     ; left
    _WinAPI_DrawLine($hDC, $aSize[0], 0, $aSize[0], $aSize[1])     ; right
    _WinAPI_DrawLine($hDC, 0, $aSize[1], $aSize[0], $aSize[1])     ; bottom

    _WinAPI_SelectObject($hDC, $oCurr)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC($lParam, $hDC)
  EndIf
EndFunc   ;==>WM_SHELLHOOK

 

Posted

Here another approach to display large MsgBox (based only on mouse).  I had this code for WMI when lots of properties need to be shown :

#include <Constants.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>
#include <WinAPIConstants.au3>

Opt("MustDeclareVars", True)

Global Const $tagMOUSEHOOKSTRUCT = $tagPOINT & ";hwnd hwnd;uint wHitTestCode;ulong_ptr dwExtraInfo;dword mouseData;"
Global $hHook

Example()

Func Example()
  Local $hStub = DllCallbackRegister(WH_MOUSE, "LRESULT", "int;wparam;lparam")
  $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE, DllCallbackGetPtr($hStub), 0, _WinAPI_GetCurrentThreadId())

  Local $sList = "First line here" & @CR
  For $i = 2 To 200
    $sList &= "Line " & $i & @CR
  Next
  $sList &= "Last line here"
  Local $iRep = MsgBox($MB_OKCANCEL, "Example", $sList)

  _WinAPI_UnhookWindowsHookEx($hHook)
  DllCallbackFree($hStub)
EndFunc   ;==>Example

Func WH_MOUSE($iMsg, $wParam, $lParam)
  If $iMsg Then Return _WinAPI_CallNextHookEx($hHook, $iMsg, $wParam, $lParam)
  Local $tMouse = DllStructCreate($tagMOUSEHOOKSTRUCT, $lParam)
  Local $hWnd = _WinAPI_GetAncestor($tMouse.hwnd, $GA_ROOT)
  If $wParam = $WM_MOUSEWHEEL Then
    Local $iDir = _WinAPI_HiWord($tMouse.mouseData)
    WinMove($hWnd, "", WinGetPos($hWnd)[0], WinGetPos($hWnd)[1] + ($iDir / 3))
  ElseIf $wParam = $WM_LBUTTONDOWN Then
    If $tMouse.hwnd = $hWnd Then WinMove($hWnd, "", WinGetPos($hWnd)[0], 0)
  ElseIf $wParam = $WM_RBUTTONDOWN Then
    WinMove($hWnd, "", WinGetPos($hWnd)[0], @DesktopHeight - WinGetPos($hWnd)[3] - 50)
  EndIf
  Return _WinAPI_CallNextHookEx($hHook, $iMsg, $wParam, $lParam)
EndFunc   ;==>WH_MOUSE

Left click will bring you to top
Right click will bring you to bottom
Mouse wheel to scroll the MsgBox

Enjoy !

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...