
InnI
-
Posts
165 -
Joined
-
Last visited
-
Days Won
4
Reputation Activity
-
InnI got a reaction from footswitch in Get per-monitor DPI scaling factor
#include <WinAPIGdi.au3> ; enum _PROCESS_DPI_AWARENESS Global Const $PROCESS_DPI_UNAWARE = 0 Global Const $PROCESS_SYSTEM_DPI_AWARE = 1 Global Const $PROCESS_PER_MONITOR_DPI_AWARE = 2 ; enum _MONITOR_DPI_TYPE Global Const $MDT_EFFECTIVE_DPI = 0 Global Const $MDT_ANGULAR_DPI = 1 Global Const $MDT_RAW_DPI = 2 Global Const $MDT_DEFAULT = $MDT_EFFECTIVE_DPI _WinAPI_SetProcessDpiAwareness($PROCESS_PER_MONITOR_DPI_AWARE) $aMonitors = _WinAPI_EnumDisplayMonitors() If Not IsArray($aMonitors) Then Exit MsgBox(0, "", "EnumDisplayMonitors error") For $i = 1 To $aMonitors[0][0] $aDPI = _WinAPI_GetDpiForMonitor($aMonitors[$i][0], $MDT_DEFAULT) $_ = IsArray($aDPI) ? MsgBox(0, "", $aDPI[0] & ":" & $aDPI[1]) : MsgBox(0, "", "error") Next Func _WinAPI_SetProcessDpiAwareness($DPIAware) DllCall("Shcore.dll", "long", "SetProcessDpiAwareness", "int", $DPIAware) If @error Then Return SetError(1, 0, 0) EndFunc Func _WinAPI_GetDpiForMonitor($hMonitor, $dpiType) Local $X, $Y $aRet = DllCall("Shcore.dll", "long", "GetDpiForMonitor", "long", $hMonitor, "int", $dpiType, "uint*", $X, "uint*", $Y) If @error Or Not IsArray($aRet) Then Return SetError(1, 0, 0) Local $aDPI[2] = [$aRet[3],$aRet[4]] Return $aDPI EndFunc
-
InnI got a reaction from baselz in ControlClick does not work
Try adding to the beginning of the script
#RequireAdmin -
InnI got a reaction from ioa747 in ControlClick does not work
Try adding to the beginning of the script
#RequireAdmin -
InnI got a reaction from Viter in BmpSearch - Search for Bitmap within Bitmap - Assembly Version
@Viter Try to use modified version
-
InnI got a reaction from argumentum in BmpSearch - Search for Bitmap within Bitmap - Assembly Version
@Viter Try to use modified version
-
InnI got a reaction from simplercoder000 in making your compiled application DPI Aware
System will not resize GUI and controls according to DPI scaling. You must do this manually. For example
; current value of primary monitor DPI is stored in the registry: ; HKCU\Control Panel\Desktop\WindowMetrics, AppliedDPI ; need to relogin after DPI changed to update this value $Scale = RegRead("HKCU\Control Panel\Desktop\WindowMetrics", "AppliedDPI") / 96 DllCall("User32.dll", "bool", "SetProcessDPIAware") GUICreate("DPI test", 200 * $Scale, 100 * $Scale) GUICtrlCreateButton("test button text", 10 * $Scale, 10 * $Scale, 80 * $Scale, 25 * $Scale) GUICtrlCreateCombo("test combo text", 10 * $Scale, 40 * $Scale, 100 * $Scale, 25 * $Scale) GUICtrlCreateLabel("test label text", 10 * $Scale, 70 * $Scale, 70 * $Scale, 25 * $Scale) GUISetState() Do Until GUIGetMsg() = -3
-
InnI got a reaction from Nine in GUI_EVENT_DROPPED not working only when script is compiled
This is possible if to use WinAPI
See example in help file for
_WinAPI_DragQueryFileEx() -
InnI got a reaction from spudw2k in _GUICtrlMenu_GetItemEnabled vs _GUICtrlMenu_GetItemState
It looks like the functions _GUICtrlMenu_GetItemEnabled and _GUICtrlMenu_GetItemDisabled should use $MFS_DISABLED
-
InnI got a reaction from UEZ in [SOLVED] Taskbar icons coordinates
@UEZ hopefully this will work
#include "CUIAutomation2.au3" ; https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/ ; Search taskbars $ahWnd = WinList("[REGEXPCLASS:Shell_(Secondary)?TrayWnd]") ConsoleWrite("Found taskbars " & $ahWnd[0][0] & @CRLF) ; Search controls Global $ahCtrl[$ahWnd[0][0]] For $i = 1 To $ahWnd[0][0] $ahCtrl[$i - 1] = ControlGetHandle($ahWnd[$i][1], "", "MSTaskListWClass1") Next ; Get UIAutomation object $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) If Not IsObj($oUIAutomation) Then Exit ConsoleWrite("Error create UIA object" & @CRLF) ; Create 2D array of buttons [name,left,top,right,bottom] Global $aBtnInfo[0][5], $Count, $pElement, $pCondition, $pElementArray, $iButtons, $vValue $tRect = DllStructCreate("long Left;long Top;long Right;long Bottom") For $n = 0 To UBound($ahCtrl) - 1 ; Get taskbar element $oUIAutomation.ElementFromHandle($ahCtrl[$n], $pElement) $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) ; Get condition (ControlType = Button) $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition) $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition) ; Find all buttons $oElement.FindAll($TreeScope_Children, $oCondition, $pElementArray) $oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray) $oElementArray.Length($iButtons) ReDim $aBtnInfo[UBound($aBtnInfo) + $iButtons][5] ; Get name and position for each button For $i = 0 To $iButtons - 1 $oElementArray.GetElement($i, $pElement) $oButton = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) $oButton.GetCurrentPropertyValue($UIA_NamePropertyId, $vValue) $oButton.CurrentBoundingRectangle($tRect) $aBtnInfo[$i + $Count][0] = $vValue $aBtnInfo[$i + $Count][1] = $tRect.Left $aBtnInfo[$i + $Count][2] = $tRect.Top $aBtnInfo[$i + $Count][3] = $tRect.Right $aBtnInfo[$i + $Count][4] = $tRect.Bottom Next $Count += $iButtons Next #include <Array.au3> _ArrayDisplay($aBtnInfo) -
InnI got a reaction from wwilk in BmpSearch - Search for Bitmap within Bitmap - Assembly Version
I used _BmpSearch quite often. And I made some changes to improve usability:
now it is not a UDF, but a function now the function accepts not only gdi32 hBitmap, but also GDI+ hImage or simply path to image file now there is no problem with the alpha channel now you can search for a 1x1 pixel image and get array of pixels now the search time is returned to the $aCoords[0][1] in milliseconds added error checking #include <GDIPlus.au3> #pragma compile(x64, false) ; #FUNCTION# ==================================================================================================================== ; Name : _BmpSearchEx ; Description : Searches for Bitmap in a Bitmap ; Syntax : _BmpSearchEx($vPic1, $vPic2, $iMax = 5000) ; Parameters : $vPic1 - Handle to bitmap (gdi32 or GDI+) to search or path to image file ; : $vPic2 - Handle to bitmap (gdi32 or GDI+) to find or path to image file ; : $iMax - Max matches to find ; Return values : Success: Returns a 2d array with the following format: ; : $aCoords[0][0] = Total matches found (0 if not found) ; : $aCoords[0][1] = Time of search in ms ; : $aCoords[$i][0] = Width of bitmap ; : $aCoords[$i][1] = Height of bitmap ; : $aCoords[$i][2] = X coordinate ; : $aCoords[$i][3] = Y coordinate ; : Failure: Returns 0 and sets @error: ; : @error = 1 - file $vPic1 not found ; : @error = 2 - file $vPic2 not found ; : @error = 3 - $vPic1 is not a bitmap ; : @error = 4 - $vPic2 is not a bitmap ; : @error = 5 - error decode opcode ; Author : Brian J Christy (Beege) ; Modified : InnI ; =============================================================================================================================== Func _BmpSearchEx($vPic1, $vPic2, $iMax = 5000) If $iMax < 1 Then $iMax = 5000 Local $hImg1, $hImg2, $iErr1, $iErr2, $iTime = TimerInit() _GDIPlus_Startup() If IsString($vPic1) Then If Not FileExists($vPic1) Then Return SetError(1, _GDIPlus_Shutdown(), 0) $hImg1 = _GDIPlus_BitmapCreateFromFile($vPic1) Else $hImg1 = _GDIPlus_BitmapCreateFromHBITMAP($vPic1) $iErr1 = @error EndIf If IsString($vPic2) Then If Not FileExists($vPic2) Then Return SetError(2, _GDIPlus_Shutdown(), 0) $hImg2 = _GDIPlus_BitmapCreateFromFile($vPic2) Else $hImg2 = _GDIPlus_BitmapCreateFromHBITMAP($vPic2) $iErr2 = @error EndIf $hSource = ($iErr1) ? _GDIPlus_BitmapCreateHBITMAPFromBitmap($vPic1) : _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImg1) If Not $iErr1 Then _GDIPlus_BitmapDispose($hImg1) $hFind = ($iErr2) ? _GDIPlus_BitmapCreateHBITMAPFromBitmap($vPic2) : _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImg2) If Not $iErr2 Then _GDIPlus_BitmapDispose($hImg2) _GDIPlus_Shutdown() Static Local $aMemBuff, $tMem, $fStartup = True If $fStartup Then ;####### (BinaryStrLen = 490) #### (Base64StrLen = 328 )##################################################################### Local $Opcode = 'yBAAAFCNRfyJRfSNRfiJRfBYx0X8AAAAAItVDP8yj0X4i10Ii0UYKdiZuQQAAAD38YnBi0X4OQN0CoPDBOL36akAAACDfSgAdB1TA10oO10YD4OVAAAAi1UkORN1A1vrBluDwwTrvVOLVSyLRTADGjtdGHd3iwg5C3UhA1oEi0gEO10Yd2Y5C3USA1oIi0gIO10Yc1c5' & _ 'C3UDW+sGW4PDBOuCi1UUid6LfQyLTRCJ2AHIO0UYczfzp4P5AHcLSoP6AHQNA3Uc6+KDwwTpVP///4tFIIkYg0UgBIPDBP9F/ItVNDlV/HQG6Tj///9bi0X8ycIwAA==' Local $aDecode = DllCall("Crypt32.dll", "bool", "CryptStringToBinary", "str", $Opcode, "dword", 0, "dword", 1, "struct*", DllStructCreate("byte[254]"), "dword*", 254, "ptr", 0, "ptr", 0) If @error Or (Not $aDecode[0]) Then Return SetError(5, 0, 0) $Opcode = BinaryMid(DllStructGetData($aDecode[4], 1), 1, $aDecode[5]) $aMemBuff = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", BinaryLen($Opcode), "dword", 4096, "dword", 64) $tMem = DllStructCreate('byte[' & BinaryLen($Opcode) & ']', $aMemBuff[0]) DllStructSetData($tMem, 1, $Opcode) ;############################################################################################################################ $fStartup = False EndIf Local $tSizeSource = _WinAPI_GetBitmapDimension($hSource) If @error Then Return SetError(3, 0, 0) Local $tSizeFind = _WinAPI_GetBitmapDimension($hFind) If @error Then Return SetError(4, 0, 0) Local $iRowInc = ($tSizeSource.X - $tSizeFind.X) * 4 Local $tSource = DllStructCreate('dword[' & ($tSizeSource.X * $tSizeSource.Y) & ']') _WinAPI_GetBitmapBits($hSource, DllStructGetSize($tSource), DllStructGetPtr($tSource)) Local $tFind = DllStructCreate('dword[' & ($tSizeFind.X * $tSizeFind.Y) & ']') _WinAPI_GetBitmapBits($hFind, DllStructGetSize($tFind), DllStructGetPtr($tFind)) _WinAPI_DeleteObject($hSource) _WinAPI_DeleteObject($hFind) ;####### (BinaryStrLen = 106) ################################################################################################# Static Local $Opcode_ = '0xC80000008B5D0C8B1383C3048B4D103913750C83C304E2F7B800000000EB118B5508FF338F028B451029C883C002EB00C9C20C00' Static Local $aMemBuff_ = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", BinaryLen($Opcode_), "dword", 4096, "dword", 64) Static Local $tMem_ = DllStructCreate('byte[' & BinaryLen($Opcode_) & ']', $aMemBuff_[0]) DllStructSetData($tMem_, 1, $Opcode_) ;############################################################################################################################## Local $iFirstDiffIdx, $iFirstDiffPix, $aFirstDiffCoords[2], $iMaxLoops = (DllStructGetSize($tFind) / 4) - 1 If $iMaxLoops Then Local $aFD = DllCallAddress('dword', DllStructGetPtr($tMem_), 'dword*', 0, 'struct*', $tFind, 'dword', $iMaxLoops) $iFirstDiffIdx = $aFD[0] $iFirstDiffPix = $aFD[1] Else $iFirstDiffIdx = 1 $iFirstDiffPix = DllStructGetData($tFind, 1, 1) EndIf $aFirstDiffCoords[1] = Int(($iFirstDiffIdx - 1) / $tSizeFind.X) $aFirstDiffCoords[0] = ($iFirstDiffIdx - 1) - ($aFirstDiffCoords[1] * $tSizeFind.X) Local $iFirst_Diff_Inc = (($aFirstDiffCoords[1] * $tSizeSource.X) + $aFirstDiffCoords[0]) * 4 If $iFirst_Diff_Inc < 0 Then $iFirst_Diff_Inc = 0 Local $tCornerPixs = DllStructCreate('dword[3]') DllStructSetData($tCornerPixs, 1, DllStructGetData($tFind, 1, $tSizeFind.X), 1) DllStructSetData($tCornerPixs, 1, DllStructGetData($tFind, 1, $tSizeFind.X * ($tSizeFind.Y - 1) + 1), 2) DllStructSetData($tCornerPixs, 1, DllStructGetData($tFind, 1, $tSizeFind.X * $tSizeFind.Y), 3) Local $tCornerInc = DllStructCreate('dword[3]') DllStructSetData($tCornerInc, 1, ($tSizeFind.X - 1) * 4, 1) DllStructSetData($tCornerInc, 1, (($tSizeSource.X - $tSizeFind.X) + $tSizeSource.X * ($tSizeFind.Y - 2) + 1) * 4, 2) DllStructSetData($tCornerInc, 1, ($tSizeFind.X - 1) * 4, 3) Local $pStart = DllStructGetPtr($tSource) Local $iEndAddress = Int($pStart + DllStructGetSize($tSource)) Local $tFound = DllStructCreate('dword[' & $iMax & ']') Local $ret = DllCallAddress('dword', DllStructGetPtr($tMem), 'struct*', $tSource, 'struct*', $tFind, _ 'dword', $tSizeFind.X, 'dword', $tSizeFind.Y, _ 'dword', $iEndAddress, 'dword', $iRowInc, 'struct*', $tFound, _ 'dword', $iFirstDiffPix, 'dword', $iFirst_Diff_Inc, _ 'struct*', $tCornerInc, 'struct*', $tCornerPixs, _ 'dword', $iMax) Local $aCoords[$ret[0] + 1][4] = [[$ret[0], Round(TimerDiff($iTime))]] If Not $ret[0] Then Return SetError(0, 0, $aCoords) For $i = 1 To $ret[0] $iFoundIndex = ((DllStructGetData($tFound, 1, $i) - $pStart) / 4) + 1 $aCoords[$i][3] = Int(($iFoundIndex - 1) / $tSizeSource.X) $aCoords[$i][2] = ($iFoundIndex - 1) - ($aCoords[$i][3] * $tSizeSource.X) $aCoords[$i][0] = $tSizeFind.X $aCoords[$i][1] = $tSizeFind.Y Next $aCoords[0][1] = Round(TimerDiff($iTime)) Return SetError(0, 0, $aCoords) EndFunc ;==>_BmpSearchEx
-
InnI got a reaction from mLipok in Using UI Automation Code in AutoIt
AutoIt can find any top-level window. No need to search from desktop. Just use method ElementFromHandle. This method can be used for any controls that have a native handle (found by AutoIt).
#AutoIt3Wrapper_UseX64=y Global $_UIA_SMART_AUTOMATION #include <GUIConstantsEx.au3> #include "UIA_Constants.au3" Example() Func Example() Local $hGUI = GUICreate("UIA HWND Example") Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) GUISetState(@SW_SHOW, $hGUI) ; --------------------------------- ; main window $hWnd = WinWait("UIA HWND Example") _Log("! hWnd = " & $hWnd) $oWindow = _UIASimple_ElementFromHandle($hWnd) Local $hWnd2, $s_Title2 $oWindow.GetCurrentPropertyValue($UIA_NativeWindowHandlePropertyId, $hWnd2) $oWindow.GetCurrentPropertyValue($UIA_NamePropertyId, $s_Title2) _Log("! hWnd2 = 0x" & Hex($hWnd2) & ", $s_Title2 = " & $s_Title2) _Log("----------------") ; button OK $hCtrl = ControlGetHandle("UIA HWND Example", "", "Button1") _Log("! hCtrl = " & $hCtrl) $oBtn = _UIASimple_ElementFromHandle($hCtrl) Local $hCtrl2, $sText $oBtn.GetCurrentPropertyValue($UIA_NativeWindowHandlePropertyId, $hCtrl2) $oBtn.GetCurrentPropertyValue($UIA_NamePropertyId, $sText) _Log("! hCtrl2 = 0x" & Hex($hCtrl2) & ", $sText = " & $sText) ; --------------------------------- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example Func _UIASimple_ElementFromHandle($hHandle) If Not IsHWnd($hHandle) Then Return SetError(1, 0, 0) Local $pElement, $oElement, $oUIA = _UIASimple_InitAutomation() $oUIA.ElementFromHandle($hHandle, $pElement) $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement) $pElement = 0 If Not IsObj($oElement) Then Return SetError(2, 0, 0) Return $oElement EndFunc ;==>_UIASimple_ElementFromHandle Func _UIASimple_InitAutomation() If IsObj($_UIA_SMART_AUTOMATION) Then Return $_UIA_SMART_AUTOMATION Local $oUIA = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation) If Not IsObj($oUIA) Then Return _Log(@ScriptLineNumber & " $oUIA ERR") $_UIA_SMART_AUTOMATION = $oUIA Return $_UIA_SMART_AUTOMATION EndFunc ;==>_UIASimple_InitAutomation Func _Log($sData, $iERR = @error, $iEXT = @extended) ConsoleWrite($sData & @CRLF) Return SetError($iERR, $iEXT) EndFunc ;==>_Log
-
InnI got a reaction from mLipok in Using UI Automation Code in AutoIt
;~ Local $hWnd2 ;~ $hWnd2 = $oWindow.GetCurrentPropertyValue($UIA_NativeWindowHandlePropertyId, False) ;~ Local $s_Title2 = $oWindow.GetCurrentPropertyValue($UIA_NamePropertyId, True) Local $hWnd2, $s_Title2 $oWindow.GetCurrentPropertyValue($UIA_NativeWindowHandlePropertyId, $hWnd2) $oWindow.GetCurrentPropertyValue($UIA_NamePropertyId, $s_Title2)
-
InnI got a reaction from mike2003 in Can't get data from STDOUT
You use StderrRead. Try to use StdoutRead.
-
InnI got a reaction from Lion66 in Get a message on the window restore event
#Include <WindowsConstants.au3> #Include <GUIConstantsEx.au3> $Restored = True $hGUI = GUICreate("Test", 640, 480, -1, -1, $WS_OVERLAPPEDWINDOW) $Button1 = GUICtrlCreateButton("Maximize", 80, 56, 113, 33) GUISetState() GUIRegisterMsg($WM_SIZE, "WM_SIZE") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 WinSetState($hGUI, "", @SW_MAXIMIZE) Sleep(1000) WinSetState($hGUI, "", @SW_RESTORE) EndSwitch WEnd ; https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-size Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) Switch BitAND($wParam, 0xFFFF) Case 0 ; SIZE_RESTORED If Not $Restored Then ConsoleWrite("Window was restored" & @LF) $Restored = True Case 1 ; SIZE_MINIMIZED ConsoleWrite("Window was minimized" & @LF) $Restored = False Case 2 ; SIZE_MAXIMIZED ConsoleWrite("Window was maximized" & @LF) $Restored = False EndSwitch Return "GUI_RUNDEFMSG" EndFunc
-
InnI got a reaction from Danp2 in Get a message on the window restore event
#Include <WindowsConstants.au3> #Include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 640, 480, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX)) $Button1 = GUICtrlCreateButton("Maximize", 80, 56, 113, 33) GUISetState() GUIRegisterMsg($WM_SIZE, "WM_SIZE") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 WinSetState($hGUI, "", @SW_MAXIMIZE) Sleep(1000) WinSetState($hGUI, "", @SW_RESTORE) EndSwitch WEnd ; https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-size Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) Switch BitAND($wParam, 0xFFFF) Case 0 ; SIZE_RESTORED ConsoleWrite("Window was restored" & @LF) Case 1 ; SIZE_MINIMIZED ConsoleWrite("Window was minimized" & @LF) Case 2 ; SIZE_MAXIMIZED ConsoleWrite("Window was maximized" & @LF) Case 3 ; SIZE_MAXSHOW ConsoleWrite("SIZE_MAXSHOW" & @LF) Case 4 ; SIZE_MAXHIDE ConsoleWrite("SIZE_MAXHIDE" & @LF) EndSwitch Return "GUI_RUNDEFMSG" EndFunc
-
InnI got a reaction from TheDcoder in Date control increment/decrement buttons disappear after updating GUI background
GUICreate("My GUI get time", 200, 200, 800, 200, $WS_CLIPCHILDREN) ; or GUISetBkColor($bActive ? $COLOR_GREEN : $COLOR_RED) _WinAPI_InvalidateRect(GUICtrlGetHandle($idDate)) ; Global $idDate
-
InnI got a reaction from Zedna in Date control increment/decrement buttons disappear after updating GUI background
GUICreate("My GUI get time", 200, 200, 800, 200, $WS_CLIPCHILDREN) ; or GUISetBkColor($bActive ? $COLOR_GREEN : $COLOR_RED) _WinAPI_InvalidateRect(GUICtrlGetHandle($idDate)) ; Global $idDate
-
InnI got a reaction from Tick in Controlclick on Zbutton?
ControlSend($hWnd, "", "ZButton22", "{space}") ; or ControlCommand($hWnd, "", "ZButton22", "SendCommandID", 0xF5) ; $BM_CLICK
-
InnI got a reaction from Tick in How to select (click) the pop-up menu item, when the screen is locked?
Try replace to ControlClick
;~ _MouseLeftClick($hWnd, $aRect[0] + 3, $aRect[1] + 3) ControlClick($hWnd, "", "", "left", 1, $aRect[0] + 3, $aRect[1] + 3) Will anything change?
-
InnI got a reaction from Tick in How to select (click) the pop-up menu item, when the screen is locked?
_MouseLeftClick is an extended ControlClick for left mouse button. Some windows need WM_SETCURSOR message. But if ControlClick works fine, use it.
-
InnI got a reaction from Tick in How to select (click) the pop-up menu item, when the screen is locked?
; Script opens SciTE pop-up menu and selects "Select All" item #include <GuiMenu.au3> #include <SendMessage.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> $sText = "Select All" ; menu item text Sleep(3333) ; lock desktop manually during this time (Win+L) ControlClick("[Class:SciTEWindow]", "", "Scintilla1", "right") $hWnd = WinWait("[class:#32768]") $hMenu = _SendMessage($hWnd, 0x01E1) ; MN_GETHMENU $iItem = _GUICtrlMenu_FindItem($hMenu, $sText) $aRect = _GUICtrlMenu_GetItemRect($hWnd, $hMenu, $iItem) _MouseLeftClick($hWnd, $aRect[0] + 3, $aRect[1] + 3) Func _MouseLeftClick($hWnd, $X, $Y, $Sleep = 10) Local Const $MK_LBUTTON = 0x0001 _WinAPI_PostMessage($hWnd, $WM_SETCURSOR, $hWnd, _WinAPI_MakeLong($HTCLIENT, $WM_LBUTTONDOWN)) _WinAPI_PostMessage($hWnd, $WM_LBUTTONDOWN, $MK_LBUTTON, _WinAPI_MakeLong($X, $Y)) Sleep($Sleep) _WinAPI_PostMessage($hWnd, $WM_SETCURSOR, $hWnd, _WinAPI_MakeLong($HTCLIENT, $WM_LBUTTONUP)) _WinAPI_PostMessage($hWnd, $WM_LBUTTONUP, 0, _WinAPI_MakeLong($X, $Y)) EndFunc
-
InnI got a reaction from pixelsearch in How to select (click) the pop-up menu item, when the screen is locked?
; Script opens SciTE pop-up menu and selects "Select All" item #include <GuiMenu.au3> #include <SendMessage.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> $sText = "Select All" ; menu item text Sleep(3333) ; lock desktop manually during this time (Win+L) ControlClick("[Class:SciTEWindow]", "", "Scintilla1", "right") $hWnd = WinWait("[class:#32768]") $hMenu = _SendMessage($hWnd, 0x01E1) ; MN_GETHMENU $iItem = _GUICtrlMenu_FindItem($hMenu, $sText) $aRect = _GUICtrlMenu_GetItemRect($hWnd, $hMenu, $iItem) _MouseLeftClick($hWnd, $aRect[0] + 3, $aRect[1] + 3) Func _MouseLeftClick($hWnd, $X, $Y, $Sleep = 10) Local Const $MK_LBUTTON = 0x0001 _WinAPI_PostMessage($hWnd, $WM_SETCURSOR, $hWnd, _WinAPI_MakeLong($HTCLIENT, $WM_LBUTTONDOWN)) _WinAPI_PostMessage($hWnd, $WM_LBUTTONDOWN, $MK_LBUTTON, _WinAPI_MakeLong($X, $Y)) Sleep($Sleep) _WinAPI_PostMessage($hWnd, $WM_SETCURSOR, $hWnd, _WinAPI_MakeLong($HTCLIENT, $WM_LBUTTONUP)) _WinAPI_PostMessage($hWnd, $WM_LBUTTONUP, 0, _WinAPI_MakeLong($X, $Y)) EndFunc
-
InnI got a reaction from pixelsearch in How do I click on a popup?
@masCh Try this function for click popup menu item by index
#include <GuiMenu.au3> WinWait("[class:#32768]") _ClickPopupItem(0) Func _ClickPopupItem($iIndex) Local $hWnd = WinGetHandle("[class:#32768]") If Not $hWnd Then Return SetError(1, 0, 0) Local $hPopup = _SendMessage($hWnd, 0x01E1) ; MN_GETHMENU If $iIndex < 0 Or $iIndex >= _GUICtrlMenu_GetItemCount($hPopup) Then Return SetError(2, 0, 0) Local $aRect = _GUICtrlMenu_GetItemRect($hWnd, $hPopup, $iIndex) If Not IsArray($aRect) Then Return SetError(3, 0, 0) Local $iOpt = Opt("MouseCoordMode", 1) MouseClick("left", $aRect[0], $aRect[1], 1, 0) Opt("MouseCoordMode", $iOpt) Return 1 EndFunc
-
InnI got a reaction from Shark007 in HiRes_DPI settings via Autoit3Wrapper
If you set Per-Monitor or Per-Monitor (V2) DPI Awareness then you must to resize and reposition the controls each time when receive WM_DPICHANGED message. Otherwise, the controls will match the DPI of the primary monitor, while other monitors may have different DPI.
-
InnI got a reaction from mLipok in Get per-monitor DPI scaling factor
#include <WinAPIGdi.au3> ; enum _PROCESS_DPI_AWARENESS Global Const $PROCESS_DPI_UNAWARE = 0 Global Const $PROCESS_SYSTEM_DPI_AWARE = 1 Global Const $PROCESS_PER_MONITOR_DPI_AWARE = 2 ; enum _MONITOR_DPI_TYPE Global Const $MDT_EFFECTIVE_DPI = 0 Global Const $MDT_ANGULAR_DPI = 1 Global Const $MDT_RAW_DPI = 2 Global Const $MDT_DEFAULT = $MDT_EFFECTIVE_DPI _WinAPI_SetProcessDpiAwareness($PROCESS_PER_MONITOR_DPI_AWARE) $aMonitors = _WinAPI_EnumDisplayMonitors() If Not IsArray($aMonitors) Then Exit MsgBox(0, "", "EnumDisplayMonitors error") For $i = 1 To $aMonitors[0][0] $aDPI = _WinAPI_GetDpiForMonitor($aMonitors[$i][0], $MDT_DEFAULT) $_ = IsArray($aDPI) ? MsgBox(0, "", $aDPI[0] & ":" & $aDPI[1]) : MsgBox(0, "", "error") Next Func _WinAPI_SetProcessDpiAwareness($DPIAware) DllCall("Shcore.dll", "long", "SetProcessDpiAwareness", "int", $DPIAware) If @error Then Return SetError(1, 0, 0) EndFunc Func _WinAPI_GetDpiForMonitor($hMonitor, $dpiType) Local $X, $Y $aRet = DllCall("Shcore.dll", "long", "GetDpiForMonitor", "long", $hMonitor, "int", $dpiType, "uint*", $X, "uint*", $Y) If @error Or Not IsArray($aRet) Then Return SetError(1, 0, 0) Local $aDPI[2] = [$aRet[3],$aRet[4]] Return $aDPI EndFunc