Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/25/2018 in all areas

  1. jchd

    XML Conversion

    Remember we're talking of a (presumably) fixed-format XML source, convertible to pure CSV as a routine task. That means an array of series of similar entities. I'd wouldn't call "difficult" the task to convert from the first form to any of the next: XML <people> <firstname>Jimmy</firstname><lastname>Hendrix</lastname> <firstname>Jim</firstname><lastname>Morrison</lastname> <firstname>Frank</firstname><lastname>Zappa</lastname> <firstname>Robert</firstname><lastname>Wyatt</lastname> <firstname>John</firstname><lastname>Coltrane</lastname> </people> JSON { "people": [ { "firstname":"Jimmy", "lastname":"Hendrix" }, { "firstname":"Jim", "lastname":"Morrison" }, { "firstname":"Frank", "lastname":"Zappa" }, { "firstname":"Robert", "lastname":"Wyatt" }, { "firstname":"John", "lastname":"Coltrane" } ] } CSV "firstname","lastname" "Jimmy","Hendrix" "Jim","Morrison" "Frank","Zappa" "Robert","Wyatt" "John","Coltrane" SQL insert into People ("firstname", "lastname") values ('Jimmy', 'Hendrix'), ('Jim', 'Morrison'), ('Frank', 'Zappa'), ('Robert', 'Wyatt'), ('John', 'Coltrane') ; Very basic string manipulation indeed.
    2 points
  2. Hi. For a certain task I need to know, if "today" is a working day (Mo-Fr, and not a Holiday either). Maybe someone else comes across a similar task: ; Autoit v3.3.8.1 #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_LegalCopyright=Rudolf Thilo, IT-Beratung Rudolf Thilo #AutoIt3Wrapper_Res_Language=1031 #AutoIt3Wrapper_Res_Field=email|autoit@ithilo.de #AutoIt3Wrapper_Res_Field=author|Rudolf Thilo (forum: "rudi") #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include-once #include <Date.au3> #include <array.au3> ; Example Call for the function: $Result = CheckWorkingDay("2012/04/08") ; that was Easter Sunday this year If $Result == True Then ConsoleWrite("Working Day" & @LF) Else ConsoleWrite($Result & @LF) EndIf Func CheckWorkingDay($Date = False) ; Function to check, if a Date is a workingday (TRUE), or "Saturday", "Sunday", "Holiday" ; Add / Remove holidays by altering the Array $aHDay ; German National Holidays (Bavaria, predominantly katholic cities) are implemented, also the Easter dependant holidays are included. (Gauss' Easter Formula) ; ;Optional Parameter $Date: If no date value "yyyy/mm/dd" is specified, "today" will be processed ; A validity check for $Date is *NOT* done! ; ; Return value: "True", if "working day" is detected; otherwise: "Saturday", "Sunday" or "Holiday" ; if a Saturday or Sunday is a Holiday as well, "Holiday" is returned. ; important note: As the return value is *NEVER* "False", you have to compare it with "==" instead of "=" !! ; Example: if CheckHoliday() == True then ... ; the statement "if CheckHoliday() then..." will *ALWAYS* be True, so it's useless as well. If $Date = False Then $Date = _NowCalcDate() ; Funktion within a Function Definition is not allowed: So $Date=False in definition, fill in "today" here... Local $Year = StringLeft($Date, 4) ; get the year Local $a, $b, $c, $d, $e, $m, $N, $k, $q If $Year < 1582 Then $Calendar = "julian" ; the retirement of the "Julian Calendar" began 1582. Else $Calendar = "gregorian" ; The use of the "Gegorian Calendar" started 1582. In 1949 China was the last state to introduce the Gregorian Calendar. EndIf $a = Mod($Year, 19) $b = Mod($Year, 4) $c = Mod($Year, 7) $k = Int($Year / 100) $p = Int((8 * $k + 13) / 25) $q = Int($k / 4) Switch $Calendar Case "gregorian" $m = Mod(15 + $k - $p - $q, 30) $N = Mod(4 + $k - $q, 7) Case "julian" $m = 15 $N = 6 EndSwitch $d = Mod(19 * $a + $m, 30) $e = Mod(2 * $b + 4 * $c + 6 * $d + $N, 7) $Shift = 22 + $d + $e ; could have used "21" here, saving the "-1" next line. Then it wouldn't match the Gauss Formula found elswhere in the web. $Easter = _DateAdd("D", $Shift - 1, $Year & "/03/01") ; "-1", because Gauss' Easter Rule returns the "Day-of-March", so we have to start at "-1" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Easter = ' & $Easter & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Local $aHDay[1] _ArrayAdd($aHDay, $Year & "/01/01") ; Neujahr _ArrayAdd($aHDay, $Year & "/01/06") ; Hl. 3 König #region Easter related holidays, Germany _ArrayAdd($aHDay, _DateAdd("D", -2, $Easter)) ; Karfreitag _ArrayAdd($aHDay, $Easter) ; Ostersonntag _ArrayAdd($aHDay, _DateAdd("D", 1, $Easter)) ; Ostermontag _ArrayAdd($aHDay, _DateAdd("D", 39, $Easter)) ; Christi Himmelfahrt _ArrayAdd($aHDay, _DateAdd("D", 49, $Easter)) ; Pfingstsonntag _ArrayAdd($aHDay, _DateAdd("D", 50, $Easter)) ; Pfingstmontag _ArrayAdd($aHDay, _DateAdd("D", 60, $Easter)) ; Fronleichnam #endregion Easter related holidays, Germany _ArrayAdd($aHDay, $Year & "/08/15") ; Mariä Himmelfahrt _ArrayAdd($aHDay, $Year & "/10/03") ; Tag der deutschen Einheit _ArrayAdd($aHDay, $Year & "/11/01") ; Allerheiligen _ArrayAdd($aHDay, $Year & "/12/25") ; 1. Weihnachtsfeiertag _ArrayAdd($aHDay, $Year & "/12/26") ; 2. Weihnachtsfeiertag ; add other national / regional holidays here: Reformationstag, Friedensfest, Buß & Bettag... Local $WorkingDay = True ; Retun value, in case the lines below don't detect Sat, Sun, Holiday. Local $Mon = StringMid($Date, 6, 2) Local $Day = StringRight($Date, 2) Switch _DateToDayOfWeekISO($Year, $Mon, $Day) ; 1 = Monday, 7 = Sunday Case 6 $WorkingDay = "Saturday" Case 7 $WorkingDay = "Sunday" EndSwitch For $i = 1 To UBound($aHDay) - 1 If $Date = $aHDay[$i] Then $WorkingDay = "Holiday" ExitLoop EndIf Next Return $WorkingDay #cs Osterabhängige Tage Rosenmontag: -48 Tage Faschingsdienstag: -47 Tage Karfreitag: -2 Tage Ostermontag: +1 Tag Christi Himmelfahrt: +39 Tage Pfingstsonntag: +49 Tage Pfingstmontag: +50 Tage Fronleichnam: +60 Tage #ce EndFunc ;==>CheckWorkingDay Regards, Rudi.
    1 point
  3. Hi, just for reference. you can control the streamlabs OBS client via Named Pipes like so: Local $sMessage = '{"jsonrpc": "2.0","id": 1,"method": "toggleRecording","params": {"resource": "StreamingService","args": []}}' $handle = FileOpen("\\.\pipe\slobs", 2) FileWriteLine($handle, $sMessage) FileClose($handle) the api can be found here: https://stream-labs.github.io/streamlabs-obs-api-docs/docs/index.html
    1 point
  4. We rolled out bitocker on some 4000+ laptops a couple of years ago and I wrote this vbs to list the rollout status which is displayed in xml used by the inventory package we used at the time: Const ForAppending = 8 Const SetPres = 10 const HKEY_LOCAL_MACHINE = &H80000002 const REG_SZ = 1 const REG_EXPAND_SZ = 2 const REG_BINARY = 3 const REG_DWORD = 4 const REG_MULTI_SZ = 7 Dim bIsEnabled,bIsActivated,bIsOwned,bIsOwnershipAllowed,objTPM,objLog,TakeOwnership,Enable,objEnVol,strStatusTPM,strStatusBDE,strStatusTPMState Dim objGPPT,strOwnerPassword,strPassword,objWMIBDE,nProtStatus,ProtectVar,objOSSysDriv,objSWbemServices,objOS,coloperatingsystem,sProtID,strOldOwnerPassword Dim argProtect,argRK,argEM,argSMS,argLOG,argRO,argPrompt,strCurrentUser,argValid,i,strPIN,objRemovableDrive,strStatusCode,strStatusData,MIF,strEKP,strEK Dim ActiveDirectoryBackup,ActiveDirectoryInfoToStore,RequireActiveDirectoryBackup,EncryptionMethod,BackupMandatory,strStartDate,strStartTime,strRetry,strPolicy DIM TPM_Enabled, TMP_err, Drive_St, lDriveType '~ on error resume next DIM tpmst,encst, systempart, part_details tpmst = ConnectTPMProv() encst = DriveEncryted() systempart = "" part_details = "" getsystempart systempart, part_details writeXML "C:",tpmst&encst,"",systempart,part_details WScript.sleep(1000) WScript.Quit(0) Function ConnectTPMProv() on error resume next strConnectionStr1 = "winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!root\cimv2\Security\MicrosoftTpm" TPM_Enabled = 0 Encryption_status = 0 TMP_err = 0 err.clear Set objWMITPM = GetObject(strConnectionStr1) If Err.Number <> 0 Then '~ Wscript.Echo "ERROR - Failed to connect to the MicrosoftTPM provider." TPM_Enabled = 9 Else '~ Wscript.Echo "Connection succeeded to MicrosoftTPM" ' There should either be 0 or 1 instance of the TPM provider class Set colTpm = objWMITPM.InstancesOf("Win32_Tpm") If colTpm.Count = 0 Then '~ Wscript.Echo "ERROR - Failed get a TPM instance in the provider class. Script is exiting..." Else 'Get a single instance of the TPM provider class Set objTpm = objWMITPM.Get("Win32_Tpm=@") If Err.Number <> 0 Then '~ Wscript.Echo "ERROR - Failed get a TPM instance in the provider class. Script is exiting...(Error: " & Err.Number & ")" Else TPM_Enabled = 1 '~ Wscript.Echo "Successfully retrieved a TPM instance from the Win32_TPM provider class" GetTPMStatus() 'Get the current status of the TPM to determine action '~ Wscript.Echo "bIsEnabled:" & bIsEnabled & "bIsActivated:" & bIsActivated & " bIsOwned:" & bIsOwned 'The following If statements cause the script to react differently depending on the TPM state If bIsEnabled = "True" and bIsActivated = "True" and bIsOwned = "True" Then '~ Wscript.Echo "TPM is in a ready state to enable BitLocker." TPM_Enabled = 6 ElseIf bIsEnabled = "True" and bIsActivated = "True" and bIsOwned = "False" Then '~ Wscript.Echo "TPM ownership is not taken." TPM_Enabled = 5 ElseIf bIsEnabled = "True" and bIsActivated = "False" and bIsOwned = "False" Then '~ Wscript.Echo "TPM is turned on but not activated.." TPM_Enabled = 4 ElseIf bIsEnabled = "False" And bIsActivated = "False" and bIsOwned = "False" Then '~ Wscript.Echo "TPM is not turned on.." TPM_Enabled = 3 ElseIf bIsEnabled = "False" and bIsActivated = "True" and bIsOwned = "True" Then '~ Wscript.Echo "TPM is not enabled" TPM_Enabled = 2 End If End If End If end if Err.Clear ConnectTPMProv = TPM_Enabled return 1 ' End Function function DriveEncryted() on error resume next Dim systempart, part_details,strDrive,strProtectionStatus,strVolumeId, encsts encsts = 0 ' Check whether the C: drive is encrypted ' WMI connection to Win32_EncryptableVolume, note that this will be only available on devices where BitLocker is enabled '~ Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2\Security\MicrosoftVolumeEncryption") Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!root\cimv2\Security\MicrosoftVolumeEncryption") ' If Err.Number <> 0 Then '~ Wscript.Echo "ERROR - Failed to connect to the MicrosoftVolumeEncryption provider." encsts = 9 else Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume ",,48) For Each objItem in colItems teller = teller + 1 strProtectionStatus = objItem.ProtectionStatus strDrive = objItem.DriveLetter strVolumeId = objItem.PersistentVolumeID '~ Numeric value that corresponds to the type of disk drive this logical disk represents. '~ Unknown (0) '~ No Root Directory(1) '~ Removable Disk(2) '~ Local Disk(3) '~ Network Drive(4) '~ Compact Disc (5) '~ RAM Disk (6) if GetDriveType(strDrive) = 3 then '~ Wscript.Echo "strProtectionStatus " & strProtectionStatus GetVolName(strDrive) '~ WScript.Echo "2.systempart : " & systempart '~ WScript.Echo "2.part_details: " & part_details if strProtectionStatus = "1" then encsts = 1 end if end if Next if teller = 0 then encsts = 9 end if end if DriveEncryted=encsts return End Function Function GetDriveType(DriveLetter) '~ Wscript.Echo "### Get Disk DriveType for " & DriveLetter '~ Enumerating Logical Disk Drive Properties strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colDisks = objWMIService.ExecQuery _ ("Select * from Win32_LogicalDisk") For each objDisk in colDisks if objDisk.DeviceID = DriveLetter then GetDriveType = objDisk.DriveType '~ Wscript.Echo "DeviceID: " & DriveLetter & " DriveType:" & GetDriveType Exit Function end if Next '~ Wscript.Echo "! DeviceID: " & DriveLetter& " DriveType not found." End Function Function GetVolName(DriveLetter) '~ Wscript.Echo "### Get Disk DriveType for " & DriveLetter '~ Enumerating Logical Disk Drive Properties strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colDisks = objWMIService.ExecQuery _ ("Select * from Win32_LogicalDisk") For each objDisk in colDisks if objDisk.DeviceID = DriveLetter then GetVolName = objDisk.VolumeName '~ Wscript.Echo "DeviceID: " & DriveLetter & " info:" & GetVolName Exit Function end if Next '~ Wscript.Echo "! DeviceID: " & DriveLetter& " DriveType not found." End Function Function ProtectStatus (strProtectionStatus) Select Case strProtectionStatus Case 0 ProtectStatus = "OFF" Case 1 ProtectStatus = "ON" Case 2 ProtectStatus = "Unk" End Select End Function Function GetTPMStatus() on error resume next Err.Clear nRC = objTpm.IsEnabled(bIsEnabled) If nRC <> 0 Then '~ Wscript.Echo "ERROR - The method IsEnabled failed with return code 0x" & Hex(nRC) End If Err.Clear nRC = objTpm.IsActivated(bIsActivated) If nRC <> 0 Then '~ Wscript.Echo "ERROR - The method IsActivated failed with return code 0x" & Hex(nRC) End If Err.Clear nRC = objTpm.IsOwned(bIsOwned) If nRC <> 0 Then '~ Wscript.Echo "ERROR - The method IsOwned failed with return code 0x" & Hex(nRC) End If strStatusTPMState = "TPM found in the following state: Enabled - " & bIsEnabled & ", Activated - " & bIsActivated & ", Owned - " & bIsOwned End Function Sub getsystempart(systempart,part_details) strComputer = "." systempart = 7 part_details = "" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_Volume") For Each objItem In colItems '~ WScript.Echo "Caption: " & objItem.Caption & " Label:" & objItem.Label & " Size:" & objItem.Capacity & " " & mid(objItem.Caption,2,1) part_details = part_details& "#" & objItem.Caption & "|" & objItem.Label & "|" & objItem.Capacity ' * Didn't work because some had "System" as Label '~ if objItem.Label = "System Reserved" then '~ systempart = 1 '~ end if ' if lcase(mid(objItem.Caption,2,2)) <> ":" and objItem.Capacity < 20000000000 then systempart = 1 end if Next '~ WScript.Echo "systempart : " & systempart '~ WScript.Echo "part_details: " & part_details End sub Sub writeXML(strDrive,TPM_Enabled,strVolumeId,Syspart,SyspartDet) Wscript.Echo "<SOFTWARES>" & vbCrLf & _ "<PUBLISHER>Staples Specific</PUBLISHER>" & vbCrLf & _ "<NAME>Bitlocker_Status</NAME>" & vbCrLf & _ "<VERSION>" & TPM_Enabled & "</VERSION>" & vbCrLf & _ "<FOLDER>" & strDrive & "/</FOLDER>" & vbCrLf & _ "<COMMENTS>" & SyspartDet & "</COMMENTS>" & vbCrLf & _ "<FILENAME>" & strVolumeId &"</FILENAME>" & vbCrLf & _ "<FILESIZE>" & Syspart & "</FILESIZE>" & vbCrLf & _ "<GUID />" & vbCrLf & _ "<LANGUAGE />" & vbCrLf & _ "<INSTALLDATE>2016-05-02 10:30:00</INSTALLDATE>" & vbCrLf & _ "<BITSWIDTH>0</BITSWIDTH>" & vbCrLf & _ "<SOURCE>1</SOURCE>" & vbCrLf & _ "</SOFTWARES>" End Sub ' We had no issues with performance. Jos
    1 point
  5. robertocm, I have discovered a few other cases where the UDF returns 9 when it should not. I was trying to prevent these exceptions from firing the "user selection" event, but as there are so many I am now looking to limit the event return to when the user has clicked the mouse or used the arrow keys. The real world is a bit complicated and taking up my time at the moment, but I hope to have something for you to try and break soon. M23
    1 point
  6. I see there are 2 others available for VSC .... But this one seems to be the most extensive ... https://marketplace.visualstudio.com/items?itemName=4ern.4ern I just installed it and it runs fine Keyboard Shortcuts : Run Script: F5 AutoIt Check: Ctrl+F5 Compile Script: Ctrl+F7 Build Script: F7 Run AutoIt Help: Ctrl+F1 Run Au3Info: Ctrl+F6 Debug to MsgBox: Ctrl+Shift+D Debug to Console: Alt+D Run Koda: Alt+M PS : After installing the extension don't forget to RESTART VSC. Enjoy!
    1 point
  7. Maybe you can use something like this? #include <File.au3> Func subfolders() $aFileList = _FileListToArrayRec(@ScriptDir & "\Patches\", '*;"";Finished', $FLTAR_FILES , $FLTAR_RECUR ) If IsArray($aFileList) Then For $arraynumber = 1 To $aFileList[0] - 1 FileMove(@ScriptDir & "\Patches\" & $aFileList[$arraynumber], @ScriptDir & "\Patches\") Next EndIf EndFunc ;==>subfolders subfolders()
    1 point
  8. Many parameters (dimensions) + multiple, partly conflicting constraints: use Simulated Annealing. Study the TSP example (corresponds to the distances to move pallets/boxes), then think long and hard about how to define your cost function, depending on what's relatively most important (you may have to spend some time testing and tuning this for "best" results).
    1 point
  9. A program running at a lower security level can not interact with one with a higher security level. The script would have to be running with admin rights to be able to do this. BTW, in AutoIt is the function RunAs and RunAsWait that does the same thing basically.
    1 point
  10. *.* also returns files with no extension, at least in _FileListToArray and the Windows command console.
    1 point
  11. JLogan3o13

    Auto login Live.com

    @Fink89 not the smartest thing putting your username in password in a thread for all to see. I have removed them for you this time.
    1 point
  12. 1) you are correct that _FileListToArrayRec() is indeed sufficient for your purposes. 2) "*" is a more comprehensive form, that should be preferred over "*.*", as it also returns files without extensions. 3) your original issue was the ExitLoop command in the Case Else section.
    1 point
  13. AutoBert

    Auto login Live.com

    I hope for you username and password are fake, if not i suggest to change before someone else capture your mailaccount.
    1 point
  14. Hello. Probably You can use this. with some is file in use/locked function. Saludos
    1 point
  15. Thank you so much @Danp2, it worked!!! Reference Local $sJsonElement = '{"' & $_WD_ELEMENT_ID & '":"' & $sElementId & '"}' _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().left", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().top", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().right", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().bottom", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().x", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().y", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().width", $sJsonElement) _WD_ExecuteScript($sSession, "return arguments[0].getBoundingClientRect().height", $sJsonElement)
    1 point
  16. Hello @BigDaddyO You can trigger the mouseover event using javascript. Local $sJsonElement = '{"element-6066-11e4-a52e-4f735466cecf":"' & $eHoverItem & '"}' Local $sResponse = _WD_ExecuteScript($sSession, "$('p').mouseover(); return true;", $sJsonElement) Saludos Saludos
    1 point
  17. Hello. It's Code work correcly for me. anyway here is a mod. let me know if it works for you. Opt("MustDeclareVars", 1) ; *** SEMINKO ADDED THIS ****** HotKeySet("{F9}", "Mute") ; ***************************** Global Enum $eRender, $eCapture, $eAll, $EDataFlow_enum_count Global Enum $eConsole, $eMultimedia, $eCommunications, $ERole_enum_count Global Const $CLSCTX_INPROC_SERVER = 1 Global Const $E_NOTFOUND = 0x80070490 Global Const $S_OK = 0 Global Const $CLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}" Global Const $IID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}" Global Const $tagIMMDeviceEnumerator = _ "EnumAudioEndpoints hresult(int;dword;ptr*);" & _ "GetDefaultAudioEndpoint hresult(int;int;ptr*);" & _ "GetDevice hresult(wstr;ptr*);" & _ "RegisterEndpointNotificationCallback hresult(ptr);" & _ "UnregisterEndpointNotificationCallback hresult(ptr)" Global Const $IID_IMMDevice = "{D666063F-1587-4E43-81F1-B948E807363F}" Global Const $tagIMMDevice = _ "Activate hresult(struct*;dword;ptr;ptr*);" & _ "OpenPropertyStore hresult(dword;ptr*);" & _ "GetId hresult(wstr*);" & _ "GetState hresult(dword*)" Global Const $IID_IDeviceTopology = "{2A07407E-6497-4A18-9787-32F79BD0D98F}" Global Const $tagIDeviceTopology = "GetConnectorCount hresult(int*);GetConnector hresult(int;ptr*);" & _ "GetSubunitCount hresult(int*);GetSubunit hresult(int;ptr*);GetPartById hresult(int,ptr*);GetDeviceId hresult(ptr*);GetSignalPath hresult(ptr;ptr;bool;ptr*)" Global Const $IID_IConnector = "{9c2c4058-23f5-41de-877a-df3af236a09e}" Global Const $tagIConnector = "GetType hresult(ptr*);GetDataFlow hresult(ptr*);ConnectTo hresult(ptr);Disconnect hresult(none);IsConnected hresult(int*);" & _ "GetConnectedTo hresult(ptr*);GetConnectorIdConnectedTo hresult(wstr*);GetDeviceIdConnectedTo hresult(wstr*)" Global Const $IID_IPart = "{AE2DE0E4-5BCA-4F2D-AA46-5D13F8FDB3A9}" Global Const $tagIPart = "GetName hresult(wstr*);GetLocalId hresult(uint*);GetGlobalId hresult(wstr*);GetPartType hresult(ptr);GetSubType hresult(ptr);" & _ "GetControlInterfaceCount hresult(uint*);GetControlInterface hresult(int;ptr*);EnumPartsIncoming hresult(ptr*);EnumPartsOutgoing hresult(ptr*);" & _ "GetTopologyObject hresult(ptr*);Activate hresult(dword;struct*;ptr*);RegisterControlChangeCallback hresult(ptr);UnregisterControlChangeCallback hresult(ptr)" Global Const $IID_IPartsList = "{6DAA848C-5EB0-45CC-AEA5-998A2CDA1FFB}" Global Const $tagIPartsList = "GetCount hresult(uint*);GetPart hreuslt(uint;ptr*)" Global Const $IID_IAudioMute = "{DF45AEEA-B74A-4B6B-AFAD-2366B6AA012E}" Global Const $tagIAudioMute = "SetMute hresult(bool;ptr);GetMute hresult(int*)" ; *** SEMINKO ADDED THIS ****** While 1 Sleep(250) WEnd ; ***************************** Func MUTE() Local $hr = -1 Local $oMMDeviceEnumerator = ObjCreateInterface($CLSID_MMDeviceEnumerator, $IID_IMMDeviceEnumerator, $tagIMMDeviceEnumerator) If @error Then ConsoleWrite("!Error Creating IMMDeviceEnumerator Interface" & @CRLF) Exit EndIf Local $pDevice = 0 $hr = $oMMDeviceEnumerator.GetDefaultAudioEndpoint($eRender, $eConsole, $pDevice) If FAILED($hr) Then ConsoleWrite("!Error Getting Default Render Endpoint Device" & @CRLF) $oMMDeviceEnumerator = 0 Exit EndIf Local $oMMDevice = ObjCreateInterface($pDevice, $IID_IMMDevice, $tagIMMDevice) If @error Then ConsoleWrite("!Error Creating IMMDevice Interface" & @CRLF) $oMMDeviceEnumerator = 0 Exit EndIf Local $pDeviceTopology = 0 $hr = $oMMDevice.Activate(__uuidof($IID_IDeviceTopology), $CLSCTX_INPROC_SERVER, 0, $pDeviceTopology) If FAILED($hr) Then ConsoleWrite("!Error Getting Device Topology" & @CRLF) $oMMDeviceEnumerator = 0 $oMMDevice = 0 Exit EndIf Local $oDeviceTopology = ObjCreateInterface($pDeviceTopology, $IID_IDeviceTopology, $tagIDeviceTopology) If @error Then ConsoleWrite("!Error Creating IDeviceTopology Interface" & @CRLF) $oMMDeviceEnumerator = 0 $oMMDevice = 0 Exit EndIf Local $pConnEndpoint = 0 $hr = $oDeviceTopology.GetConnector(0, $pConnEndpoint) If FAILED($hr) Then ConsoleWrite("!Error Getting endpoint Connector" & @CRLF) $oMMDeviceEnumerator = 0 $oMMDevice = 0 $oDeviceTopology = 0 Exit EndIf Local $oIConnector = ObjCreateInterface($pConnEndpoint, $IID_IConnector, $tagIConnector) If @error Then ConsoleWrite("!Error Creating IConnector Interface" & @CRLF) $oMMDeviceEnumerator = 0 $oMMDevice = 0 $oDeviceTopology = 0 Exit EndIf Local $pConnDevice = 0 $hr = $oIConnector.GetConnectedTo($pConnDevice) If FAILED($hr) Then ConsoleWrite("!Error GetConnectedTo Device" & @CRLF) $oMMDeviceEnumerator = 0 $oMMDevice = 0 $oDeviceTopology = 0 Exit EndIf Local $oConnDevice = ObjCreateInterface($pConnDevice, $IID_IConnector, $tagIConnector) If @error Then ConsoleWrite("!Error Creation oConnDevice(IConnector) Interface" & @CRLF) $oMMDeviceEnumerator = 0 $oMMDevice = 0 $oDeviceTopology = 0 Exit EndIf Local $pPart = 0 $hr = $oConnDevice.QueryInterface($IID_IPart, $pPart) If FAILED($hr) Then ConsoleWrite("!Error Getting Part" & @CRLF) $oMMDeviceEnumerator = 0 $oMMDevice = 0 $oDeviceTopology = 0 $oConnDevice = 0 Exit EndIf Local $oIPart = ObjCreateInterface($pPart, $IID_IPart, $tagIPart) If @error Then ConsoleWrite("!Error Creating IPart Interface" & @CRLF) $oMMDeviceEnumerator = 0 $oMMDevice = 0 $oDeviceTopology = 0 Exit EndIf ConsoleWrite(">>>>>>>>>>>>>>>>>BEGIN<<<<<<<<<<<<<<<<<<<<" & @CRLF) GetPart($oIPart) $oIPart = 0 EndFunc ;==>MUTE Func GetPart(ByRef $oIPart) Local Static $bNextIsMute = False Local $sPartName = "" Local $PartLocalId = "" Local $hr = -1 ConsoleWrite("+Part" & @CRLF) $hr = $oIPart.GetName($sPartName) If FAILED($hr) Then ConsoleWrite("Not Part Name" & @CRLF) Return $hr EndIf $oIPart.GetLocalId($PartLocalId) If FAILED($hr) Then ConsoleWrite("Not Part ID" & @CRLF) Return $hr EndIf ConsoleWrite(">" & $sPartName) ConsoleWrite(" ID: " & $PartLocalId & @CRLF) If $bNextIsMute=False Then $bNextIsMute = StringInStr($sPartName, 'Front Pink In') ? True : False EndIf If $bNextIsMute Then Local $pIAudioMute = 0 Local $bMute = 0 Local $oIAudioMute = 0 $hr = $oIPart.Activate($CLSCTX_INPROC_SERVER, __uuidof($IID_IAudioMute), $pIAudioMute) If SUCCEEDED($hr) Then $bNextIsMute = False $oIAudioMute = ObjCreateInterface($pIAudioMute, $IID_IAudioMute, $tagIAudioMute) If @error Then ConsoleWrite("!Error Creating IAudioMute Interface") EndIf $hr = $oIAudioMute.GetMute($bMute) If FAILED($hr) Then ConsoleWrite("!Error Getting Mute State" & @CRLF) EndIf $hr = $oIAudioMute.SetMute(Not ($bMute), Null) If SUCCEEDED($hr) Then ConsoleWrite("!MUTE: " & (($bMute = False) ? "ON!" : "OFF!") & @CRLF) TrayTip("!MUTE: " & (($bMute = False) ? "ON!" : "OFF!"), "Danyfirex", 2, 1) Sleep(2000) EndIf EndIf EndIf Local $pIncomingParts = 0 $hr = $oIPart.EnumPartsIncoming($pIncomingParts) If ($hr = $E_NOTFOUND) Then ConsoleWrite("Not incoming Parts in Part" & @CRLF) Return $S_OK EndIf If FAILED($hr) Then ConsoleWrite("!ERROR Enumerating incoming Parts" & @CRLF) Return $hr EndIf Local $oIPartsList = ObjCreateInterface($pIncomingParts, $IID_IPartsList, $tagIPartsList) If @error Then ConsoleWrite("!Error Creating IPartsList Interface") EndIf Local $iNParts = 0 $oIPartsList.GetCount($iNParts) If FAILED($hr) Then ConsoleWrite("Couldn't get count of incoming parts") Return $hr EndIf Local $pIncomingPart = 0 Local $oIPart2 = 0 For $i = $iNParts - 1 To 0 Step -1 $hr = $oIPartsList.GetPart($i, $pIncomingPart) If (FAILED($hr)) Then ConsoleWrite("Not Got Part" & @CRLF) $oIPartsList = 0 Return $hr EndIf Local $oIPart2 = ObjCreateInterface($pIncomingPart, $IID_IPart, $tagIPart) If @error Then ConsoleWrite("!Error Creating IPartsList(2) Interface") $oIPartsList = 0 Return $hr EndIf $hr = GetPart($oIPart2) If FAILED($hr) Then $oIPartsList = 0 $oIPart2 = 0 Return $hr EndIf Next $oIPart2 = 0 Return $S_OK EndFunc ;==>GetPart Func __uuidof($sGUID) Local $tGUID = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]") DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sGUID, "struct*", $tGUID) If @error Then Return SetError(@error, @extended, 0) Return $tGUID EndFunc ;==>__uuidof Func SUCCEEDED($hr) Return ($hr >= 0) EndFunc ;==>SUCCEEDED Func FAILED($hr) Return ($hr < 0) EndFunc ;==>FAILED Saludos
    1 point
  18. I can't see well at this distance! Can you post a link?
    1 point
  19. @PoojaKrishna There are lots of examples on the web for doing this. Here's one such example, which you should be able to translate into a series of _WD_ExecuteScript calls.
    1 point
  20. You can use _DateToDayOfWeek #include<date.au3> #include<array.au3> $Year = 2016 $month = 4 $DaysInMonth = _DateDaysInMonth($Year, $month) ;how many days the current month has MsgBox(0, $DaysInMonth, "") $LastDayInMonth = _DateToDayOfWeek($Year, $month, $DaysInMonth) ;last day in the month (date format) Dim $LastNamedDays[7][2] ;array of [dates][last Weekday in month] For $i = 0 To 6 $LastNamedDays[$i][0] = $Year & "/" & $month & "/" & _DateDaysInMonth($Year, $month) - $i $LastNamedDays[$i][1] = "Last " & _DateDayOfWeek(_DateToDayOfWeek($Year, $month, $DaysInMonth - $i)) Next _ArrayDisplay($LastNamedDays)
    1 point
  21. Credits go to the authors of AutoIt Unlocker! #NoTrayIcon #include "WinAPIEx.au3" #include <WinAPI.au3> Dim $hTimer = TimerInit() Dim $aFiles = _ProcessListFiles("firefox.exe") ; Get a list of files currently opened by the process ConsoleWrite("+>Took " & Round(TimerDiff($hTimer)) & " milliseconds" & @CRLF) #include <Array.au3> _ArrayDisplay($aFiles) Exit Func _ProcessListFiles($vProcess, $nMaxFiles = 1000) Static Local $aPrivilege = DllCall("ntdll.dll", "int", "RtlAdjustPrivilege", "int", 20, "int", 1, "int", 0, "int*", 0) Local $nProcessId = ProcessExists($vProcess), $aRet Static Local $hCurrentProcess = _WinAPI_GetCurrentProcess() Local $aHandles = _WinAPI_EnumProcessHandles($nProcessId) Local $hObject, $aFiles[$nMaxFiles+1], $sPath Local $hProcess = _WinAPI_OpenProcess(0x0040, 0, $nProcessId, True) For $i = 1 To $aHandles[0][0] Step 1 If $aHandles[$i][3] = 0x00120189 Or $aHandles[$i][3] = 0x0012019f Or $aHandles[$i][3] = 0x00100000 Then ContinueLoop $hObject = _WinAPI_DuplicateHandle($hProcess, $aHandles[$i][0], $hCurrentProcess, 0, False, $DUPLICATE_SAME_ACCESS) If Not $hObject Then ContinueLoop If __IsFileObject($hObject) Then $sPath = __FileObjectPath($hObject) _WinAPI_CloseHandle($hObject) If FileExists($sPath) Then For $n = 1 To $aFiles[0] If $aFiles[$n] = $sPath Then $sPath = 0 ExitLoop EndIf Next If $sPath Then $aFiles[0] += 1 $aFiles[$aFiles[0]] = $sPath If $aFiles[0] >= $nMaxFiles Then ExitLoop EndIf EndIf EndIf Next ReDim $aFiles[$aFiles[0]+1] Return $aFiles EndFunc Func __IsFileObject(ByRef $hObject) Static Local $tPOTI = DllStructCreate('ushort;ushort;ptr;byte[128]'), $pData, $Length, $tString Local $aRet = DllCall("ntdll.dll", 'uint', 'NtQueryObject', 'ptr', $hObject, 'uint', 2, 'ptr', DllStructGetPtr($tPOTI), 'ulong', DllStructGetSize($tPOTI), 'ptr', 0) If @error Or $aRet[0] Then Return $pData = DllStructGetData($tPOTI, 3) If Not $pData Then Return $Length = DllCall("kernel32.dll", 'int', 'lstrlenW', 'ptr', $pData) If @error Or Not $Length[0] Then Return $Length = $Length[0] $tString = DllStructCreate('wchar[' & ($Length + 1) & ']', $pData) If @error Then Return Return (DllStructGetData($tString, 1) == "File") EndFunc Func __FileObjectPath($hObject) Static Local $tStruct = DllStructCreate("char[255];") Local $aDrive = DriveGetDrive("ALL"), $sPath Local $aDrivesInfo[UBound($aDrive) - 1][2] For $I = 0 To UBound($aDrivesInfo) - 1 $aDrivesInfo[$I][0] = $aDrive[$I + 1] DllCall("kernel32.dll", "dword", "QueryDosDevice", "str", $aDrivesInfo[$I][0], "ptr", DllStructGetPtr($tStruct), "dword", 255) $aDrivesInfo[$I][1] = DllStructGetData($tStruct, 1) Next Local Static $tPOTI = DllStructCreate("ushort Length;ushort MaximumLength;ptr Buffer;wchar Reserved[260];"), $sDeviceStr, $vSolid = False DllCall("ntdll.dll", "ulong", "NtQueryObject", "ptr", $hObject, "int", 1, "ptr", DllStructGetPtr($tPOTI), "ulong", DllStructGetSize($tPOTI), "ulong*", "") $sDeviceStr = DllStructGetData(DllStructCreate("wchar[" & Ceiling(DllStructGetData($tPOTI, "Length") / 2) & "];", DllStructGetData($tPOTI, "buffer")), 1) For $y = 0 To UBound($aDrivesInfo) - 1 If StringLeft($sDeviceStr, StringLen($aDrivesInfo[$y][1])) = $aDrivesInfo[$y][1] Then $sPath = StringUpper($aDrivesInfo[$y][0]) & StringTrimLeft($sDeviceStr, StringLen($aDrivesInfo[$y][1])) EndIf Next Return $sPath EndFunc Anonymous
    1 point
  22. BugFix

    Is date an holiday?

    I've made an function to check if given date is an holiday. Because different countries have different holidays i've used the most known holidays for check. You can use also other defined dates inside function if needed. Or you add own holidays. You can give the date as (year, mon, day) or as ("YYYY/MM/DD") and let mon and day free. #include-once #include <Date.au3> ;=============================================================================== ; Function Name: _IsHoliday($iYear, $iMon=-1, $iDay=-1) ; Description:: Checks if given date is an holiday ; Parameter(s): $iYear year of date (as from 1900) OR ; entire date as string "YYYY/MM/DD" ; $iMon month of date (if $iYear not entire date) ; $iDay day of date (if $iYear not entire date) ; Requirement(s): #include <Date.au3> ; Return Value(s): Success ; is Holiday - name of holiday ; isn't Holiday - blank string ; Failure ; 0 @error=1 - date isn't valid ; Note: you can insert own days as holiday ; Author(s): BugFix (bugfix@autoit.de) ;=============================================================================== Func _IsHoliday($iYear, $iMon=-1, $iDay=-1) Local $aDate = StringRegExp($iYear, '(\d{4})/(\d{1,2})/(\d{1,2})', 3) If Not @error Then $iYear = $aDate[0] $iMon = $aDate[1] $iDay = $aDate[2] EndIf If $iYear < 1900 Or $iMon < 1 Or $iMon > 12 Or $iDay < 1 Or $iDay > 31 Then Return SetError(1,0,0) $iMon = StringRight('0' & $iMon, 2) $iDay = StringRight('0' & $iDay, 2) If Not _DateIsValid($iYear & '/' & $iMon & '/' & $iDay) Then Return SetError(1,0,0) Local $oHoliday = ObjCreate('Scripting.Dictionary') Local $HDays[32][2], $a, $b, $c, $d, $e, $H1, $H2, $N, $M Local $Easter, $EasterDate, $EasterDay, $EasterMonth, $PfSoDat ; fix days $oHoliday.Add($iYear & "/01/01", "New Year's Day") $oHoliday.Add($iYear & "/05/01", "May Day") $oHoliday.Add($iYear & "/12/25", "Christmas Day") $oHoliday.Add($iYear & "/12/26", "Boxing Day") ; variable days $a = Mod($iYear, 19) $b = Mod($iYear, 4) $c = Mod($iYear, 7) $H1 = Int($iYear / 100) $H2 = Int($iYear / 400) $N = 4 + $H1 - $H2 $M = 15 + $H1 - $H2 - Floor (Int((8 * $H1 + 13) / 25)) $d = Mod((19 * $a + $M), 30) $e = Mod((2 * $b + 4 * $c + 6 * $d + $N), 7) If $d + $e = 35 Then $Easter = 50 Else If $d = 28 And $e = 6 And $a > 10 Then $Easter = 49 Else $Easter = 22 + $d + $e EndIf EndIf If $Easter < 32 Then $EasterDay = $Easter $EasterMonth = "03" Else $EasterDay = $Easter - 31 $EasterMonth = "04" EndIf If $EasterDay < 10 Then $EasterDay = "0" & $EasterDay EndIf $EasterDate = $iYear & "/" & $EasterMonth & "/" & $EasterDay $oHoliday.Add(_DateAdd( 'd', -2, $EasterDate) , "Good Friday") $oHoliday.Add($EasterDate , "Easter Sunday") $oHoliday.Add(_DateAdd( 'd', 1, $EasterDate) , "Easter Monday") $oHoliday.Add(_DateAdd( 'd', 39, $EasterDate) , "Ascension Thursday") $oHoliday.Add(_DateAdd( 'd', 49, $EasterDate) , "Whitsunday") $PfSoDat = _DateAdd( 'd', 50, $EasterDate) $oHoliday.Add($PfSoDat, "Whit Monday") #region - other days that may be an holiday, activate if needed #cs Local $MutterDat, $4AdvDat ; Mother's Day = 2. Sunday of May BUT if Whit = 2. Sunday of May than Mother's Day at 1. Sunday ; 2. Sunday only between 8. and 14.5. For $maitag = 8 To 14 If _DateToDayOfWeek($iYear, 5, $maitag) = 1 Then If $maitag < 10 Then $maitag = "0" & $maitag EndIf $MutterDat = $iYear & "/05/" & $maitag If $MutterDat = $PfSoDat Then $MutterDat = _DateAdd( 'd', -7, $iYear & "/05/" & $maitag) EndIf ExitLoop EndIf Next $oHoliday.Add($MutterDat, "Mother's Day") ; Thanksgiving 1. Sunday of October (between 1. and 7.10.) For $oktobertag = 1 To 7 If _DateToDayOfWeek($iYear, 10, $oktobertag) = 1 Then $oktobertag = "0" & $oktobertag $oHoliday.Add($iYear & "/10/" & $oktobertag, "Thanksgiving") ExitLoop EndIf Next ; 4.advent = Sunday before 25.12. (between 18. and 24.12.) For $deztag = 18 To 24 If _DateToDayOfWeek($iYear, 12, $deztag) = 1 Then $4AdvDat = $iYear & "/12/" & $deztag $oHoliday.Add(_DateAdd( 'd', -7, $4AdvDat), "3. Advent") $oHoliday.Add(_DateAdd( 'd', -14, $4AdvDat), "2. Advent") $oHoliday.Add(_DateAdd( 'd', -21, $4AdvDat), "1. Advent") $oHoliday.Add(_DateAdd( 'd', -28, $4AdvDat), "Sunday before Advent on which the dead are commemorated") $oHoliday.Add(_DateAdd( 'd', -32, $4AdvDat), "Day of Prayer and Repentance") ExitLoop EndIf Next $oHoliday.Add(_DateAdd( 'd', -48, $EasterDate), "Monday before Lent") $oHoliday.Add(_DateAdd( 'd', -47, $EasterDate), "Shrove Tuesday") $oHoliday.Add(_DateAdd( 'd', -46, $EasterDate), "ash wednesday") $oHoliday.Add(_DateAdd( 'd', -3, $EasterDate), "Holy Thursday") $oHoliday.Add(_DateAdd( 'd', 60, $EasterDate), "Corpus Christi") $oHoliday.Add($iYear & "/01/06", "Epiphany") $oHoliday.Add($iYear & "/02/14", "Valentine's Day") $oHoliday.Add($iYear & "/10/31", "Reformation Day") $oHoliday.Add($iYear & "/11/01", "All Saints' Day") $oHoliday.Add($iYear & "/12/24", "Christmas Eve") $oHoliday.Add($iYear & "/12/31", "New Year's Eve") $oHoliday.Add($4AdvDat, "4. Advent") ; ######### Here you can insert own holidays ####################### ; $oHoliday.Add('YYYY/MM/DD', 'Name of holiday') <== SAMPLE ; ################################################################## #ce #endregion If $oHoliday.Exists($iYear & '/' & $iMon & '/' & $iDay) Then Return $oHoliday.Item($iYear & '/' & $iMon & '/' & $iDay) Else Return '' EndIf EndFunc ;==>_IsHoliday_IsHoliday.au3
    1 point
×
×
  • Create New...