
jestermgee
Active Members-
Posts
21 -
Joined
-
Last visited
jestermgee's Achievements

Seeker (1/7)
0
Reputation
-
Ok, so sorry if this is covered or if I do not include all the correct information, I'm no seasoned programmer just trying to learn what I need to get by. I have managed to learn over the last few weeks how to decompile a msgpack string into json and then use this UDF to get/put data and recompile back to msgpack. I am stuck on what seems a simple problem that no suggestions in this thread have worked and I see this has been noted as an issue but the latest UDF is not allowing me to progress. I am using the UDF by Ward, 2021.11.20 The issue is when a period is within the key itself so I have this sample json here I am trying to read the VST.magic and VST3.uid values: { "VST.magic","Test" "VST3.uid",[ 2229853791 2455052834 2533024787 1016289816 ] "pluginName","Omnisphere" "pluginVendor","Spectrasonics" } I have this example code: $sJsonString = FileRead(@ScriptDir & "\Test_PLID_Data.json") Json_Dump($sJsonString) $oJsonString = Json_Decode($sJsonString) ;$aKey = $oJsonString.keys $data = Json_Get($oJsonString, '.VST.magic') ConsoleWrite("RESULT = " & $data & @CRLF) I cannot get any result trying to read these keys, just blank. This works fine: $data = Json_Get($oJsonString, '.pluginName') And the above will work if I remove the period from the key and try read it again so it is specific to the period in the key. I saw this as an issue some time ago and some workaround proposed do not work for me. I have tried: $data = Json_Get($oJsonString, '."VST"."magic"') $data = Json_Get($oJsonString, '.VST."magic"') $data = Json_Get($oJsonString, '[VST][magic]') $data = Json_Get($oJsonString, '[VST]["magic"]') And probably every variation of all the above attempts but cannot get anything to work. EDIT: My current method to work around this since these are the only 2 keys that have a period is to StringReplace these with _ to allow my code to do what needs to be done then substitute the period back again when writing the string out again. Not perfect but works.
-
Generate NFO files based on file name
jestermgee replied to jestermgee's topic in AutoIt General Help and Support
Stefan Thankyou so much for your help I have completed the script and through studying what you did have learn't a few new skills. The script I have created won't be a solution for everyone but it sure as hell works a treat for me and saves SOOOOOOOOO much time so thanks for your help. There were just a couple of issues with some of the syntaxes you had which was confusing me but once I broke down the program and studied the help file I was on my way to understanding how the code was trying to work. I then added the extra info I wanted in my NFO file and lastly allowed the program to detect other video files than just avi (which required the ability for 3 and 4 character extensions to be processed). The code isn't perfect but it works well so long as all files are in the correct format. I am sure if others need this they can modify it for their needs. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: Jester Mgee Script Function: This script is designed to create a simple .NFO file for video files. The script is hard coded to work on files with the following format names: Show Name - SSxEE - Episode Title.ext The Episode Title, Season Number (SS) and Episode Number (EE) will all be extracted and entered into an NFO file that will be created in the folder with the video files. The script is run from within the folder that NFO files are to be generated and will process the formats of files listed in the script. IF an NFO file already resides in the directory it will be replaced automatically. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <file.au3> #include <array.au3> Global $aravifiles, $file, $title, $season, $episode $avidir = @ScriptDir $nfodir = @ScriptDir ; Process 3 character extension files ;get avi files $aravifiles = _FileListToArray ($avidir, "*.avi", 1) _processfilename3() ;get mpg files $aravifiles = _FileListToArray ($avidir, "*.mpg", 1) _processfilename3() ;get wmv files $aravifiles = _FileListToArray ($avidir, "*.mpg", 1) _processfilename3() ;get mkv files $aravifiles = _FileListToArray ($avidir, "*.mkv", 1) _processfilename3() ; Process 4 character extension files $aravifiles = _FileListToArray ($avidir, "*.divx", 1) _processfilename4() $aravifiles = _FileListToArray ($avidir, "*.mpeg", 1) _processfilename4() $aravifiles = _FileListToArray ($avidir, "*.mt2s", 1) _processfilename4() ; Function for 3 character filenames (avi; mpg; wmv; mkv) Func _processfilename3() ;Loop over array with filenames For $i = 1 To UBound ($aravifiles) - 1 ;Cut 4 char from the right -> get rid of extension and set new extension $file = $nfodir & "\" & StringTrimRight ($aravifiles [$i], 4) & ".nfo" ;Split Avi Filename by - $temp = StringSplit ($aravifiles [$i], " - ", 1) ;_ArrayDisplay ($temp, "StringSplit - File Name") ;last element is title -> get rid of extension and rid of leading space $title = StringTrimRight ($temp [3], 4) ;title and episode is split of 2 nd element of 1st stringsplit, splitting by x $temp1 = StringSplit ($temp [2], "x", 1) ;_ArrayDisplay ($temp1, "StringSplit - Season / Episode") ;season is last elemnt of split, get rid of spaces $season = StringStripWS ($temp1 [1], 8) ;episode is 1st elemnt of split, get rid of spaces $episode = StringStripWS ($temp1 [2], 8) ;write nfo file _writenfo () Next EndFunc ; Function for 3 character filenames (divx; mpeg; mt2s) Func _processfilename4() ;Loop over array with filenames For $i = 1 To UBound ($aravifiles) - 1 ;Cut 5 char from the right -> get rid of extension and set new extension $file = $nfodir & "\" & StringTrimRight ($aravifiles [$i], 5) & ".nfo" ;Split Avi Filename by - $temp = StringSplit ($aravifiles [$i], " - ", 1) ;_ArrayDisplay ($temp, "StringSplit - File Name") ;last element is title -> get rid of extension and rid of leading space $title = StringTrimRight ($temp [3], 5) ;title and episode is split of 2 nd element of 1st stringsplit, splitting by x $temp1 = StringSplit ($temp [2], "x", 1) ;_ArrayDisplay ($temp1, "StringSplit - Season / Episode") ;season is last elemnt of split, get rid of spaces $season = StringStripWS ($temp1 [1], 8) ;episode is 1st elemnt of split, get rid of spaces $episode = StringStripWS ($temp1 [2], 8) ;write nfo file _writenfo () Next EndFunc Func _writenfo () If FileExists ($file) Then FileDelete ($file) FileWriteLine ($file, "<episodedetails>") ;chr (9) is a TAB FileWriteLine ($file, Chr (9) & "<title>" & $title & "</title>") FileWriteLine ($file, Chr (9) & "<rating>5.0</rating>") FileWriteLine ($file, Chr (9) & "<season>" & $season & "</season>") FileWriteLine ($file, Chr (9) & "<episode>" & $episode & "</episode>") FileWriteLine ($file, Chr (9) & "<plot>Auto-Generated NFO File.</rating>") FileWriteLine ($file, Chr (9) & "<credits>Jester Mgee Systems</credits>") FileWriteLine ($file, Chr (9) & "<director></director>") FileWriteLine ($file, Chr (9) & "<aired></aired>") FileWriteLine ($file, Chr (9) & "<actor>") FileWriteLine ($file, Chr (9) & Chr (9) &"<name></name>") FileWriteLine ($file, Chr (9) & Chr (9) &"<role></role>") FileWriteLine ($file, Chr (9) & Chr (9) &"<thumb></thumb>") FileWriteLine ($file, Chr (9) & "</actor>") FileWriteLine ($file, "</episodedetails>") EndFunc -
Generate NFO files based on file name
jestermgee replied to jestermgee's topic in AutoIt General Help and Support
Thanks for the reply There is a lot of that script I don't fully understand so troubleshooting will be a bit hard for me. I tried running the script on a test file and received the following error: C:\Documents and Settings\jason.NESS\Desktop\NFO Generator.au3 (16) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $title = StringTrimLeft (StringTrimRight ($temp [2], 4),1) $title = StringTrimLeft (StringTrimRight (^ ERROR Not quite sure what to do there. -
I only create scripts when I have a need to do so and I have not needed to create a script for a while now but am looking into one that I can offer the XBMC community. The script that I want to look at creating will generate a NFO file (xml text file) with the filename of a video file. In that file would be the basics of the file name. For example: This show - 01x01 - Pilot Episode.avi What I want to do is create the file: This show - 01x01 - Pilot Episode.nfo Then in this file I want to extract the bits of the file name to fill the relevent fields: <episodedetails> <title>Pilot Episode</title> <season>01</season> <episode>01</episode> </episodedetails> I am completely stuck. As a start I know I can create a loop to use FindFileFirst and FindFileNext to read the file names byt I can't figure out how to get this file name and create another file based off it and fill in the details. My initial thought was to create a temp directory and create a blank text file, then write the lines within the test file then move the file into the video directory and change the extension while moving but it's a bit out of my depth of expertese. Any help to get me started would be great. There are other things I need to get in this but I am sure I can figure those out.
-
Read Options In A Window?
jestermgee replied to jestermgee's topic in AutoIt General Help and Support
Ha... I'm getting better at this I have now done the following: $i = 0 While $i <= 10 WinActivate("Open DVD Disc") ControlFocus("Open DVD Disc", "", 1001) $var = ControlGetText("Open DVD Disc", "", 1001) $result = StringInStr("" & $var & "", "E:") $i = $i + 1 If Not $result = 1 Then Send("{DOWN}") Else ExitLoop EndIf WEnd MsgBox(0, "Test", "Text = " & $result & "") Exit Trying to find the "E:" drive which is below the "D:" drive in the dropdown box. I had to actually focus the GUIBox rather than the main program to send the keystroke for the next selection but I am now reading each option in turn until I find what I need. This goes a long way to make things easier and more reliable for me but any extra suggestions would be really helpful as i'm still learning the ropes. -
Read Options In A Window?
jestermgee replied to jestermgee's topic in AutoIt General Help and Support
I seem to be getting somewhere slowly. I managed to read the first selected value with the following test: WinActivate("DVD Shrink") $var = ControlGetText("Open DVD Disc","", 1001) MsgBox(0,"Test", "Text = "&$var&"") This returns the selected disc drive letter with disk name. Now, how can I just grab the first 2 characters? I want to grab the "D:" (drive letter) and compare this to what the user has entered as a drive letter. If this is not correct then i'll send a {down} command and read the next value. -
This should be pretty straight forward. I want to be able to read what options are available in a selection window. Spcifically, as my training exersize I am writing an automation script for DVD Shrink to learn about how the processes of AutoIT all work. What I wanted to do is for GUI selection boxes such as when you select "Open Disk" I want some way of knowing what options are in the selection box. Using the discovery tool I can see a heap of information: >>>> Window <<<< Title: Open DVD Disc Class: #32770 Position: 324, 277 Size: 366, 209 Style: 0x94C800CC ExStyle: 0x00010101 Handle: 0x005B06C4 >>>> Control <<<< Class: Button Instance: 3 ClassnameNN: Button3 Advanced (Class): [CLASS:Button; INSTANCE:3] ID: Text: Position: 12, 7 Size: 336, 104 ControlClick Coords: 177, 80 Style: 0x50000007 ExStyle: 0x00000004 Handle: 0x002B0798 >>>> Mouse <<<< Position: 192, 116 Cursor ID: 0 Color: 0xECE9D8 >>>> StatusBar <<<< >>>> Visible Text <<<< OK Cancel Select DVD Drive: D:\ [NO DISC] >>>> Hidden Text <<<< but wanted a way of grabbing spcifically the options that are available in the drop down box. I have 2 drives that I can select to open and as a test I would like to know how to read what options are available. I can easily do it at the moment by sending either an UP or DOWN command but the theory of this exercise can be used later. On a similar note I would also like to know if/how I can read text that is selected in a window under a selection bar. This could be used in place of my previous requirement.
-
I simply want to know what is not needed in this function for what I want to do. I have found the following function on the forum that did return the name and path of the uninstall program for the program specified but I have simply modded it to return INSTALLED or NOT INSTALLED for now (I didn't create it but it's what I need) ; Enter Displayname as parameter $result = _UninstallEntry('DVD Decrypter', 1) If Not @error Then MsgBox(0, "Installed", "Installed") Else MsgBox(0, "Not Installed", "Not Installed") EndIf ;If Not @error Then ; MsgBox(0, '', $result) ;EndIf Func _UninstallEntry($displayname, $value = 0) Local $key_main = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' Local $i, $key_main, $key_result, $key_sub, $version, $size = StringLen($displayname) Switch $value Case 1 $value = 'UninstallString' Case 2 $value = 'QuietUninstallString' Case 3 $value = 'DisplayVersion' Case Else $value = '' EndSwitch For $i = 1 To 1000 $key_sub = RegEnumKey($key_main, $i) If @error Then ExitLoop If StringLeft(RegRead($key_main & '\' & $key_sub, 'DisplayName'), $size) = $displayname Then $data = RegRead($key_main & '\' & $key_sub, $value) If $value = '' Then Return 'Installed' If $data = '' Or @error Then ContinueLoop Return $data EndIf Next SetError(1) Return EndFunc All I need (which it does do) is to return an error level depending on IF the program is instaled or not to change the way my script will work. Because i'm a beginner I don't quite understand what all of the code in the function does so I know there is some that doesn't need to be there for what I require so I was just looking for a real quick hand to trim the above so it simply looks for the installed program (DVD Decrypter in the above example) and throws me the "installed" or "not installed" message. So I can learn as best as I can I need anything that is not required for the task to be removed so I can use this in future scripts. Cheers
-
FileInstall() - To root directory?
jestermgee replied to jestermgee's topic in AutoIt General Help and Support
Man that was quick... I also found and tested: $rootdir = @AutoItExe which does what I need. Thanks -
How can I simply extract included files to the location I run the script from? I am required to enter in the destination location which is "unknown" as the script will run from wherever and I want all extracted files to be placed in the same directory. Creating a destination "\" just installs to the root C drive.
-
That's exactly what I needed Works a treat now and I have now updated my first post with the modified code. Thanks.
-
I am trying to improve this code now I have most of it working. I have made some additional timing changes and also created a check to see if my script successfully closed the program. What I would like to do is get rid of the winwait timeouts if at all possible. I need to wait while DVDShrink rips the disk but I also need a way to exit the script should something go wrong and the process never finishes. I am using this script as a learning tool so any pointers would be great. QUESTION: Is there an easy way I can simply check to see if DVD Shrink is still running WHILE waiting for a particular process to finish? Where I have the following code: WinWait("Backup Complete", "", 2400) I'd like to do a continous check to see if the DVDShrink.exe process is still running and if it is not then exit the script with an error. Ideally i'd like to continously check throughout the entire script for the existance of the running process and terminate at any time the process is not found. How can I create a continous subroutine to do this?
-
Hello All I am not a full noob when it comes to programming but i'm definatelly not an elite programmer. I can create a hack here and a solution there but there is so much I don't understand and would love to. I'm getting there but I have to teach myself. I have a program here that I created for my HTPC system for my girlfriend. It is an automation script for DVDShrink 3.2 and is designed for true 1 touch ripping and burning. I needed a way I could insert a DVD, use a remote control to rip to HDD without the need for a mouse or keyboard. I also wanted options to be able to simply rip to HDD without burning so I could do that later. Here is the script I created over time to do this: #cs ---------------------------------------------------------------------------- Title: AutoDVDShrink Version: 3.2.10.0 Author: JesterMgee Script Function: Automate DVDShrink with no user intervention. 1 click DVD backup. Choose (in config file) to archive rips to HDD and/or burn DVD. Designed with HTPC applications in mind where you insert a DVD, press copy then go back to what it was you were doing. #ce ---------------------------------------------------------------------------- ; #include "Misc.au3" ;Includes a check to see if process is already running and terminates process. if _Singleton("AutoDVDShrink",1) = 0 Then ProcessClose("AutoDVDShrink.exe") EndIf ;Create Config.ini file if it doesn't exsist If Not FileExists("Config.ini") Then IniWrite("Config.ini", "OPTIONS", "DVDLETTER", "F:") IniWrite("Config.ini", "OPTIONS", "DEFAULTDIR", "D:\DVDRip") IniWrite("Config.ini", "OPTIONS", "KEEPCOPY", "YES") IniWrite("Config.ini", "OPTIONS", "BURNCOPY", "YES") MsgBox(48,"No Configuration File Found", "No configuration file detected. A Configuration file has been created. Please set the options are reload AutoDVDShrink.") Exit EndIf ;subroutine to continously check for DVDShrink. If not detected the script will exit with a failure message. Routine is activated by AdlibEnable. Func processquit() If Not ProcessExists("DVD Shrink 3.2.exe") Then MsgBox(16,"Problem - DVD Shrink Not Detected", "DVD Shrink was not detected or has terminated. The process has not finished successfully and must quit.",60) CDTray(""&$DVDLETTER&"", "open") Exit EndIf EndFunc ;Load in values fron config.ini $DVDLETTER = IniRead("Config.ini", "OPTIONS", "DVDLETTER", "F:") $DEFAULTDIR = IniRead("Config.ini", "OPTIONS", "DEFAULTDIR", "D:\DVDRip") $KEEPCOPY = IniRead("Config.ini", "OPTIONS", "KEEPCOPY", "YES") $BURNCOPY = IniRead("Config.ini", "OPTIONS", "BURNCOPY", "YES") DirRemove(""&$DEFAULTDIR&"\TEMP") While 1 If FileExists(""&$DVDLETTER&"\VIDEO_TS") Then ;Check Drive Tray Run("C:\Program Files\DVD Shrink\DVD Shrink 3.2.exe") ;Launch DVDShrink WinWait("DVD Shrink 3.2", "", 10) ;Open DVD Shrink AdlibEnable("processquit", 1000) ;Enable the routine to check for DVD Shrink. IF @error = 1 Then Exit EndIf sleep(100) Send("{ALT}") ;Open Menu sleep(100) Send("{DOWN}") ;Drop down menu Send("{D}") ;Select "Open Disc" Send("{ENTER}") ;Select DVD in rom drive on pop-up menu sleep(1000) ; Send("{ENTER}") WinWait("DVD Shrink 3.2 - "&$DVDLETTER&"", "", 900) ;wait for options window (wait for analyzing to finish) IF @error = 1 Then WinClose("DVD Shrink 3.2") Exit EndIf sleep(100) Send("^b") ;Send CTRL+B for "Backup" sleep(1000) IF $BURNCOPY = ("YES") Then ;Routine to select to either burn to disk or just save to HDD Send("{HOME}") Else Send("{END}") EndIf sleep(200) Send("{TAB}") IF $KEEPCOPY = ("YES") Then $var = DriveGetLabel( ""&$DVDLETTER&"" ) Send(""&$DEFAULTDIR&"\"&$var&"", 1) Else Send(""&$DEFAULTDIR&"\TEMP", 1) EndIf WinWait("Backup DVD", "", 20) ;Backup dialog window sleep(100) Send("{ENTER}") ;Confirm backup to HDD sleep(100) If WinExists("DVD Shrink 3.2", "Delete the files now") Then ;If files exist in directory then delete Send("y") Endif Opt("WinTitleMatchMode", 2) ;Sets match mode for detecting the window to "any" to find the word "encoding" WinWait("Encoding", "", 20) ;waits for the encoding window then switches control back to Meedio sleep(500) send("!{TAB}") ;Switches back to background application WinWait("Backup Complete", "", 2400) ;Wait for the backup complete window then close DVD Shrink. sleep(500) AdlibDisable() $var = WinClose("DVD Shrink 3.2") ;Close program after DVD copy complete If $var = 1 Then MsgBox(64,"Completed", "The ripping process has completed. Please check to make sure it worked and have a good day",60) Else MsgBox(16,"Problem", "DVDShrink was not closed by AutoDVD Shrink. The disk may not have ripped successfully.",60) EndIf CDTray(""&$DVDLETTER&"", "open") Exit Else ;Displays message if no DVD detected in drive CDTray(""&$DVDLETTER&"", "open") $var = MsgBox(1,"No DVD Detected..."&$DVDLETTER&"", "Insert a DVD Video Disk First. Auto Continue In 15 Sec.",15) CDTray(""&$DVDLETTER&"", "close") If $var = 2 Then Exit EndIf WEnd The code simply emulates keyboard presses to automate the copying process and I have helpful tags in there to show what everything does. I'd like to clean it up a bit using routines and such but haven't mastered that yet. The code isn't perfect but if you have DVDShrink then you should be able to compile this code and test it out. You need DVDShrink 3.2 and it needs to be installed in the default dir (or need to change some of the code). Because i'm no expert, there are some cases that if you do manually stop the copying process or there is some kind of failure, the script doesn't terminate. That is where I have timeouts where i'd like to have more of a reliable method since on some slower machines the timeout may expire before the ripping is done. I'm open to suggestions to help me curb bad coding habbits. I have created many, many a batch script which I am quite good at but as many people here would agree, batch scripts tend to be sloppy on a good day and lead to bad habbits in coding. Cheers EDIT: Had to make a change to one timeout that was way too short.
-
I am working on a monitor for my media server to automatically shutdown the server when it is not required to be running. At the moment the monitor runs as a service ont he server and simply checks via a ping to see if the HTPC machines are online. If they are it then makes a second check to see if the screen saver is running. If the screen saver is running then a shutdown sequence begins. This all works fine. The issue I want to solve now is that my HTPC in the lounge is set to auto turn OFF the monitors after 1 hour and when the monitor is switched off, the screensaver is terminated and the monitor sees the machine as being on and in use. I would like to build a 3rd check that can see if the machine has switched off the monitor. Any ideas?
-
Looping Fails When Compiled To .EXE
jestermgee replied to jestermgee's topic in AutoIt General Help and Support
Excellent!!! Not only does it work as it should (fixes the loop) but also is easier to read and understand! I knew there would have to be a way of making the code neater but i'm just beginning and using anything I can find at the moment as examples on how to do it so thank you very much for taking the time to show me the right way. Much appreciated. My plan was to add in some functions (which I have variables in there for) that will prevent the questions being continously after I have selected to enable or disable the mail forward UNTIL the phones status changes (goes online or offline again). I just needed to get it running first then optomize it and that's what I will do right now.