Jump to content

Leaderboard

Popular Content

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

  1. In this thread it was mentioned how a software could manage single/multiple monitors. I was curious to see how it could be possible to make it work without the tool. So I made a script that change brightness (VCP 10) of my primary monitor for a few seconds. To learn about the VCP commands refer to : https://www.ddcutil.com/vcpinfo_output/ Among other commands, you can turn on/off (VCP D6) secondary monitor, change contrast (VCP 12), etc. In the example you can see (and parse) all commands allowed by your monitor(s). #include <String.au3> #include <Array.au3> #include <WinAPIGdi.au3> #include <WinAPISysWin.au3> Local $aPos, $aData = _WinAPI_EnumDisplayMonitors() If IsArray($aData) Then ReDim $aData[$aData[0][0] + 1][5] For $i = 1 To $aData[0][0] $aPos = _WinAPI_GetPosFromRect($aData[$i][1]) For $j = 0 To 3 $aData[$i][$j + 1] = $aPos[$j] Next Next EndIf _ArrayDisplay($aData, '_WinAPI_EnumDisplayMonitors') Local $hWnd = _WinAPI_GetDesktopWindow() ConsoleWrite($hWnd & @CRLF) $hMonitor = _WinAPI_MonitorFromWindow($hWnd, $MONITOR_DEFAULTTONEAREST) ConsoleWrite($hMonitor & @CRLF) Local $aRet = DllCall("Dxva2.dll", "int", "GetNumberOfPhysicalMonitorsFromHMONITOR", "handle", $hMonitor, "int*", 0) ;_ArrayDisplay($aRet) Local $iNumberMonitor = $aRet[2] Const $tag_PHYSICAL_MONITOR = "handle hPhysicalMonitor; wchar strPhysicalMonitorDescription[128];" Local $tPhysicalMonitor = DllStructCreate(_StringRepeat($tag_PHYSICAL_MONITOR, $iNumberMonitor)) $aRet = DllCall("Dxva2.dll", "int", "GetPhysicalMonitorsFromHMONITOR", "handle", $hMonitor, "int", $iNumberMonitor, "struct*", $tPhysicalMonitor) ;_ArrayDisplay($aRet) MsgBox($MB_SYSTEMMODAL, "", $tPhysicalMonitor.strPhysicalMonitorDescription) $aRet = DllCall("Dxva2.dll", "int", "GetCapabilitiesStringLength", "handle", $tPhysicalMonitor.hPhysicalMonitor, "int*", 0) ;_ArrayDisplay($aRet) Local $iLength = $aRet[2] + 1 Local $tCapabilities = DllStructCreate("char sCapabilities[" & $iLength & "];") $aRet = DllCall("Dxva2.dll", "int", "CapabilitiesRequestAndCapabilitiesReply", "handle", $tPhysicalMonitor.hPhysicalMonitor, _ "ptr", DllStructGetPtr($tCapabilities), "int", $iLength) ;_ArrayDisplay($aRet) ConsoleWrite($tCapabilities.sCapabilities & @CRLF) Local Enum $MC_MOMENTARY, $MC_SET_PARAMETER ; _MC_VCP_CODE_TYPE $aRet = DllCall("Dxva2.dll", "int", "GetVCPFeatureAndVCPFeatureReply", "handle", $tPhysicalMonitor.hPhysicalMonitor, _ "byte", 0x10, "int*", 0, "int*", 0, "int*", 0) ;_ArrayDisplay($aRet) ConsoleWrite($aRet[3] = $MC_MOMENTARY ? "Momentary" : ($aRet[3] = $MC_SET_PARAMETER ? "Set" : "Unknown") & @CRLF) ConsoleWrite("Current value = " & $aRet[4] & "/" & "Maximum = " & $aRet[5] & @CRLF) Local $iCurrent = $aRet[4] $aRet = DllCall("Dxva2.dll", "int", "SetVCPFeature", "handle", $tPhysicalMonitor.hPhysicalMonitor, _ "byte", 0x10, "int", 20) Sleep(5000) $aRet = DllCall("Dxva2.dll", "int", "SetVCPFeature", "handle", $tPhysicalMonitor.hPhysicalMonitor, _ "byte", 0x10, "int", $iCurrent) $aRet = DllCall("Dxva2.dll", "int", "DestroyPhysicalMonitors", "int", $iNumberMonitor, "ptr", DllStructGetPtr($tPhysicalMonitor)) ;_ArrayDisplay($aRet)
    1 point
  2. For those who may be interested, just made an example script using the same API as the tool mentioned by @Earthshine, but without any external software...
    1 point
  3. Thanks a lot @Earthshine, it works like a charm! I now use MultiMonitorTool.exe to enable/disable monitors and on Nirsoft website I also found this very handy utility: soundvolumeview-x64 I use it to quickly swap my sound output device. Thanks a lot to all of you guys, what an awesome community!
    1 point
  4. Hi jimmy123j, I had the same issue with the dotted rectangle when the item is focused. @LarsJ provided a solution that worked fine for me and it seems to solve your problem too. 1) Running your original script, the focused item is surrounded with the dotted rectangle : 2) With the additional line of code (placed immediately after the listview creation), the dotted rectangle has gone : $Window2_List = GUICtrlCreateListView("Item 1|Item 2|Item 3|Item 4|Item 5", 0, 0, 400, 200, $LVS_REPORT + $LVS_SINGLESEL, $LVS_EX_FULLROWSELECT + $WS_EX_CLIENTEDGE) _GUICtrlListView_SetCallBackMask($Window2_List, 4) ; "disable state information about focused item" (LarsJ) . Can be useful (keep that line)
    1 point
  5. Yeah I found this utility from that thread https://www.nirsoft.net/utils/control_my_monitor.html You can control it via the command line so you could do it in AutoIT very easily
    1 point
  6. In Windows 10 it normally uses the following key, you would need to find the hash key which is machine specific which can be a challenge although their are tools from memory that can automate this. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\UserChoice While you can use group policy to force file associations, it means users aren't able to change those associations https://admx.help/?Category=Windows_10_2016&Policy=Microsoft.Policies.WindowsExplorer::DefaultAssociationsConfiguration You can configure the default user file associations, but this only impacts new user accounts not existing user accounts. https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/export-or-import-default-application-associations
    1 point
  7. Windows is treating the filenames as Strings. The filename (argument) is passed to other apps as a string. On the AutoIt Script side, it is passed as a string as well, see the Command Line Parameters: https://www.autoitscript.com/autoit3/docs/intro/running.htm When you double click on a text file, on windows side, it can be a bit complicated. I do not know the exact order but it looks something like: Windows explorer is checking if the text extension, usually ".txt" has an assigned app to open it. If yes, it is opening the default app, if no, it is looking first if there is an app for the unknown files ( * ), then if it does not know how to, it presents a list of apps which could open it. (The apps usually set the extensions which they can open, somewhere in the registry (new in win 10 i think) ) Here is a small info on how to change the default editor for .bat files: https://www.itprotoday.com/windows-78/how-can-i-change-default-editor-used-editing-batch-files They use, in the example: But i remember, at least from the XP times that the filenames/paths with spaces in it may not work. (because space is a delimiter char, used to distinguish the program from the parameter) The correct use, at least for windows before 10, should be:
    1 point
×
×
  • Create New...