Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/10/2023 in all areas

  1. ...do I have to moderate ?, no ?, ok, I will, but I rather not. In any case..., all of you are right in your statements. The title say "Knowledge of C++ language is necessary" and the answer is no. Is it beneficial ?, yes. Is it needed ?, no. Should you learn it, yes. Must you ?, no. Good chat, carry on. PS: if anyone can show me links to how to have GUIs as easy as with AutoIt ( with "add your own code if you feel like to" and not be locked in a "drag and drop builder" only mode ), I'll try that language. Thanks
    2 points
  2. You can look even more under the hood and learn assembly, but wait you can look even more under the hood and write binary code. So the conclusion might be that everything it's a must know. It's definitely good to know as much as you can but what you really need depends very much of what do you try to achieve. Most people will be perfectly happy with what native AutoIt provides.
    2 points
  3. I've wanted to post this for a while. It's a great script to help debug control data....perfect scenario, when you have a 'Button' grouping, and spy tools cannot focus on those controls within the button bounds (groups). I also use it to verify that a given ID is not present more than once...if not, that's how I identify the control in future scripts. Output can be filtered by: 1) Filter by IsVisible 2) Filter by matching class (ex Button, Label, Static) 3) Filter by containing text #include <Array.au3> #include <WinAPI.au3> ConsoleWrite("Make your window active!" & @CRLF) Sleep(5000) GetAllWindowsControls(WinGetHandle("[ACTIVE]")) Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default) If Not IsHWnd($hCallersWindow) Then ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF) Return False EndIf ; Get all list of controls If $bOnlyVisible = Default Then $bOnlyVisible = False If $sStringIncludes = Default Then $sStringIncludes = "" If $sClass = Default Then $sClass = "" $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 If StringLen($sClass)>0 Then For $i = UBound($aClassList)-1 To 0 Step - 1 If $aClassList[$i]<>$sClass Then _ArrayDelete($aClassList,$i) EndIf Next EndIf For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible") If $bOnlyVisible And Not $bIsVisible Then $iTotalCounter += 1 ContinueLoop EndIf If StringLen($sStringIncludes) > 0 Then If Not StringInStr($text, $sStringIncludes) Then $iTotalCounter += 1 ContinueLoop EndIf EndIf If IsArray($aPos) Then ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>GetAllWindowsControls
    1 point
  4. I agree with @wolf9228. In the meantime, I've been able to acquire a little C/C++ knowledge that now makes reading source code on MSDN sites and the like a little easier. It's not essential for Autoit, but it's helpful when browsing pages where the source code is written in C/C++. For beginners Autoit is extremely suitable, since one hardly needs WinAPI knowledge and programming with the WinAPI simplifies very much. If you want to look under the hood, then you must inevitably deal with the WinAPI and there is no way around MSDN...
    1 point
  5. Shark007

    Tester needed ^^

    new screenshots 4KPC @225 laptop 1080p screen @ 150 laptop dragged to 4K @ 225
    1 point
  6. ..write a log file ?, I mean, thousands of results ?. Are you planning to use it to code, log, ..use how ? The line of questioning goes towards the solution that would better fit your needs.
    1 point
  7. Thank you for all this work it works very nice Here is the full script ;-------------------------------------------------------------------------------------- #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #include "encryption\AutoIt\CryptoNG.au3" #include <String.au3> #include <Array.au3> #include <String.au3> #include <Inet.au3> #include <MsgBoxConstants.au3> #include <Constants.au3> $IP_Address = @IPAddress1 $MAC_Address = GET_MAC($IP_Address) Func GET_MAC($_MACsIP) Local $_MAC,$_MACSize Local $_MACi,$_MACs,$_MACr,$_MACiIP $_MAC = DllStructCreate("byte[6]") $_MACSize = DllStructCreate("int") DllStructSetData($_MACSize,1,6) $_MACr = DllCall ("Ws2_32.dll", "int", "inet_addr", "str", $_MACsIP) $_MACiIP = $_MACr[0] $_MACr = DllCall ("iphlpapi.dll", "int", "SendARP", "int", $_MACiIP, "int", 0, "ptr", DllStructGetPtr($_MAC), "ptr", DllStructGetPtr($_MACSize)) $_MACs = "" For $_MACi = 0 To 5 If $_MACi Then $_MACs = $_MACs & ":" $_MACs = $_MACs & Hex(DllStructGetData($_MAC,1,$_MACi+1),2) Next DllClose($_MAC) DllClose($_MACSize) Return $_MACs EndFunc ; The URL of the web page Local $sUrl = "http://www.test.com/mac.php" ; Get the source code of the web page Local $sSource = _INetGetSource($sUrl) aes_cbc_decrypt_example() ;================================================= Func aes_cbc_decrypt_example() Const $ENC_BASE64_MESSAGE = $sSource, _ $SECRET = "Test12345678@A" Local $sDecryptedMessage = "" Local $vEncryptKey = "" Local $xFullEncryptedMessage = Binary(""), _ $xEncryptedMessage = Binary(""), _ $xIV = Binary("") ;Pad short key with null characters to be compatible with PHP's openssl_encrypt() function $vEncryptKey = Binary($SECRET & _StringRepeat(Chr(0), 18)) ;Convert encrypted message from base64 to binary $xFullEncryptedMessage = _CryptoNG_CryptStringToBinary($ENC_BASE64_MESSAGE, $CNG_CRYPT_STRING_BASE64) If @error Then ConsoleWrite("ERROR: " & _CryptoNG_LastErrorMessage() & @CRLF) Return False EndIf ;Parse out IV and encrypted message from full encrypted message $xIV = BinaryMid($xFullEncryptedMessage, 1, 16) $xEncryptedMessage = BinaryMid($xFullEncryptedMessage, 17) ;Decrypt encrypted message $sDecryptedMessage = _CryptoNG_AES_CBC_DecryptData($xEncryptedMessage, $vEncryptKey, $xIV) If @error Then ConsoleWrite("ERROR: " & _CryptoNG_LastErrorMessage() & @CRLF) Return False EndIf Global $pagecontent = $sDecryptedMessage EndFunc If StringInStr($pagecontent, $MAC_Address) Then MsgBox(0, $MAC_Address, "Found "&$MAC_Address) ; ;Do some tasks Else MsgBox(0, $MAC_Address, "Not Found "&$MAC_Address) EndIf
    1 point
  8. #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #include <Constants.au3> #include "CryptoNG\CryptoNG.au3" #include <String.au3> aes_256_cbc_decrypt_example() Func aes_256_cbc_decrypt_example() Const $ENC_BASE64_MESSAGE = "Viah/Gz3hotsXtll2d1eSrXv3cT70QyuMizS5HBsxV9PgjgsLSA8UHL1AAkHtuJN", _ $PASSPHRASE = "Test12345678@A" Local $sDecryptedMessage = "" Local $vEncryptKey = "" Local $xFullEncryptedMessage = Binary(""), _ $xEncryptedMessage = Binary(""), _ $xIV = Binary("") ;Pad/Truncate 32 byte (256 bit) key to be compatible with PHP's openssl_encrypt() function. ;- https://www.php.net/manual/en/function.openssl-encrypt.php Select Case BinaryLen($PASSPHRASE) < 32 $vEncryptKey = Binary($PASSPHRASE & _StringRepeat(Chr(0), 32 - BinaryLen($PASSPHRASE))) Case BinaryLen($PASSPHRASE) > 32 $vEncryptKey = BinaryMid($PASSPHRASE, 1, 32) Case Else $vEncryptKey = Binary($PASSPHRASE) EndSelect ;Convert encrypted message from base64 to binary $xFullEncryptedMessage = _CryptoNG_CryptStringToBinary($ENC_BASE64_MESSAGE, $CNG_CRYPT_STRING_BASE64) If @error Then Exit MsgBox($MB_ICONERROR, "_CryptoNG_CryptStringToBinary() Error", _CryptoNG_LastErrorMessage()) ;Parse out IV and encrypted message from full encrypted message $xIV = BinaryMid($xFullEncryptedMessage, 1, 16) $xEncryptedMessage = BinaryMid($xFullEncryptedMessage, 17) ;Decrypt encrypted message $sDecryptedMessage = _CryptoNG_AES_CBC_DecryptData($xEncryptedMessage, $vEncryptKey, $xIV) If @error Then Exit MsgBox($MB_ICONERROR, "_CryptoNG_AES_CBC_DecryptData() Error", _CryptoNG_LastErrorMessage()) ;Display results ConsoleWrite(@CRLF) ConsoleWrite("CryptoNG UDF v" & _CryptoNG_Version() & @CRLF & @CRLF) ConsoleWrite("Full encrypted message (Base64) = " & $ENC_BASE64_MESSAGE & @CRLF) ConsoleWrite("Full encrypted message (Binary) = " & $xFullEncryptedMessage & @CRLF & @CRLF) ConsoleWrite("Initialization Vector (Binary) = " & $xIV & @CRLF) ConsoleWrite("Encrypted message (Binary) = " & $xEncryptedMessage & @CRLF & @CRLF) ConsoleWrite("Passphrase = " & $PASSPHRASE & @CRLF) ConsoleWrite("Encryption Key (Binary) = " & $vEncryptKey & @CRLF & @CRLF) ConsoleWrite("Decrypted Message = " & $sDecryptedMessage & @CRLF) EndFunc Console output: CryptoNG UDF v2.1.0 Full encrypted message (Base64) = Viah/Gz3hotsXtll2d1eSrXv3cT70QyuMizS5HBsxV9PgjgsLSA8UHL1AAkHtuJN Full encrypted message (Binary) = 0x5626A1FC6CF7868B6C5ED965D9DD5E4AB5EFDDC4FBD10CAE322CD2E4706CC55F4F82382C2D203C5072F5000907B6E24D Initialization Vector (Binary) = 0x5626A1FC6CF7868B6C5ED965D9DD5E4A Encrypted message (Binary) = 0xB5EFDDC4FBD10CAE322CD2E4706CC55F4F82382C2D203C5072F5000907B6E24D Passphrase = Test12345678@A Encryption Key (Binary) = 0x5465737431323334353637384041000000000000000000000000000000000000 Decrypted Message = 00:5F:99:41:C3:00 If you have any questions about the example script, feel free to ask.
    1 point
  9. GMK

    OOo/LibO Calc UDF

    Can't test right now, but try this: #include ".\Required-AU\OOoCalc.au3" ; For Open Office / Libre Office Spreadsheet #include <MsgBoxConstants.au3> Global $fExcelTemplate = @ScriptDir & "\Required\PO.xls" MsgBox($MB_OK, "Open Office", "Starting OO Hidden") Global $oCalc = _OOoCalc_BookOpen($fExcelTemplate, True) If @error Then Exit MsgBox($MB_TOPMOST, "Notice", "Unable to open Book: " & $fExcelTemplate) Global $oCalcWin = $oCalc.CurrentController.Frame.ContainerWindow Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase SplashTextOn("Wait","Waiting for OO To Start") WinWait("Office Calc") WinActivate("Office Calc") SplashOff() SplashTextOn("Wait","Moving Hidden Window") $oCalcWin.setPosSize(1000, 0, 800, 800, 15) ;x,y,w,h,flag=15 SplashOff() SplashTextOn("Wait","In 3 secs will show OO window") Sleep(3000) SplashOff() $oCalcWin.Visible = True MsgBox($MB_OK, "Open Office", "Click OK to close the sheet") _OOoCalc_BookClose($oCalc)
    1 point
  10. If you can you provide an encrypted message that was generated by the PHP routine that you posted, I will show you an example of how to decrypt it.
    1 point
  11. It is easiest to read the value directly in the Edit control with UIASpy. Patterns are only used for actions. eg. to press a button
    1 point
  12. http://forum.oszone.net/post-1907424.html#post1907424 http://azjio.narod.ru/autoit3_docs/userfunctions/_NumberNumToName.htm https://www.autoitscript.com/forum/topic/142799-converting-numbers
    1 point
  13. cdeb

    udf Deepl API

    here is a script to be able to translate texts via the API of DeepL Local $sText = "Questa è una prova" Local $source_lang = "IT" Local $target_lang = "ES" Local $key = "xxxxxx-xxxx-xxxxx-xxxx-xxxxxxxxx:fx" Local $sURL = "https://api-free.deepl.com/v2/translate" Local $sResult = deeplapi__translate($sText, $source_lang, $target_lang, $key, $sURL) If @error Then MsgBox($MB_SYSTEMMODAL, "", "Error deeplapi__translate() - @error ("&@error&")"&@CRLF&$sResult) ;############################################################################### Func deeplapi__translate($sText, $source_lang, $target_lang, $key, $sURL) Local $debug = 0 Local $oComErr = Null Local $sData = "text="&deeplapi__URIEncode($sText)&"&source_lang="&$source_lang&"&target_lang="&$target_lang If $debug Then ConsoleWrite("$sData: "&$sData&@CRLF) ;Set up a local COM error handler $oComErr = ObjEvent("AutoIt.Error", deeplapi__com_error_handler) If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "Unable to register COM error handler - @error = " & @error) #forceref $oComErr Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("POST", $sURL, False) If (@error) Then Return SetError(1, 0, 0) $oHTTP.SetRequestHeader("Authorization", "DeepL-Auth-Key "&$key&"") $oHTTP.SetRequestHeader("User-Agent", "YourApp/1.2.3") $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send($sData) If @error Then Return SetError(2, 0, 0) If ($oHTTP.Status <> 200) Then Local $msgError Switch $oHTTP.Status Case 400 $msgError = "400 (BadRequest)" Case 403 $msgError = "403 (Forbidden)" Case 413 $msgError = "413 (PayloadTooLarge)" Case 414 $msgError = "414 (URITooLong)" Case 429 $msgError = "429 (TooManyRequests)" Case 456 $msgError = "456 (QuotaExceeded)" Case 500 $msgError = "500 (InternalServerError)" Case 504 $msgError = "504 (ServiceUnavailable)" Case 529 $msgError = "529 (TooManyRequests)" Case Else $msgError = $oHTTP.Status&" (undefined status)" EndSwitch Return SetError(3, 0, $msgError) EndIf Return SetError(0, 0, $oHTTP.ResponseText) EndFunc #Region - internal --------------------------------------------------------------- ;############################################################################### ; source: https://www.autoitscript.com/forum/topic/95850-url-encoding/?do=findComment&comment=689060 ; modified es: 'ciao%20mondo' e non 'ciao+mondo' Func deeplapi__URIEncode($sData) ; Prog@ndy Local $aData = StringSplit(BinaryToString(StringToBinary($sData,4),1),"") Local $nChar $sData="" For $i = 1 To $aData[0] ; ConsoleWrite($aData[$i] & @CRLF) $nChar = Asc($aData[$i]) Switch $nChar Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126 $sData &= $aData[$i] ;~ Case 32 ;~ $sData &= "+" Case Else $sData &= "%" & Hex($nChar,2) EndSwitch Next Return $sData EndFunc ;############################################################################### Func deeplapi__com_error_handler($oError) With $oError ConsoleWrite(@CRLF & "COM ERROR DETECTED!" & @CRLF) ConsoleWrite(" Error ScriptLine....... " & .scriptline & @CRLF) ConsoleWrite(" Error Number........... " & "0x" & Hex(.number) & " (" & .number & ")" & @CRLF) ConsoleWrite(" Error WinDescription... " & StringStripWS(.windescription, $STR_STRIPTRAILING) & @CRLF) ConsoleWrite(" Error RetCode.......... " & "0x" & Hex(Number(.retcode)) & " (" & Number(.retcode) & ")" & @CRLF) ConsoleWrite(" Error Description...... " & StringStripWS(.description , $STR_STRIPTRAILING) & @CRLF) EndWith Return ;Return to allow calling function to handle error EndFunc #EndRegion - internal ------------------------------------------------------------
    1 point
  14. @NassauSky Local $sValue $oValuePattern.CurrentValue($sValue) ConsoleWrite( "CurrentValue: " & $sValue & @CRLF )
    1 point
  15. UEZ

    AutoIt Snippets

    _WinAPI_SetDPIAwareness.au3 ;Coded by UEZ build 2023-07-25 beta ;To get it working properly, please compile script first and start the exe afterwards #AutoIt3Wrapper_Res_HiDpi=y #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Change2CUI=y #include <GUIConstantsEx.au3> #include <Misc.au3> #include <WinAPIGdiDC.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> #Region _WinAPI_SetDPIAwareness ;https://learn.microsoft.com/en-us/windows/win32/api/windef/ne-windef-dpi_awareness Global Enum $DPI_AWARENESS_INVALID = -1, $DPI_AWARENESS_UNAWARE = 0, $DPI_AWARENESS_SYSTEM_AWARE = 1, $DPI_AWARENESS_PER_MONITOR_AWARE = 2 ;https://learn.microsoft.com/en-us/windows/win32/hidpi/dpi-awareness-context Global Const $DPI_AWARENESS_CONTEXT_UNAWARE = $DPI_AWARENESS_UNAWARE - 1 Global Const $DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = $DPI_AWARENESS_UNAWARE - 2 Global Const $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = $DPI_AWARENESS_UNAWARE - 3 Global Const $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = $DPI_AWARENESS_UNAWARE - 4 Global Const $DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED = $DPI_AWARENESS_UNAWARE - 5 ; enum _MONITOR_DPI_TYPE Global Enum $MDT_EFFECTIVE_DPI = 0, $MDT_ANGULAR_DPI, $MDT_RAW_DPI Global Const $MDT_DEFAULT = $MDT_EFFECTIVE_DPI Global Const $WM_DPICHANGED = 0x02E0 ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-adjustwindowrectexfordpi Func _WinAPI_AdjustWindowRectExForDpi($dpi, $dwStyle, $dwExStyle, $bMenu = False) Local $tRECT = DllStructCreate($tagRECT) Local $aResult = DllCall("user32.dll", "bool", "AdjustWindowRectExForDpi", "struct*", $tRECT, "dword", $dwStyle, "bool", $bMenu, "dword", $dwExStyle, "uint", $dpi) ;requires Win10 v1607+ / no server support If @error Then Return SetError(@error, @extended, 0) Return $tRECT EndFunc ;==>_WinAPI_AdjustWindowRectExForDpi Func _WinAPI_GetDPI($hWnd = _WinAPI_GetDesktopWindow()) Local Const $hDC = _WinAPI_GetDC($hWnd) If @error Then Return SetError(1, 0, 0) Local Const $iDPI = _WinAPI_GetDeviceCaps($hDC, $LOGPIXELSX) If @error Or Not $iDPI Then _WinAPI_ReleaseDC($hWnd, $hDC) Return SetError(2, 0, 0) EndIf _WinAPI_ReleaseDC($hWnd, $hDC) Return $iDPI EndFunc ;==>_WinAPI_GetDPI ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforwindow Func _WinAPI_GetDpiForWindow($hWnd) Local $aResult = DllCall("user32.dll", "uint", "GetDpiForWindow", "hwnd", $hWnd) ;requires Win10 v1607+ / no server support If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetDpiForWindow ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiawarenesscontext Func _WinAPI_SetProcessDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1703+ / Windows Server 2016+ If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_SetProcessDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setthreaddpiawarenesscontext Func _WinAPI_SetThreadDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall("user32.dll", "bool", "SetThreadDpiAwarenessContext", "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1703+ / Windows Server 2016+ If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_SetThreadDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-setprocessdpiawareness Func _WinAPI_SetProcessDpiAwareness($PROCESS_DPI_AWARENESS = $DPI_AWARENESS_PER_MONITOR_AWARE) Local $iResult = DllCall("Shcore.dll", "long", "SetProcessDpiAwareness", "int", $PROCESS_DPI_AWARENESS) ;requires Win 8.1+ / Server 2012 R2+ If @error Or $iResult Then Return SetError(1, 0, 0) Return 1 EndFunc ;==>_WinAPI_SetProcessDpiAwareness Func _WinAPI_SetDPIAwareness($DPIAwareContext = $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, $iMode = 1) Switch @OSBuild Case 6000 To 9199 If Not DllCall("user32.dll", "bool", "SetProcessDPIAware") Then Return SetError(1, 0, 0) Case 9200 To 13999 $DPIAwareContext = ($DPIAwareContext < 0) ? 0 : ($DPIAwareContext > 2) ? 2 : $DPIAwareContext _WinAPI_SetProcessDpiAwareness($DPIAwareContext) If @error Then Return SetError(2, @error, 0) Case @OSBuild > 13999 $DPIAwareContext = ($DPIAwareContext < -5) ? -5 : ($DPIAwareContext > -1) ? -1 : $DPIAwareContext $iMode = ($iMode < 1) ? 1 : ($iMode > 2) ? 2 : $iMode Switch $iMode Case 1 _WinAPI_SetProcessDpiAwarenessContext($DPIAwareContext) If @error Then Return SetError(3, 0, 0) Case 2 _WinAPI_SetThreadDpiAwarenessContext($DPIAwareContext) If @error Then Return SetError(4, 0, 0) EndSwitch EndSwitch If @OSBuild < 14393 Then $iDPI = _WinAPI_GetDPI() If @error Then Return SetError(5, 0, 0) Else Local Const $hGUI_dummy = GUICreate("", 1, 1, 0, 0) $iDPI = _WinAPI_GetDpiForWindow($hGUI_dummy) GUIDelete($hGUI_dummy) If @error Then Return SetError(6, 0, 0) EndIf Return $iDPI EndFunc ;==>_WinAPI_SetDPIAwareness #EndRegion Global $dpiScaledX, $dpiScaledY, $aCtrlFS[5][2], $hGUI, $hGUI_child, $g_iDPI_ratio2, $iLable_child, $iPic_child, _ $sImage = "c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif" Example1() Func Example1() Local $iDPI = _WinAPI_SetDPIAwareness($DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) If @error Or Not $iDPI Then Exit MsgBox($MB_ICONERROR, "ERROR", "Cannot set DPI awareness!", 10) ConsoleWrite("DPI read: " & $iDPI & @CRLF) Local $iDPI_ratio = $iDPI / 96 $g_iDPI_ratio2 = 96 / $iDPI $hGUI = GUICreate("Example 1", 314 * $iDPI_ratio, 130 * $iDPI_ratio, -1, 10) GUISetFont(12 * $iDPI_ratio, 400, 0, "Times New Roman") $aCtrlFS[0][0] = GUICtrlCreateLabel("Label1", 16 * $iDPI_ratio, 16 * $iDPI_ratio, 40 * $iDPI_ratio, 21 * $iDPI_ratio) $aCtrlFS[0][1] = 10 GUICtrlSetBkColor(-1, 0x3399FF) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $aCtrlFS[1][0] = GUICtrlCreateLabel("Label2", 64 * $iDPI_ratio, 16 * $iDPI_ratio, 40 * $iDPI_ratio, 21 * $iDPI_ratio) $aCtrlFS[1][1] = 10 GUICtrlSetBkColor(-1, 0x3399FF) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $aCtrlFS[2][0] = GUICtrlCreateLabel("Label3", 112 * $iDPI_ratio, 16 * $iDPI_ratio, 40 * $iDPI_ratio, 21 * $iDPI_ratio) $aCtrlFS[2][1] = 10 GUICtrlSetBkColor(-1, 0x3399FF) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $aCtrlFS[3][0] = GUICtrlCreateInput("Input1", 160 * $iDPI_ratio, 16 * $iDPI_ratio, 137 * $iDPI_ratio, 22 * $iDPI_ratio) $aCtrlFS[3][1] = 10 GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $aCtrlFS[4][0] = GUICtrlCreateButton("Close", 16 * $iDPI_ratio, 48 * $iDPI_ratio, 283 * $iDPI_ratio, 65 * $iDPI_ratio) $aCtrlFS[4][1] = 16 GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $hGUI_child = GUICreate("Child", 320 * $iDPI_ratio, 260 * $iDPI_ratio, -1, -1, -1, -1, $hGUI) GUISetBkColor(0xFFFFFF) $iLable_child = GUICtrlCreateLabel("Label11", 16, 16, 288 * $iDPI_ratio, 168 * $iDPI_ratio) GUICtrlSetFont(-1, 65, 400, 0, "Times New Roman", 5) $iPic_child = GUICtrlCreatePic($sImage, 0, 160 * $iDPI_ratio, 68 * $iDPI_ratio, 71 * $iDPI_ratio) ResizeFont($hGUI) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI_child) GUIRegisterMsg($WM_DPICHANGED, "WM_DPICHANGED") While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $aCtrlFS[4][0] GUIDelete($hGUI_child) GUIDelete($hGUI) ExitLoop EndSwitch WEnd EndFunc ;==>Example1 Func ResizeFont($hWnd) Local $iDPI = _WinAPI_GetDpiForWindow($hWnd), $dpi_ratio = $iDPI / 96 Switch $hWnd Case $hGUI Local $i For $i = 0 To UBound($aCtrlFS) - 1 GUICtrlSetFont($aCtrlFS[$i][0], $aCtrlFS[$i][1] * $dpi_ratio * $g_iDPI_ratio2, 400, 0, "Times New Roman", 5) Next Case $hGUI_child GUICtrlSetFont($iLable_child, 65 * $dpi_ratio * $g_iDPI_ratio2, 400, 0, "Times New Roman", 5) EndSwitch EndFunc ;==>ResizeFont Func WM_DPICHANGED($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Local $dpi_ratio2 = 96 / _WinAPI_LoWord($wParam) Local $dpi_ratio = _WinAPI_LoWord($wParam) / 96 Local $tRECT = DllStructCreate($tagRECT, $lParam) Local $iX = $tRECT.left, $iY = $tRECT.top, $iW = $tRECT.right - $iX, $iH = $tRECT.bottom - $iY _WinAPI_AdjustWindowRectExForDpi(_WinAPI_HiWord($wParam), BitOR($WS_BORDER, $WS_CAPTION, $WS_CLIPSIBLINGS, $WS_GROUP, $WS_POPUP, $WS_SYSMENU, $WS_VISIBLE), $WS_EX_WINDOWEDGE) _WinAPI_SetWindowPos($hWnd, 0, $iX, $iY, $iW, $iH, BitOR($SWP_NOZORDER, $SWP_NOACTIVATE)) ResizeFont($hWnd) Local $aPos = ControlGetPos($hWnd, "", $iPic_child) If UBound($aPos) = 4 Then _WinAPI_MoveWindow(GUICtrlGetHandle($iPic_child), $aPos[0] * $dpi_ratio2 * $g_iDPI_ratio2, $aPos[1] * $dpi_ratio2 * $g_iDPI_ratio2, $aPos[2] * $dpi_ratio * $g_iDPI_ratio2, $aPos[3] * $dpi_ratio * $g_iDPI_ratio2) GUICtrlSetImage($iPic_child, $sImage) EndIf $tRECT = 0 ConsoleWrite("DPI change to " & _WinAPI_LoWord($wParam) & " detected and applied to the GUI elements" & @CRLF) Return 1 EndFunc ;==>WM_DPICHANGED
    1 point
  16. What's New in Version 0.2023.7.23 Fixed: compiled with "HiDpi=Y" and now looking at it in a 4k monitor with 200% scaleing, ...big oops. Broke: x64. The HiDpi patch I put together don't work running as x64. Broke: Some stuff in WinXP. The old version is still up for download. (I'll look at it what I get more time to do so) As a side effect the X,Y is correct in any monitor so, is a good update. Compiled script on 3.3.16.1 Files download are in the files section. What and why: ..decided to use the 4k monitor as the main monitor and, CV would not be properly sized Since I'm the unofficial maintainer of the code, it's up to me to fix it but, I'm in a hurry, so did what I could with the time I have. Anyone that'd like to have a go at it, please do. Is not my code/utility, is ours. ( yes, yours too )
    1 point
  17. #Include <WinAPI.au3> Global Const $SPI_GETMOUSESPEED = 112 ; 0x0070 Global Const $SPI_SETMOUSESPEED = 113 ; 0x0071 ; Get individual setting : Global $g_tMouseSpeed = DllStructCreate('int Speed') _WinAPI_SystemParametersInfo($SPI_GETMOUSESPEED, 0, DllStructGetPtr($g_tMouseSpeed), 0) ConsoleWrite("MouseSpeed (individual) = " & $g_tMouseSpeed.Speed & @CRLF) ; Info : value ranges between 1 (slowest) and 20 (fastest) - 10 is the default ; 1. Set speed to 1 = 'slowest' (for 4 sec.) _WinAPI_SystemParametersInfo($SPI_SETMOUSESPEED, 0, 1, 2) ConsoleWrite("MouseSpeed = 1 ('slowest')" & @CRLF) Sleep(4000) ; 2. Set speed to 20 = 'fastest' (for 4 sec.) _WinAPI_SystemParametersInfo($SPI_SETMOUSESPEED, 0, 20, 2) ConsoleWrite("MouseSpeed = 20 ('fastest')" & @CRLF) Sleep(4000) ; 3. Set speed back to individual setting _WinAPI_SystemParametersInfo($SPI_SETMOUSESPEED, 0, $g_tMouseSpeed.Speed, 2)
    1 point
  18. hodgepodge, The Info tool will give you coodinates in this form 984,561. These are horizontal (x) and vertical (y) coordinates. So you need to measure the top-left and bottom right of the rectangle, as shown here: x1,y1------------------------------------------- | | | | | | |--------------------------------------------x2,y2Then in PixelSearch you enter the coordinates thus: PixelSearch ( x1, y1, x2, y2, etc........)Does no--one do basic geometry anymore? M23
    1 point
×
×
  • Create New...