Jump to content

A little help


Lapone
 Share

Recommended Posts

Hi all,

I'm new in the forum.

I need help convertind a command like this:

nconvert -out bmp -resize 640 480 -o C:\result_%%.bmp mypic.jpg
oÝ÷ Ú)í ­¢+{ZÅ«­¢+Ø(ÀÌØíáôMÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈí¹½¹ÙÉйáÅÕ½Ðì(ÀÌØíÁ¥ôMÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈíµåÁ¥¹©ÁÅÕ½Ðì(ÀÌØíÍÐôQµÁ¥ÈµÀìÅÕ½ÐìÀäÈíÉÍձйµÀÅÕ½Ðì(ÀÌØíÉÌôͭѽÁ]¥Ñ µÀìÌäìÌäìµÀìͭѽÁ!¥¡Ð()ÉÕ¸ ÀÌØíáµÀìÌäìµ½ÕеÀµÉÍ¥éÅÕ½ÐìÌäìµÀìÀÌØíÉ̵ÀìÌäìÅÕ½Ðìµ¼µÀìÀÌØíÍÐÅÕ½ÐìÌäìµÀìÀÌØíÁ¥°ÅÕ½ÐìÅÕ½Ðì°M]}!%¤(

Thanks in advance

Link to comment
Share on other sites

  • Developers

RunWait(@ComSpec & ' /C "' $exe & '" -out bmp -resize "' & $res & '" -o "' & $dest & '" "' & $pic & '"', "", @SW_HIDE)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 4 weeks later...

Hi, it seems that I successfully handled my little script to randomize wallpaper in a BartPE CD

#NoTrayIcon
Dim $favDir = @ScriptDir & '\Wallpapers\'
Dim $exe = @ScriptDir & "\nconvert.exe"
Dim $dest = @TempDir & "\wall.bmp"


$hFilesFolders = _FileListToArrayEx($favDir, '*.jpg; *.bmp; *.gif; *.png')
    If @error Then Exit
      $s_FileList = _ArrayToString($hFilesFolders, "*",1)
      $a_FileList = StringSplit($s_FileList, "*")
      $s_TempFile = _TempFile()
      _FileWriteFromArray($s_TempFile, $a_FileList)
      $count = _FileCountLines($s_TempFile)
      $sLine = FileReadLine($s_TempFile, 1)
      _removeLineInFile($s_TempFile, $sLine, 3, 1, 0, 0)
      $read = FileReadLine($s_TempFile, Random(1, $count, 0))
      Filedelete ($s_TempFile)
      SetImage($favDir & $read)


Func SetImage($pic)
    If Not FileExists($pic) Then Return -1
    FileDelete($dest)
    RunWait($exe & ' -out bmp -resize "' & @DesktopWidth & '" "' & @DesktopHeight & '" -o "' & $dest & '" "' & $pic & '"', "", @SW_HIDE)

    Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop"
    Local $REG_LOGON= "HKEY_LOCAL_MACHINE\SOFTWARE\Reatogo\Logon\Shells\Explorer"

    RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0)
    RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 2)
    RegWrite($REG_DESKTOP, "Wallpaper", "REG_SZ", $pic)
    RegWrite($REG_LOGON, "Wallpaper", "REG_SZ", $pic)
    Sleep(250)
    DllCall("User32.dll", "int", "SystemParametersInfo", _
            "int", 20, _
            "int", 0, _
            "string", $dest, _
            "int", 0x01)
Return 0
EndFunc

My question is How can I modify this script to avoid the need of write to temp file? :whistle:

Regards

Link to comment
Share on other sites

How can I modify this script to avoid the need of write to temp file?

#NoTrayIcon
Dim $favDir = @ScriptDir & '\Wallpapers\'
Dim $exe = @ScriptDir & "\nconvert.exe"
Dim $dest = @TempDir & "\wall.bmp"


$hFilesFolders = _FileListToArrayEx($favDir, '*.jpg; *.bmp; *.gif; *.png')
    If @error Then Exit
      $s_FileList = _ArrayToString($hFilesFolders, "*",1)
      $a_FileList = StringSplit($s_FileList, "*")
      $count = $a_FileList[0]
      $sLine = $a_FileList[1]
      _ArrayDelete($a_FileList, $sLine)
      $read = $a_FileList[Random(1, $count, 0)]
      SetImage($favDir & $read)


Func SetImage($pic)
    If Not FileExists($pic) Then Return -1
    FileDelete($dest)
    RunWait($exe & ' -out bmp -resize "' & @DesktopWidth & '" "' & @DesktopHeight & '" -o "' & $dest & '" "' & $pic & '"', "", @SW_HIDE)

    Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop"
    Local $REG_LOGON= "HKEY_LOCAL_MACHINE\SOFTWARE\Reatogo\Logon\Shells\Explorer"

    RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0)
    RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 2)
    RegWrite($REG_DESKTOP, "Wallpaper", "REG_SZ", $pic)
    RegWrite($REG_LOGON, "Wallpaper", "REG_SZ", $pic)
    Sleep(250)
    DllCall("User32.dll", "int", "SystemParametersInfo", _
            "int", 20, _
            "int", 0, _
            "string", $dest, _
            "int", 0x01)
