Jump to content

nend

Active Members
  • Posts

    415
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by nend

  1. Tested it and all works ok (like all your scripts😀) On Windows 11 64Bit Thanks for the script
  2. Is there anybody else how knows how to discover mDNS devices in local network and get there TXT records? The delivered examples from 20ice18 doesn't work, I'm just stuck.
  3. You can try this UDF for sending mail to a 365 server. https://www.autoitscript.com/forum/topic/203411-mail-udf/#comment-1469732
  4. Thanks for the help but..... it needs a UDF which I can't find anywhere "UDPOs.au3". Can you show me where I can download it? I also get a error "StringToNumber" undefined function, is that the same as "Number"? Error "_ArrayCreate" undefined function. If I replace the "StringToNumber" to "Number" it won't work. Did this script works on your PC?
  5. How can I scan a network for mDSN devices and see there TXT records. A while a go I stript down the DIG udf to make it a mDNS discovery device, see the example. I search the internet over 5 hours but there is little information how this works. Is there someone how knows how to scan the network for the devices (shows all the mDNS devices) and get there TXT records? $mdsn_return = _mDNS("http://xxxxxxx.local") ConsoleWrite($mdsn_return & @CRLF) Func _mDNS($domain) Local $return_ip, $domain_convert, $mDNS_msg $domain = StringReplace($domain , "http://", "") Local $domain_array = StringSplit($domain, ".") For $i = 1 To $domain_array[0] $domain_convert = $domain_convert & Hex(BinaryLen($domain_array[$i]), 2) & StringTrimLeft(StringToBinary($domain_array[$i]), 2) Next UDPStartup() Local $mDNS_sock = UDPOpen("224.0.0.251", 5353) If @error Then UDPShutdown() SetError(1) Return "" EndIf Local $query_time = TimerInit() UDPSend($mDNS_sock, "0x5A8901000001000000000000" & $domain_convert & "0000010001") Do $mDNS_msg = UDPRecv($mDNS_sock, 512, 1) Until $mDNS_msg <> "" Or TimerDiff($query_time) > 1000 UDPShutdown() For $i = 3 To 0 Step -1 $return_ip = $return_ip & Dec(StringMid(BinaryMid($mDNS_msg, BinaryLen($mDNS_msg) - $i, 1), 3)) If $i <> 0 Then $return_ip = $return_ip & "." EndIf Next If $return_ip <> "0.0.0.0" Then Return $return_ip Else SetError(2) EndIf EndFunc
  6. You can use a barcode font, ik works great in AutoIt https://fonts2u.com/free-3-of-9-regular.font
  7. Hmm, totaly overlooked that. Thanks @TheXman and @Jos for helping
  8. No not always, this is also a example (005*A). So if there is a decimal point and there is a other number before the decimal point then zero then capture and else strip al leading zero's (000.96*A) = 0.96 (001.96*A) = 1.96 (005*A) = 5 The amount of leading zero's can be different.
  9. Allmost, this will output .96 but I need 0.96, do you know a sollution for this?
  10. I need your Regex skils. I need a number out of this, if the number is above the 1 then it works, but if it is below the 1 examle 0.96 it shows 96. How can I fix this? #include <StringConstants.au3> Local $teststring1 = "(000.96*A)"; has to be 0.96 Local $teststring2 = "(001.96*A)"; has to be 1.96 Local $array = StringRegExp($teststring1, "\(0*\.*(.*)\*", $STR_REGEXPARRAYGLOBALMATCH, 1) ConsoleWrite($array[0] & @CRLF)
  11. This one works perfect, thanks @Gianni and @argumentum for your help.
  12. Thanks for helping me, but.... I still get the wrong checksum (>>>18C0 = !F7F2) I think I'm doing something wrong but can't find out what.
  13. In Holland almost every house holding has the same smart energy meter and this meter send out a "Telegram" data message which you can read and do what ever you want with it. Now I want to check the CRC16 if the data is correct arrived. I found a few scripts and try to check the CRC but the code is a bit difficult for me, is there some how can point me the right way, I found this CRC16 checksum on the forum and try to modify it #include <String.au3> $data = FileRead(@ScriptDir & "\Tel.txt") $data = _StringBetween($data, "", "!") ;ConsoleWrite($data[0]) ConsoleWrite(_Crc16($data[0]) & @CRLF) ; ======================================================= ; Function _Crc16 ; Purpose: Return the crc16 checksum of the input value ; Author: 'roby' at http://www.autoitscript.com/forum ; ======================================================= Func _Crc16($value) $value = Binary($value) Local $crc = 0xFFFF Local $table[256] = [ _ 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, _ 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, _ 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, _ 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, _ 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, _ 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41, _ 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, _ 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040, _ 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, _ 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441, _ 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, _ 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, _ 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, _ 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40, _ 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, _ 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041, _ 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, _ 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441, _ 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, _ 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840, _ 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, _ 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, _ 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, _ 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041, _ 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, _ 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440, _ 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, _ 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841, _ 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, _ 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, _ 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, _ 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040 ] For $i = 1 To BinaryLen($value) $crc = BitXOR(BitShift($crc, 8), $table[BitAND(BitXOR($crc, BinaryMid($value, $i, 1)), 0xFF)]) Next Return Hex($crc, 4) EndFunc ;==>_Crc16 This is the data where F7F2 is the checksum, every thing between the first character and ! character has to be calculated /KFM5KAIFA-METER 1-3:0.2.8(42) 0-0:1.0.0(180605091333S) 0-0:96.1.1(4530303236303030303133343837363135) 1-0:1.8.1(001790.476*kWh) 1-0:1.8.2(002320.188*kWh) 1-0:2.8.1(000000.000*kWh) 1-0:2.8.2(000000.000*kWh) 0-0:96.14.0(0002) 1-0:1.7.0(00.258*kW) 1-0:2.7.0(00.000*kW) 0-0:96.7.21(00010) 0-0:96.7.9(00004) 1-0:99.97.0(1)(0-0:96.7.19)(000101000011W)(2147483647*s) 1-0:32.32.0(00000) 1-0:52.32.0(00000) 1-0:72.32.0(00000) 1-0:32.36.0(00000) 1-0:52.36.0(00000) 1-0:72.36.0(00000) 0-0:96.13.1() 0-0:96.13.0() 1-0:31.7.0(000*A) 1-0:51.7.0(000*A) 1-0:71.7.0(000*A) 1-0:21.7.0(00.125*kW) 1-0:22.7.0(00.000*kW) 1-0:41.7.0(00.124*kW) 1-0:42.7.0(00.000*kW) 1-0:61.7.0(00.009*kW) 1-0:62.7.0(00.000*kW) 0-1:24.1.0(003) 0-1:96.1.0(4730303235303033333436333738353136) 0-1:24.2.1(180605090000S)(05225.708*m3) !F7F2 I found a website where it's made in Java https://github.com/jeroen13/p1-smart-meter-crc16/blob/main/p1-smart-meter-crc16.js And I found this information CRC is a CRC16 value calculated over the preceding characters in the data message (from ‘/’ to ‘!’ using polynomial x 16 + x15 + x2 + 1). The value is represented as 4 hexadecimal characters. MSB first. Can somebody help me with this? Tel.txt CRC16.au3
  14. This is the latest version I made. You can change the Font type but you have to change a lot of calculations to make sure everything is on the right spot. #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> #include <TrayConstants.au3> #include <Misc.au3> Opt("TrayMenuMode", 3) Global $program_name = "Spotibar" Global $program_version = "0.2" Global $hGraphic_object_controls, $Hbitmap_controls, $nowplaying Global $strip_extra, $tray_toolTip, $Gui_notification, $a_text_size[2] $list = ProcessList(@ScriptName) If $list[0][0] > 1 Then Exit EndIf _GDIPlus_Startup() TraySetToolTip($program_name & " V" & $program_version) Local $tray_config_menu = TrayCreateMenu("Config") Local $tray_config_colour = TrayCreateItem("Text colour", $tray_config_menu) Local $tray_config_strip = TrayCreateItem("Strip extra information", $tray_config_menu) Local $tray_screensaver = TrayCreateItem("Keep screen always on", $tray_config_menu) Local $tray_config_autostart = TrayCreateItem("Auto start with Windows", $tray_config_menu) TrayCreateItem("") Local $tray_exit = TrayCreateItem("Exit") If RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip") = "" Or RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip") = "1" Then TrayItemSetState($tray_config_strip, $TRAY_CHECKED) $strip_extra = True Else TrayItemSetState($tray_config_strip, $TRAY_UNCHECKED) $strip_extra = False EndIf If RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Screen lock") = "1" Then TrayItemSetState($tray_screensaver, $TRAY_CHECKED) DllCall('kernel32.dll', 'long', 'SetThreadExecutionState', 'long', BitOR(0x80000000, 0x00000002, 0x00000001)) ; stops screensaver timer EndIf If RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour") = "" Then Global $text_colour = "0xFF009B00" Else Global $text_colour = "0xFF" & StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour"), 6) EndIf RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar") If Not @error Then TrayItemSetState($tray_config_autostart, $GUI_CHECKED) EndIf OnAutoItExitRegister("_Exit_SP") Local $tmr_loop Local $h_win_infobar = _Infobar_start() While 1 Local $tray = TrayGetMsg() Switch $tray Case $tray_config_strip If BitAND(TrayItemGetState($tray_config_strip), $TRAY_UNCHECKED) Then TrayItemSetState($tray_config_strip, $TRAY_CHECKED) RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip", "REG_SZ", 1) $strip_extra = True Else TrayItemSetState($tray_config_strip, $TRAY_UNCHECKED) RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip", "REG_SZ", 0) $strip_extra = False EndIf Case $tray_config_colour TrayItemSetState($tray_config_colour, $TRAY_CHECKED) Local $colourinfo = RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour") If $colourinfo = "" Then $colourinfo = "0x009B00" EndIf $colourinfo = _ChooseColor(2, $colourinfo, 2) If Not (@error) Then If $colourinfo > "" Then RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour", "REG_SZ", $colourinfo) $text_colour = "0xFF" & StringRight($colourinfo, 6) _Infobar_set_text($h_win_infobar) EndIf EndIf TrayItemSetState($tray_config_colour, $TRAY_UNCHECKED) Case $tray_config_autostart If BitAND(TrayItemGetState($tray_config_autostart), $TRAY_UNCHECKED) Then RegDelete("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar") RegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar", "REG_SZ", '"' & @ScriptDir & '\Spotibar.exe"') TrayItemSetState($tray_config_autostart, $TRAY_CHECKED) Else RegDelete("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar") TrayItemSetState($tray_config_autostart, $TRAY_UNCHECKED) EndIf Case $tray_screensaver If BitAND(TrayItemGetState($tray_screensaver), $TRAY_UNCHECKED) Then RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Screen lock", "REG_SZ", 1) DllCall('kernel32.dll', 'long', 'SetThreadExecutionState', 'long', BitOR(0x80000000, 0x00000002, 0x00000001)) ; stops screensaver timer TrayItemSetState($tray_screensaver, $TRAY_CHECKED) Else RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Screen lock", "REG_SZ", 0) DllCall('kernel32.dll', 'long', 'SetThreadExecutionState', 'long', 0x80000000) ; start screensaver timer TrayItemSetState($tray_screensaver, $TRAY_UNCHECKED) EndIf Case $tray_exit _Exit_SP() EndSwitch If TimerDiff($tmr_loop) > 1000 Then _TMR_get_title() $tmr_loop = TimerInit() EndIf Sleep(10) WEnd Func _TMR_get_title() Local Static $nowplaying_old $nowplaying = _Get_NowPlaying() If $nowplaying = "0" Then $nowplaying = "" EndIf $nowplaying = StringReplace($nowplaying, "/", Chr ( 47 )) If $strip_extra Then $nowplaying = StringRegExpReplace($nowplaying, ":(.*)", "", 0); strips everything after : $nowplaying = StringRegExpReplace($nowplaying, "\([^)]*\)|\[[^)]*\]", "", 0); strip everything between ( ) and [ ] $nowplaying = StringStripWS($nowplaying, 3); strip leading and trealing whitespace Local $array_strip = StringRegExp($nowplaying, "(.*?\s-\s.*?)\s-\s.*", $STR_REGEXPARRAYGLOBALMATCH, 1); strip everything after the second dash character If Not @error Then $nowplaying = $array_strip[0] EndIf EndIf If $nowplaying <> $nowplaying_old Then $tray_toolTip = $nowplaying TraySetToolTip($program_name & " V" & $program_version & @CRLF & @CRLF & $nowplaying) _Infobar_set_text($h_win_infobar) $nowplaying_old = $nowplaying EndIf _Infobar_Calc_Position($h_win_infobar) EndFunc Func _Get_NowPlaying() Local $aWinLis For $i = 0 To 15 $aWinList = WinList("[Class:Chrome_WidgetWin_0; INSTANCE:" & $i & "]") If UBound($aWinList) > 1 Then If $aWinList[1][0] > "" Then Return $aWinList[1][0] ExitLoop EndIf EndIf Next EndFunc #Region Infobar Func _Infobar_start() $Hbitmap_controls = _GDIPlus_BitmapCreateFromScan0(800, 25) $hGraphic_object_controls = _GDIPlus_ImageGetGraphicsContext($Hbitmap_controls) Local $fullscreencontrolgui = GUICreate("", 0, 0, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW)) _SetBitmap($fullscreencontrolgui, $Hbitmap_controls, 255, 1000, 25) GUISetState(@SW_SHOW, $fullscreencontrolgui) WinSetOnTop($fullscreencontrolgui, "", 1) Return $fullscreencontrolgui EndFunc Func _Infobar_set_text($h_win, $fade = True) Local Static $pos_array[2] If NOT _Infobar_visible() Then $nowplaying = "" EndIf If $fade Then For $i = 255 To 0 Step -15 _SetBitmap($h_win, $Hbitmap_controls, $i, $pos_array[0] + 10, $pos_array[1]) Sleep(7) Next EndIf _GDIPlus_GraphicsClear($hGraphic_object_controls, 0x00000000) Local $hBrush = _GDIPlus_BrushCreateSolid($text_colour) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI") Local $hFont = _GDIPlus_FontCreate($hFamily, 12, 1) Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0) Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND(0) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $nowplaying, $hFont, $tLayout, $hFormat) $a_text_size[0] = Round($aInfo[0].Width, 0) $a_text_size[1] = Round($aInfo[0].Height, 0) _GDIPlus_GraphicsDrawStringEx($hGraphic_object_controls, $nowplaying, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_GraphicsDispose($hGraphic) Local $a_pos = ControlGetPos("[CLASS:Shell_TrayWnd]", "", "Windows.UI.Composition.DesktopWindowContentBridge1") If Not @error Then $pos_array[0] = $a_text_size[0] $pos_array[1] = $a_text_size[1] WinMove($h_win, "", ($a_pos[0] - $a_text_size[0]) - 12, @DesktopHeight - ($a_pos[3] / 2) - 12, $a_text_size[0] + 20, $a_text_size[1]) If $fade Then For $i = 0 To 255 Step 15 _SetBitmap($h_win, $Hbitmap_controls, $i, $a_text_size[0] + 10, $a_text_size[1]) Sleep(7) Next EndIf _SetBitmap($h_win, $Hbitmap_controls, 255, $a_text_size[0] + 10, $a_text_size[1]) EndIf EndFunc Func _Infobar_Calc_Position($h_win) Local Static $nowplaying_change, $start_cord_check_old, $visible_change If NOT _Infobar_visible() Then $nowplaying = "" If $visible_change = True Then _Infobar_set_text($h_win, False) EndIf $visible_change = False Else If $visible_change = False Then _Infobar_set_text($h_win, False) EndIf $visible_change = True EndIf Local $a_pos = ControlGetPos("[CLASS:Shell_TrayWnd]", "", "Windows.UI.Composition.DesktopWindowContentBridge1") If Not @error Then If $nowplaying <> $nowplaying_change Then _SetBitmap($h_win, $Hbitmap_controls, 255, $a_text_size[0] + 10, $a_text_size[1]) $nowplaying_change = $nowplaying EndIf Local $start_cord_check = ($a_pos[0] - $a_text_size[0]) - 12 If $start_cord_check <> $start_cord_check_old Then WinMove($h_win, "", $start_cord_check, (@DesktopHeight - ($a_pos[3] / 2)) - 12, $a_text_size[0] + 20, $a_text_size[1]) $start_cord_check_old = $start_cord_check EndIf EndIf WinSetOnTop($h_win_infobar, "", 1) EndFunc Func _Infobar_visible() If WinActive("[CLASS:WorkerW]") Or WinActive("[CLASS:Progman]") Then Return True Else Local $aPos = WinGetPos("[ACTIVE]") If Not @error Then If IsArray($aPos) Then If UBound($aPos) < 5 Then If $aPos[2] >= @DesktopWidth And $aPos[3] >= @DesktopHeight Then Return False Else Return True EndIf EndIf Else Return True EndIf SetError(1) EndIf EndIf EndFunc #EndRegion Func _SetBitmap($hGUI, $hImage, $iOpacity, $n_width, $n_height) Local $hScrDC = _WinAPI_GetDC(0) Local $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) Local $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) Local $tSize = DllStructCreate($tagSIZE) Local $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $n_width) DllStructSetData($tSize, "Y", $n_height) Local $tSource = DllStructCreate($tagPOINT) Local $pSource = DllStructGetPtr($tSource) Local $tBlend = DllStructCreate($tagBLENDFUNCTION) Local $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc Func _Exit_SP() _GDIPlus_BitmapDispose($Hbitmap_controls) _GDIPlus_GraphicsDispose($hGraphic_object_controls) _GDIPlus_Shutdown() DllCall('kernel32.dll', 'long', 'SetThreadExecutionState', 'long', BitOR(0x80000000, 0x00000002, 0x00000001)) Exit EndFunc
  15. Looks great, thanks!
  16. Just run the script or compiled to a exe file You have to run the Spotify Windows app to get it to work, it won't work with the web browser version of Spotify. I made a update of this program, if there is any interest in the update please let me know and I will update the source code.
  17. With the function "_BASS_Encode_Start" and "lame.exe" it's possible. If the radio station is a MP3 stream (the most are that) you can also you use inetget or inetread AutoIt Functions
  18. Everything in 1 zip file Spotibar.zip
  19. Hi I made a program which get the artist – title information from the Windows Spotify program and shows it on the Windows taskbar (not working from the web version). It’s shows the Artist – Title information on the right side on the Windows taskbar. You can change the text colour by clicking on the icon in the icon in the systray. Can you give me feedback please? Thanks for testing it. Only for Windows 11 !!!! #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> #include <Array.au3> #include <Include/StringSize.au3> #include <TrayConstants.au3> #include <String.au3> #include <Misc.au3> Opt("TrayMenuMode", 3) Global $program_name = "Spotibar" Global $program_version = "V0.1" Global $hGraphic_object_controls, $Hbitmap_controls, $nowplaying Global $strip_extra Local $tmr_loop = TimerInit() _GDIPlus_Startup() TraySetToolTip($program_name & " " & $program_version) Local $tray_config_menu = TrayCreateMenu("Config") Local $tray_config_strip = TrayCreateItem("Strip extra information", $tray_config_menu) Local $tray_config_colour = TrayCreateItem("Text colour", $tray_config_menu) Local $tray_config_autostart = TrayCreateItem("Auto start with Windows", $tray_config_menu) TrayCreateItem("") Local $tray_exit = TrayCreateItem("Exit") If RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip") = "" Or RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip") = "1" Then TrayItemSetState($tray_config_strip, $TRAY_CHECKED) $strip_extra = True Else TrayItemSetState($tray_config_strip, $TRAY_UNCHECKED) $strip_extra = False EndIf If RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour") = "" Then Global $text_colour = "0xFF009B00" Else Global $text_colour = "0xFF" & StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour"), 6) EndIf $var = RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar") If Not @error Then TrayItemSetState($tray_config_autostart, $GUI_CHECKED) EndIf Local $h_win_infobar = _Infobar_start() While 1 Local $tray = TrayGetMsg() Switch $tray Case $tray_config_strip If BitAND(TrayItemGetState($tray_config_strip), $TRAY_UNCHECKED) Then TrayItemSetState($tray_config_strip, $TRAY_CHECKED) RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip", "REG_SZ", 1) $strip_extra = True Else TrayItemSetState($tray_config_strip, $TRAY_UNCHECKED) RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip", "REG_SZ", 0) $strip_extra = False EndIf Case $tray_config_colour TrayItemSetState($tray_config_colour, $TRAY_CHECKED) Local $colourinfo = RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour") If $colourinfo = "" Then $colourinfo = "0x009B00" EndIf $colourinfo = _ChooseColor(2, $colourinfo, 2) If Not (@error) Then If $colourinfo > "" Then RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour", "REG_SZ", $colourinfo) $text_colour = "0xFF" & StringRight($colourinfo, 6) _Infobar_set_text($h_win_infobar) EndIf EndIf TrayItemSetState($tray_config_colour, $TRAY_UNCHECKED) Case $tray_config_autostart If BitAND(TrayItemGetState($tray_config_autostart), $TRAY_UNCHECKED) Then RegDelete("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar") RegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar", "REG_SZ", '"' & @ScriptDir & '\Spotibar.exe"') TrayItemSetState($tray_config_autostart, $TRAY_CHECKED) Else RegDelete("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar") TrayItemSetState($tray_config_autostart, $TRAY_UNCHECKED) EndIf Case $tray_exit _GDIPlus_Shutdown() Exit EndSwitch If TimerDiff($tmr_loop) > 1000 Then _TMR_get_title() $tmr_loop = TimerInit() EndIf Sleep(10) WEnd Func _TMR_get_title() Local Static $nowplaying_old $nowplaying = _Get_NowPlaying() If $nowplaying = "0" Then $nowplaying = "" EndIf If $strip_extra Then $nowplaying = StringRegExpReplace($nowplaying, "\([^)]*\)|\[[^)]*\]", "", 0); strip everything between ( ) and [ ] $nowplaying = StringStripWS($nowplaying, 3); strip leading and trealing whitespace Local $array_strip = StringRegExp($nowplaying, "(.*?\s-\s.*?)\s-\s.*", $STR_REGEXPARRAYGLOBALMATCH, 1); strip everything after the second dash character If Not @error Then $nowplaying = $array_strip[0] EndIf EndIf If $nowplaying <> $nowplaying_old Then TraySetToolTip($program_name & " " & $program_version & @CRLF & @CRLF & $nowplaying) ConsoleWrite($nowplaying & @CRLF) _Infobar_set_text($h_win_infobar) $nowplaying_old = $nowplaying EndIf _Infobar_Calc_Position($h_win_infobar) WinSetOnTop($h_win_infobar, "", 1) EndFunc Func _Get_NowPlaying() Local $aWinLis For $i = 0 To 15 $aWinList = WinList("[Class:Chrome_WidgetWin_0; INSTANCE:" & $i & "]") If UBound($aWinList) > 1 Then If $aWinList[1][0] > "" Then Return $aWinList[1][0] ExitLoop EndIf EndIf Next EndFunc Func _Infobar_start() $Hbitmap_controls = _GDIPlus_BitmapCreateFromScan0(800, 25) $hGraphic_object_controls = _GDIPlus_ImageGetGraphicsContext($Hbitmap_controls) _GDIPlus_GraphicsSetTextRenderingHint($hGraphic_object_controls, 4) _GDIPlus_GraphicsSetSmoothingMode($hGraphic_object_controls, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing) Local $fullscreencontrolgui = GUICreate("", 0, 0, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW)) _SetBitmap($fullscreencontrolgui, $Hbitmap_controls, 255, 1000, 25) GUISetState(@SW_SHOW, $fullscreencontrolgui) WinSetOnTop($fullscreencontrolgui, "", 1) Return $fullscreencontrolgui EndFunc Func _Infobar_set_text($h_win) Local Static $pos_array[2] If NOT _Infobar_visible() Then $nowplaying = "" EndIf For $i = 255 To 0 Step -15 _SetBitmap($h_win, $Hbitmap_controls, $i, $pos_array[0], $pos_array[1]) Sleep(7) Next _GDIPlus_GraphicsClear($hGraphic_object_controls, 0x00000000) Local $hBrush = _GDIPlus_BrushCreateSolid($text_colour) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI") Local $hFont = _GDIPlus_FontCreate($hFamily, 12, 1) Local $tLayout = _GDIPlus_RectFCreate(0, 0, 1000, 100) _GDIPlus_GraphicsDrawStringEx($hGraphic_object_controls, $nowplaying, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) Local $a_pos = ControlGetPos("[CLASS:Shell_TrayWnd]", "", "Windows.UI.Composition.DesktopWindowContentBridge1") If Not @error Then Local $a_info = _StringSize($nowplaying, 12, 600, 0, "Segoe UI") $pos_array[0] = $a_info[2] $pos_array[1] = $a_info[3] WinMove($h_win, "", ($a_pos[0] - $a_info[2]) - 10, @DesktopHeight - ($a_pos[3] / 2) - 12, $a_info[2] + 20, $a_info[3]) For $i = 0 To 255 Step 15 _SetBitmap($h_win, $Hbitmap_controls, $i, $a_info[2], $a_info[3]) Sleep(7) Next _SetBitmap($h_win, $Hbitmap_controls, 255, $a_info[2], $a_info[3]) _Infobar_Calc_Position($h_win_infobar) EndIf EndFunc Func _Infobar_Calc_Position($h_win) Local Static $nowplaying_len, $start_cord_check_old If NOT _Infobar_visible() Then $nowplaying = "" EndIf Local $a_pos = ControlGetPos("[CLASS:Shell_TrayWnd]", "", "Windows.UI.Composition.DesktopWindowContentBridge1") If Not @error Then Local $a_info = _StringSize($nowplaying, 12, 600, 0, "Segoe UI") If Stringlen($nowplaying) <> $nowplaying_len Then _SetBitmap($h_win, $Hbitmap_controls, 255, $a_info[2] + 20, $a_info[3]) $nowplaying_len = Stringlen($nowplaying) EndIf Local $start_cord_check = ($a_pos[0] - $a_info[2]) - 10 If ($a_pos[0] - $a_info[2]) - 15 <> $start_cord_check_old Then WinMove($h_win, "", $start_cord_check, (@DesktopHeight - ($a_pos[3] / 2)) - 12, $a_info[2] + 20, $a_info[3]) $start_cord_check_old = $start_cord_check EndIf EndIf EndFunc Func _Infobar_visible() If WinActive("[CLASS:WorkerW]") Or WinActive("[CLASS:Progman]") Then Return True Else Local $aPos = WinGetPos("[ACTIVE]") If Not @error Then If IsArray($aPos) Then If UBound($aPos) < 5 Then If $aPos[2] >= @DesktopWidth And $aPos[3] >= @DesktopHeight Then Return False Else Return True EndIf EndIf Else Return True EndIf SetError(1) EndIf EndIf EndFunc Func _SetBitmap($hGUI, $hImage, $iOpacity, $n_width = 200, $n_height = 200) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $n_width) DllStructSetData($tSize, "Y", $n_height) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc
  20. I found 2 problems. 1) If I have a script with a few almost te same line and I'm sellecting 1 on them the other line get also selected and ISN get stuck in something, CPU get to max and the only thing I can do is to kill ISN and restart it, see the screenshot below. It only happens sometimes and I can't reproduce this problem all the time. Line 456 is the one I selected and 434 get also selected and then it all stops. 2) Sometimes when I stop a script ISN did not notice the that the script has stopt and it isn't possible to start the script again, the indicator stays red. These issue I had in all previous version also, these error are not from the last update.
  21. @musicstashall I can't reproduce your problem, have you try'd to delete the entire program and all config and just start from the beginning?
  22. Thanks for the update!!🙂
  23. With regex in 1 line ConsoleWrite(StringRegExpReplace(@YEAR, "^(\d{2})", "", 0) & @CRLF)
  24. New version V1.4.3 See the first post for the changes.
  25. @Nyl- Just a small fix for the client. #include <Array.au3> Global $server_name = "TRS" Global $send_port = 6666 Global $recieve_port = 7777 UDPStartup() $sIPADDRESS = _Get_client_ip($server_name) If @error Then ConsoleWrite("Error" & @CRLF) Else ConsoleWrite("Ip address server is " & $sIPADDRESS & @CRLF) EndIf Func _Get_client_ip($sendstring) Local $data, $count, $count_total UDPStartup() Local $socket_send = UDPOpen("255.255.255.255", $send_port, 1); Multicast Local $socket_recieve = UDPBind(@IPAddress1, $recieve_port) If UDPSend($socket_send, $sendstring) = 0 then SetError(1) Else While 1 If $count_total > 20 Then SetError(2) ExitLoop EndIf If $count > 5 Then If UDPSend($socket_send, $sendstring) = 0 then SetError(1); ExitLoop EndIf $count = 0 EndIf $data = UDPRecv($socket_recieve, 50, $UDP_DATA_ARRAY) If IsArray($data) Then If $data[0] = $server_name Then ExitLoop EndIf EndIf $count = $count + 1 $count_total = $count_total + 1 Sleep(100) WEnd EndIf UDPCloseSocket($socket_send) UDPCloseSocket($socket_recieve) UDPShutdown() If UBound($data) = 0 Then Return SetError(2) Else Return $data[1] EndIf EndFunc UDPShutdown() Exit
×
×
  • Create New...