Zhelkus
Active Members-
Posts
28 -
Joined
-
Last visited
Zhelkus's Achievements
Seeker (1/7)
0
Reputation
-
Check if an image is grayscale or not
Zhelkus replied to Zhelkus's topic in AutoIt General Help and Support
Let me see if I got this: there's a function in autoit that already does this... but it's slow? Hence I should search for a DLL to call and make it faster? Sorry if I'm too lame at this, I'm not really well experienced at coding or scripting... Basically what I want the script for is to check if a GIF or PNG has any colours besides shades of gray. I've found that many people save images as PNGs with 256 colours (or less) in grayscale, and some of them might have a colour that isn't a shade of gray (which isn't grayscale any longer but still has only 256 colours). Also, quite strange, some people save JPEGs to PNG in grayscale but the image has much more than 256 colours due to previously being JPEG or some other odd reason. I want to build a script that checks for that. Weird, I know. I just thought of something more practical: (hypothetically) I got an image with a palette of 256 (8bit) but only has 32 colours (grayscale). If I convert it to 16 colours (4bit) and perform a PixelChecksum on both, before and after, will I get different results or is it not that precise? And what parameter dictates whether an image is grayscale when using _GDIPlus_ImageGetPixelFormat. The palette size? Or does it actually to check the colours of every pixel? EDIT: Smashly if you wrote a script leave it. I'm pretty sure I could use anything as an aid or guideline atm. -
I want to make a simple script that checks if an image is grayscale (black and white) or not. I was thinking of scanning each image with PixelSearch and then check if amongst the whole image there's a pixel that isn't a varying shade of black or white... the thing is that I don't know how to exactly process this. I had it panned out in my head to use PixelSearch for red, green and blue. If result came out positive then it wasn't B&W. But um... what about pictures that have more than 16k colours? Then I found this link: http://www.autoitscript.com/forum/index.php?showtopic=95357. And I wasn't sure how to use it. By any change is there already a script that does this? Any help plz?
-
Need newbie help with $tagFILETIME
Zhelkus replied to Zhelkus's topic in AutoIt General Help and Support
Well, I managed to fix my problem. It was in fact an issue with Foobar. In the end I was able to reorder my music database and I just wanted to finish this thread by saying thanks. Here's the final draft of my script: ;Date converter for MP3 Database List ;Reads line in list with date in year-month-day-hour-minute-second string format and creates a new file list with the same dates in Windows time format #include <Date.au3> $srceList = "C:\Users\Zhelkus\Documents\AutoIT Scripts\Date list\The Ultimate List - Dates Only.txt" $inList = FileOpen($srceList, 0) $destList = "C:\Users\Zhelkus\Documents\AutoIT Scripts\Date list\The Ultimate List - Dates Only - System Converted.txt" $outList = FileOpen($destList, 10) FileClose($outList) $tOffset = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation", "bias")/60 Dim $n = 0 $outList = FileOpen($destList, 1) Dim $time1 = 0 ;to compare with previous line in list While 1 $line = FileReadLine($inList) If @error Then ExitLoop $n += 1 ToolTip($n, 0, 0) $line = Number($line) $tYear = StringLeft($line, 4) $tMon = StringLeft(StringTrimLeft($line, 4), 2) $tDay = StringLeft(StringTrimLeft($line, 6), 2) $tHour = StringLeft(StringTrimLeft($line, 8), 2) $tMin = StringLeft(StringTrimLeft($line, 10), 2) $tSec = StringLeft(StringTrimLeft($line, 12), 2) $line = _DateAdd('h', $tOffset, $tYear & "/" & $tMon & "/" & $tDay & " " & $tHour & ":" & $tMin & ":" & $tSec) $tYear = StringLeft($line, 4) $tMon = StringLeft(StringTrimLeft($line, 5), 2) $tDay = StringLeft(StringTrimLeft($line, 8), 2) $tHour = StringLeft(StringTrimLeft($line, 11), 2) $tMin = StringLeft(StringTrimLeft($line, 14), 2) $tSec = StringLeft(StringTrimLeft($line, 17), 2) $iStamp = _Date_Time_EncodeFileTime($tMon, $tDay, $tYear, $tHour, $tMin, $tSec) $time2 = DllStructGetData($iStamp, "Hi") * 4294967296 + DllStructGetData($iStamp, "Lo") While $time2 <= $time1 $time2 += 10000000; to make sure that all lines are different in case files have same dates: +1 second WEnd $time1 = $time2 FileWriteLine($outList, $time2) WEnd It's a bit noobish but it did what I wanted it to do. -
Need newbie help with $tagFILETIME
Zhelkus replied to Zhelkus's topic in AutoIt General Help and Support
Thanks mate, tho I already tried that. The problem I'm having is that fb2k adds the same Added Date to the database for two different filetime strings (one normal and the other 5 hours behind). I made a link in the post prior to this one in case anybody's curious but I doubt it can be fixed with AutoIt, it seems more like a problem with fb2k. So far I haven't gotten any meaningful response. I'll just have to wait it out, most of that community is European so they might log in later. -
Need newbie help with $tagFILETIME
Zhelkus replied to Zhelkus's topic in AutoIt General Help and Support
Ooh! Excellent! That automates it even more! Sad thing now is that I'm having foobar problems with this... I've already made a thread on the other side and I'm hoping I'll get assistance fixing it. I'll post back when everything is solved. -
Need newbie help with $tagFILETIME
Zhelkus replied to Zhelkus's topic in AutoIt General Help and Support
I don't follow... Whose registry value? Foobar's or Windows'? -
Need newbie help with $tagFILETIME
Zhelkus replied to Zhelkus's topic in AutoIt General Help and Support
Actually, I think the script works perfectly. The problem must be in foobar because I am in fact in a -5GMT zone. It's very likely that fb2k is doing the miscount... odd for it to do so tho. Anyway, thanks a lot guys! I'll just add a new line in the script for the missing hours. -
Need newbie help with $tagFILETIME
Zhelkus replied to Zhelkus's topic in AutoIt General Help and Support
This is excellent! It's just the string I need! I think I may not know the proper naming after all... I'm curious as to how the new file time was calculated because I spent half an hour going through the help file and I concluded it had to be general knowledge . Now, I just tried it and the timestamp was imported into the library successfully but it was 5 hours delayed... I had this time string: 20090221091755 (original list) changed into this: 128796814750000000 (new list with windows file time) where it should have read this: 2009-02-21 09:17:55 (expected string-"ified" time) wrote this to the tag instead: 2009-02-21 04:17:55 (how it showed in foobar) Any ideas? Should I just go about adding 5 hours to every string I pick up from the source list? If so, how would I make sure that the string remains a valid time string... ?? -
Hiya! I'm building a list of files with their respective dates in order to reorganize my music collection. Foobar can store filetimes in tags and then maintain the library from there. I intend to make use of this by tagging all my MP3s with the correct file times of the dates I obtained my songs (recently switched to fb2k and they're all in random order atm). Well, that's the background of it. What I'm doing is building a script that will read the lines in a filelist that only contains the dates in 14 digit string format and then create a new list with every line read written into a new file with the filetime format (intervals since January 1, 1601). My problem is that I can't find a way to print the $tagFILETIME structure I need to write to the MP3 tags. This is my script (it's pretty short but it doesn't need to do any more): ;Date converter for MP3 Database List ;Scans for file with date in year-month-day-hour-minute-second string format and creates a new file with the same dates in Windows time format #include <Date.au3> $srceList = "C:\Users\Zhelkus\Documents\AutoIT Scripts\Date list\The Ultimate List - Dates Only.txt" $inList = FileOpen($srceList, 0) $destList = "C:\Users\Zhelkus\Documents\AutoIT Scripts\Date list\The Ultimate List - Dates Only -> System Converted.txt" $outList = FileOpen($destList, 10) FileClose($outList) $outList = FileOpen($destList, 1) While 1 $line = FileReadLine($inList) If @error Then ExitLoop MsgBox(0,0.5, $line) ;just to see if everything went well $tYear = StringLeft($line, 4) $tMon = StringLeft(StringTrimLeft($line, 4), 2) $tDay = StringLeft(StringTrimLeft($line, 6), 2) $tHour = StringLeft(StringTrimLeft($line, 8), 2) $tMin = StringLeft(StringTrimLeft($line, 10), 2) $tSec = StringLeft(StringTrimLeft($line, 12), 2) ;~ FileWriteLine($outList, _Date_Time_FileTimeToSystemTime($line)) ;just ignore $time = _Date_Time_EncodeFileTime($tMon, $tDay, $tYear, $tHour, $tMin, $tSec) MsgBox(0,0, _Date_Time_FileTimeToStr($time)) ;more testing... damn WEnd I'd appreciate any help
-
Thanks for the replies guys. I'm almost convinced that there's something wrong my understanding of how StdoutRead() works... because it's still not working on my PC (could Vista be the reason? lol). I've tried both code suggestions and they all work the same. #include <GUIConstants.au3> #include <GuiEdit.au3> GUICreate("Firefox backup", 600, 700) $edit1 = GUICtrlCreateEdit("", -1, -1, 600, 700) GUISetState(@SW_SHOW) $program = "7z.exe" $parameter = " a -t7z ""C:\Users\" & @UserName & "\Programs\test.7z"" ""C:\Users\" & @UserName & "\Music\Mike Oldfield - Moonlight Shadow (12' Extended Version).mp3"""; just a file big enough and slow enough to compress and observe StdoutRead() working ;~ Local $7zstdout = Run("cmd.exe", "C:\Program Files\7-zip", @SW_HIDE, BitOR(1,8)) Local $7zstdout = Run(@ComSpec & " /c 7z.exe " & $parameter, "C:\Program Files\7-zip", @SW_HIDE, BitOR(1,8)) ;~ StdinWrite($7zstdout, $program & $parameter & @CRLF) ;~ StdinWrite($7zstdout) Local $line Local $line2 = "" While True $line = StdoutRead($7zstdout, 1) If @error Then ExitLoop ;~ _GUICtrlEdit_AppendText($edit1, $line & @CRLF) If Not $line = "" And $line <> $line2 Then GUICtrlSetData($edit1, $line & @CRLF,1) $line2 = $line Sleep(25) WEnd _GUICtrlEdit_AppendText($edit1, @CRLF & "Finished.") While 1 if GUIGetMsg() == -3 then exit WEnd I believed that StdoutRead() would allow me to read the messages output in the command line by a process while it was running. Say, recreate the the percentage of an image conversion in real-time in an edit control, or watch the files being added to an archive in real-time, which is this case, etc. And thanks for the 7zip UDF, rasim, but what I want to try to do now is understand how this works and use it for other small programs I have floating around that require manual input. The manual explains it so easy and clean... until it covers this part... self-teaching suddenly starts to get harder... *sob*. So far, every try throws out the entire output in a single turn once the program has finished and closes. Peeking at the output only displays the same info over and over again repeatedly until the character limit for the edit control is reached. That's why I added the "$line2 <> $line" to the If. I honestly thought I was getting the hang of this until I stumbled here... oh the sorrow... *sniff*.
-
I tried to follow the help file's script as it was laid out but I don't understand where I'm wrong. In your example above you have $data store all the outputs form the stream but you set to display it at the end. What I want is to read the stream as the program is running. Now, like I said, I'm just a noob at this so if you solved it for me I may have overlooked it That's why I'd rather ask you to explain it to me if possible, please. Thanks for the reply btw.
-
I have a script where I want to make a progress bar according to the program's completion of a certain task. For this matter I'm using 7zip. The last characters for almost each line is the percentage of the progress of the archive's creation. However, when I use StdoutRead() the stream returns blank until the program finishes. The same happens for any other command line program I use. I even created a dummy/test script to see if I could tweak something like peeking at the stream but it won't reveal anything... Here's what I've been doing: #include <GUIConstants.au3> #include <GuiEdit.au3> GUICreate("Firefox backup", 600, 700) $edit1 = GUICtrlCreateEdit("", -1, -1, 600, 700) GUISetState(@SW_SHOW) $program = "7z.exe" $parameter = " a -t7z ""C:\Users\" & @UserName & "\Programs\test.7z"" ""C:\Users\" & @UserName & "\Music\Mike Oldfield - Moonlight Shadow (12' Extended Version).mp3"""; just a file big enough and slow enough to compress and observe StdoutRead() working $7zstdout = Run(@ComSpec & " /k " & $program & $parameter, "C:\Program Files\7-Zip", @SW_SHOW, 8) If @error Then MsgBox(16, "Error", "something happened with the process") Exit EndIf While 1 $line = StdoutRead($7zstdout, 0) If @error Then ExitLoop _GUICtrlEdit_AppendText($edit1, $line) Sleep(25) WEnd _GUICtrlEdit_AppendText($edit1, @CRLF & "Finished.") While 1 $msg = GUIGetMsg() If $msg == $GUI_EVENT_CLOSE Then Exit WEnd I've searched the forum and found people having similar problems (if not the same) but I can't make out how they solved it... I'm too n00bish
-
Make Edit box follow scroll down automatically
Zhelkus replied to Zhelkus's topic in AutoIt GUI Help and Support
Sorry for the late reply. This is an example of how I was managing the edit box. As you guessed it, martin, I was using a variable Case $Button1 $sTime = TimerInit() $msgEdit1 &= @CRLF & "Looking for a refresher?" GUICtrlSetData($Edit1, $msgEdit1) Thanks for the help guys. -
Make Edit box follow scroll down automatically
Zhelkus posted a topic in AutoIt GUI Help and Support
I'm a noob and this is a noob request. I have an edit control box using this piece of script: $Edit1 = GUICtrlCreateEdit("", 16, 32, 545, 209, BitOR($ES_READONLY, $WS_HSCROLL, $WS_VSCROLL, $ES_MULTILINE)) I have a macro inserting text into it but each time text is inserted the box scrolls back to the top. This doesn't happen if I enter text into it manually, but that isn't the point. According to the help file, $ES_AUTOVSCROLL will automatically scroll up after each insertion as well. I want the opposite of that. Could somebody please help me? -
@error flag won't kick in to stop infinite While loop
Zhelkus replied to Zhelkus's topic in AutoIt General Help and Support
Thanks a lot. Not-so-seamlessly learning through T&E.