Return 0
EndFunc

I dont know the functions, but this i think will work...

If tyou show here the rest of the functions, it will be much easyear to fix this.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • Moderators

No way for me to test this:

$hFilesFolders = _FileListToArrayEx($favDir, '*.jpg; *.bmp; *.gif; *.png')
If @error Then Exit
$s_FileList = _ArrayToString($hFilesFolders, "*", 1);confused on why you would make it a string, then the next line make it an array again.
$a_FileList = StringSplit($s_FileList, "*")
$sHold = ''
For $iCC = 1 To UBound($a_FileList) - 1
    If StringInStr($a_FileList[$iCC], $sLine, 1) Then;Instead of _ReplaceStringInFile
        $sHold &= 3 & Chr(1)
    Else
        $sHold &= $a_FileList[$iCC] & Chr(1)
    EndIf
Next
$sHold = StringSplit(StringTrimRight($sHold, 1), Chr(1));Re make an array
_SetImage ($favDir & $sHold[Random(1, UBound($sHold) - 1, 1));random from 1 to max elements, no decimals

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks MsCreatoR & SmOke_N for the reply.

@MsCreatoR

Works :whistle:

@SmOke_N

If StringInStr($a_FileList[$iCC], $sLine, 1) Then

If StringInStr($a_FileList[$iCC], ^ ERROR

Error: Variable used without being declared.

I'll check further
Link to comment
Share on other sites

  • 4 weeks later...

Hi, I want to change the script for saving the pictures displayed into a SeenPic.txt.

At Startup the script checks if SeenPic.txt exists and if it exists deletes the images already seen from the "total array".

But something went wrong because the same images are shown many times...

Any advice is really appreciated.

#NoTrayIcon
Dim $favDir = @ScriptDir & '\Wallpapers\'
Dim $exe = @ScriptDir & "\nconvert.exe"
Dim $dest = @TempDir & "\wall.bmp"
$hFileRead = FileOpen(@ScriptDir & '\SeenPic.txt', 0)  ;--------------------------------->
$hFileWrite = FileOpen(@ScriptDir & '\SeenPic.txt', 1)  ;--------------------------------->

$hFilesFolders = _FileListToArrayEx($favDir, '*.jpg; *.bmp; *.gif; *.png')
    If @error Then Exit
    If $hFileRead = 1 Then        ;--------------------------------->


    While 1         ;--------------------------------->
    $Used = FileReadLine($hFileRead)  ;--------------------------------->
     If @error = -1 Then ExitLoop   ;--------------------------------->
     _ArrayDelete($hFilesFolders, $Used)  ;--------------------------------->
     Wend   ;--------------------------------->
    Endif    ;--------------------------------->


      $s_FileList = _ArrayToString($hFilesFolders, "*",1)
      $a_FileList = StringSplit($s_FileList, "*")
      $count = $a_FileList[0]
      $sLine = $a_FileList[1]
      _ArrayDelete($a_FileList, $sLine)
      $read = $a_FileList[Random(1, $count, 0)]
      FileWrite($hFileWrite, $read&@CRLF)    ;--------------------------------->
      SetImage($favDir & $read)


Func SetImage($pic)
    If Not FileExists($pic) Then Return -1
    FileDelete($dest)
    RunWait($exe & ' -out bmp -resize "' & @DesktopWidth & '" "' & @DesktopHeight & '" -o "' & $dest & '" "' & $pic & '"', "", @SW_HIDE)

    Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop"
    Local $REG_LOGON= "HKEY_LOCAL_MACHINE\SOFTWARE\Reatogo\Logon\Shells\Explorer"

    RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0)
    RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 2)
    RegWrite($REG_DESKTOP, "Wallpaper", "REG_SZ", $pic)
    RegWrite($REG_LOGON, "Wallpaper", "REG_SZ", $pic)
    Sleep(250)
    DllCall("User32.dll", "int", "SystemParametersInfo", _
            "int", 20, _
            "int", 0, _
            "string", $dest, _
            "int", 0x01)
Return 0
EndFunc

The SeenPic.txt looks like this

bb19cb8017ba.bmp
5545652ac40f.bmp
d991523ed278.bmp
ef9e92091cf2.bmp
40cf8d4e2c7b.bmp
a14c5a96ba92.bmp
bb19cb8017ba.bmp
eb01ecd05186.bmp
cdefbde86f38.bmp

Regards

Link to comment
Share on other sites

Might want to change Random(1, $count, 0) to Random(1, $count, 1) so it returns and intiger. Otherwise the chance to get the last element in the array will be very slim.

Yes, you are right. :whistle:

In my folder I have 100 picture.

Until the 98 "Seen Picture" no problem whit the last two this error:

$read = $a_FileList[Random(1, $count, 1)]

$read = ^ ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

.... I need some error checking and something to reset the SeenPic.txt
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...