Leaderboard
Popular Content
Showing content with the highest reputation on 11/18/2020 in all areas
-
@DirtyJohny Since this is not as simple as it seems because some of the WMIMonitorID class properties are byte arrays that need to be converted to strings, I thought I would help you out. Below is one way that you can grab the property values. #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #include <Constants.au3> example() Func example() Local $oComErr, $oWmi, $oInstances $oComErr = ObjEvent("AutoIt.Error", com_error_handler) #forceref $oComErr ;Get WMI object $oWmi = ObjGet("winmgmts:\root\WMI") If Not IsObj($oWmi) Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to create WMI object") ;Select object instances $oInstances = $oWmi.ExecQuery("SELECT * FROM WMIMonitorID") If $oInstances.Count = 0 Then Exit MsgBox($MB_ICONWARNING,"Warning","No objects found") ;Display instance properties For $oInstance in $oInstances With $oInstance ConsoleWrite(@CRLF) ConsoleWrite("InstanceName = " & .InstanceName & @CRLF) ConsoleWrite("YearOfManufacture = " & .YearOfManufacture & @CRLF) ConsoleWrite("WeekOfManufacture = " & .WeekOfManufacture & @CRLF) If IsArray(.UserFriendlyName) Then ConsoleWrite("UserFriendlyName = " & convert_int_array_to_string(.UserFriendlyName) & @CRLF) If IsArray(.ManufacturerName) Then ConsoleWrite("ManufacturerName = " & convert_int_array_to_string(.ManufacturerName) & @CRLF) If IsArray(.SerialNumberId) Then ConsoleWrite("SerialNumberId = " & convert_int_array_to_string(.SerialNumberId) & @CRLF) If IsArray(.ProductCodeID) Then ConsoleWrite("ProductCodeID = " & convert_int_array_to_string(.ProductCodeID) & @CRLF) EndWith Next EndFunc Func convert_int_array_to_string($aUInts) Local $s = "" For $i = 0 To UBound($aUInts) - 1 If $aUInts[$i] = 0 Then ExitLoop $s &= Chr($aUInts[$i]) Next Return $s EndFunc Func com_error_handler($oComError) ConsoleWrite(@CRLF) ConsoleWrite(StringFormat("Script Line = %s", $oComError.ScriptLine) & @CRLF) ConsoleWrite(StringFormat("Win Err Desc = %s", StringStripWS($oComError.WinDescription, $STR_STRIPTRAILING)) & @CRLF) ConsoleWrite(StringFormat("Error Number = %i (0x%x)", $oComError.Number, $oComError.Number) & @CRLF) ConsoleWrite(StringFormat("Error Desc = %s", $oComError.Description) & @CRLF) Exit EndFunc Example Output: InstanceName = DISPLAY\HWP293A\5&294a6614&0&UID1048849_0 YearOfManufacture = 2012 WeekOfManufacture = 46 UserFriendlyName = HP 2311x ManufacturerName = HWP SerialNumberId = 3CQ24628ZX ProductCodeID = 293A3 points
-
SOLVED - Declaring Number for Breaking Do ... Until loop
Siwa and 2 others reacted to JockoDundee for a topic
My summary of accreditation, IMHO 1) Nine said “you’re comparing a string with a number”. Although, technically this was inaccurate, since actually it was a string compared to a string, it was the essence of the error and the first response as well, and therefore as is typical, earns 50%. 2) I said “Nine is correct.” Affirmations of true statements at best earn 25% of the original statement, which in this case was awarded 50% - therefore it earns a quarter of a half or 12.5%. 3) I posted some code purporting to be a solution. Unfortunately, I overlooked that StringRegExp returns an array, therefore my Number() function would have an unknown, but certainly unhelpful effect if applied to the array directly. Still, with a slight change it would have work - therefore I award it 2.5% 4) pseakins thought that the loop condition was not being reached, causing the infinite loop. He had missed the output listing, which was hidden under a reveal - therefore I award him the nominal 5% “good faith” effort. 5) pseakins insists that there is no number/string typing issue, because he hadn’t seen the console output. 6) I post a pedantic string/numeric example, because I had seen the output, yet still earning 0% for irrelevance. 7) pseakins looks at the output after I mention it, he concludes that both variables must be strings, since if even one is numeric, then the evaluation is numeric. totals: Nine: 50% pseakins: 35% me: 15%3 points -
Printer Management UDF
FrancescoDiMuro reacted to jguinch for a file
Version 3.1.0
646 downloads
Here is an UDF for managing printers. Features are : - add, remove or rename a printer - add or remove a driver - add or remove a TCP/IP printer port - add or remove a LPR printer port - connect to a remote printer - enum printers and there configuration and properties - pause resume or cancel all jobs of a printer - checks if a printer exists - print a test page - set the default printer1 point -
HTML Pretty Print UDF
argumentum reacted to genius257 for a topic
@NassauSky Sorry for the delay. Using it for the HTML pretty print, does not play to the strengths. When using ReDim, new memory is allocated for the entire new size of the new array and the data is then copied over. Finally the old array memory is freed. This makes sense for changes to the end of the array, but if you need to make changes at the start or middle, you need a loop to iterate over the entire loop (AutoIt is not the fastest for this). Linked Lists however are very good at changes anywhere in the list, as the next pointer simply need to be altered. Then again, Arrays are better for random index access, as each index is easy to find based on the starting ptr + item size * index, compared to the Linked List where you need to run through each element, until the desired index is reached. I choose Linked List to not waste time on re-allocating the same array again and again during generation. And for future features planned with the HTML parser. Performance wise i did not do much testing. I expect if only generation and read is needed, a dynamic array implementation (instead of the default AutoIt static array) would be best. But then again it's mostly relevant with bigger data-sets. I have a newer(, yet still messy) version of the HTML Parser here, if you're ever interested.1 point -
Holy crap. 😲 #include "WinHttp.au3" $sAddress = "https://api.pushover.net/1/messages.json" $sApiToken = "av26ac2nAXLyPKg2QMy4zf9YcUjz2G" ; <-yours here $sUserKey = "uMQf396GvMgrsDroaryKEvVyWkgfkw" ; <-yours here $sMessage = "hello world" ; Construct the form Const $sForm = '<form action="' & $sAddress & '" method="post">' & _ '<input name="token" value="' & $sApiToken & '"/>' & _ '<input name="user" value="' & $sUserKey & '"/>' & _ '<input name="message" value="' & $sMessage & '"/>' & _ '</form>' ; Open session $hOpen = _WinHttpOpen() ; To collect connection handle (because the form is inlined) $hConnect = $sForm ; Fill the form $sRead = _WinHttpSimpleFormFill($hConnect, $hOpen) ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Tada mtfk! MsgBox(4096, "Simon says", $sRead) This worked.1 point
-
The code is barely testable, because of the missing data (matriz3.txt) But i managed to notice something, later in one function, you are switching the behavior of the Autoit script with Opt("GUIOnEventMode", 1) but you are not changing it back anywhere. (which is needed for the 1st gui) you could do something like While 1 Opt("GUIOnEventMode", 0) SelectArea() WEnd or Func SelectArea() Opt("GUIOnEventMode", 0)1 point
-
MouseMove jumping erratically on 2nd monitor. - (Moved)
JockoDundee reacted to GokAy for a topic
Nice to hear, You can play with these 2 to adjust the tiny movement: 1st line inside function Local $i_Hor_Displacement = 2 ;Jiggle n pixels And, just before sleep(500), you can replace ($i_Hor_Displacement * $i_Scaling_2nd / $i_Scaling_1st) with $i_Hor_Displacement only MouseMove($iPos_x + ($i_Hor_Displacement * $i_Scaling_2nd / $i_Scaling_1st), $iPos_y + $iPos_y_Correction, 0) Depending on the scaling and resolution sometimes 1 px isn't enough to get an actual move. By the way, the initial misplacement of 1 pixels corrects itself and settles after 1 or 2 runs. Try to observe it by running the script a few times as you do from within SciTe. And, I guess the 1 px misplacement in the 1st run is because of some rounding going on.1 point -
Better ? $Xpath = StringRegExp($sValue1, '^<([^\s]*).*?>\s*(.*?)(?:<|$)',1)1 point
-
Tested on Win10 : ; adapted from DanyFirex and xMatz code #include <GuiConstants.au3> #include <Constants.au3> Global Const $S_OK = 0 Global Enum $eRender, $eCapture Global Enum $eConsole, $eMultimedia, $eCommunications Global Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}" Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}" Global Const $tagIMMDeviceEnumerator = "EnumAudioEndpoints hresult(dword;dword;ptr*);" & _ "GetDefaultAudioEndpoint hresult(dword;dword;ptr*);" & _ "GetDevice hresult(wstr;ptr*);" & _ "RegisterEndpointNotificationCallback hresult(ptr);" & _ "UnregisterEndpointNotificationCallback hresult(ptr);" Global Const $sIID_IMMDevice = "{D666063F-1587-4E43-81F1-B948E807363F}" Global Const $tagIMMDevice = "Activate hresult(clsid;dword;variant*;ptr*);" & _ "OpenPropertyStore hresult(dword;ptr*);" & _ "GetId hresult(ptr*);" & _ "GetState hresult(dword*);" Global Const $sIID_IAudioMeterInformation = "{C02216F6-8C67-4B5B-9D00-D008E73E0064}" Global Const $tagIAudioMeterInformation = "GetPeakValue hresult(float*);" & _ "GetMeteringChannelCount hresult(dword*);" & _ "GetChannelsPeakValues hresult(dword;float*);" & _ "QueryHardwareSupport hresult(dword*);" Global $oAudioMeterInformation = _MicVolObject() If Not IsObj($oAudioMeterInformation) Then Exit MsgBox ($MB_SYSTEMMODAL,"Error","Unable to mic audio meter") Global $hGUI = GUICreate("", 80, 300, -1, -1, $WS_BORDER + $WS_POPUP) Global $hControl = GUICtrlCreateProgress(20, 20, 40, 260, $PBS_VERTICAL) AdlibRegister("_LevelMeter", 45) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd AdlibUnRegister() Func _LevelMeter() Local $iPeak If $oAudioMeterInformation.GetPeakValue($iPeak) = $S_OK Then $iCurrentRead = 100 * $iPeak GUICtrlSetData($hControl, $iCurrentRead) If $iCurrentRead Then ConsoleWrite($iCurrentRead & @CRLF) EndIf EndFunc ;==>_LevelMeter Func _MicVolObject() Local Const $CLSCTX_INPROC_SERVER = 0x1 Local $oMMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $tagIMMDeviceEnumerator) If @error Then Return SetError(1, 0, 0) Local $pDefaultDevice $oMMDeviceEnumerator.GetDefaultAudioEndpoint($eCapture, $eConsole, $pDefaultDevice) If Not $pDefaultDevice Then Return SetError(2, 0, 0) Local $oDefaultDevice = ObjCreateInterface($pDefaultDevice, $sIID_IMMDevice, $tagIMMDevice) If Not IsObj($oDefaultDevice) Then Return SetError(3, 0, 0) Local $pAudioMeterInformation $oDefaultDevice.Activate($sIID_IAudioMeterInformation, $CLSCTX_INPROC_SERVER, 0, $pAudioMeterInformation) If Not $pAudioMeterInformation Then Return SetError(4, 0, 0) Return ObjCreateInterface($pAudioMeterInformation, $sIID_IAudioMeterInformation, $tagIAudioMeterInformation) EndFunc ;==>_MicVolObject1 point
-
Ok found a way to work it out : $hFile = FileOpen("gcre.rtf", $FO_BINARY) $dTxt = FileRead($hFile) FileClose($hFile) $sTxt = BinaryToString($dTxt) ConsoleWrite($sTxt & @CRLF) If StringRight($sTxt, 1) = Chr(0) Then ConsoleWrite("found char 0" & @CRLF) $sTxt = StringTrimRight($sTxt, 1) EndIf _GUICtrlRichEdit_StreamFromVar($hRichEdit, $sTxt) Replace _GUICtrlRichEdit_StreamFromFile($hRichEdit, @DesktopDir & "\gcre.rtf") with the above code. Tested and working1 point
-
@NassauSky Another possible solution would be to use _WD_ElementActionEx with the hover action.1 point
-
Get per-monitor DPI scaling factor
footswitch reacted to InnI for a topic
#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 EndFunc1 point -
Welcome to the AutoIt forum. Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. The Moderation team0 points