warezoogle3 Posted July 1, 2012 Share Posted July 1, 2012 Hello Everybody! Sorry for my bad english! I'm newbie in AutoIT and Vbs,I've just started to learn it! But... I need your help,guys! I have a vbs script and want to convert it to AutoIt! The code of vbs script is Const FONTS = &H14& Set objShell = CreateObject("Shell.Application") Set ofso = CreateObject("Scripting.FileSystemObject") SourceFolder = ofso.GetParentFolderName(Wscript.ScriptFullName) Set oSource = objShell.Namespace(SourceFolder) Set oWinFonts = objShell.Namespace(FONTS) Set regEx = New RegExp regEx.IgnoreCase = True regEx.Pattern = "([\w\s]+?)(_[^_]*)?(\.(ttf|otf|pfm|fon))$" FOR EACH FontFile IN oSource.Items() fontFileName = ofso.GetFileName(FontFile.Path) IF regEx.Test(fontFileName) THEN Set objMatch = regEx.Execute(fontFileName) win7FontFileName = objMatch.Item(0).Submatches(0) & objMatch.Item(0).Submatches(2) localFontPath = oWinFonts.Self.Path & "\" & fontFileName win7LocalFontPath = oWinFonts.Self.Path & "\" & win7FontFileName IF NOT ofso.FileExists(localFontPath) AND NOT ofso.FileExists(win7LocalFontPath) THEN oWinFonts.CopyHere FontFile.Path END IF END IF NEXT Automatic vbs to AutoIt convertors make lots of errors! Please help me! P.S. This is great script! It install fonts from the same directory WITHOUT RESTARTING SYSTEM! P.S. I found some other scripts written on AutoIT,but they need the system restart after installing! This installs fonts WITHOUT RESTARTING OS! Please! If you convert it to AutoIt,it will be GREAT! Link to comment Share on other sites More sharing options...
JohnOne Posted July 1, 2012 Share Posted July 1, 2012 Sorry I cannot help you, but... Converting scripts between 2 languages you do not know, is not the best way to lean either of them. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
warezoogle3 Posted July 1, 2012 Author Share Posted July 1, 2012 JohnOne,thank you! I started to learn the vbs and autoit and converting this script to autoit is only for my work,not for learning! I just need it! Please anyone help me! Link to comment Share on other sites More sharing options...
JohnOne Posted July 1, 2012 Share Posted July 1, 2012 Then I suggest you look at this other script you found and try to make connections I'll start you off Local $objShell = ObjCreate("Shell.Application") Local $ofso = ObjCreate("Scripting.FileSystemObject") AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
warezoogle3 Posted July 1, 2012 Author Share Posted July 1, 2012 JohnOne,your are great! Thank you very much!So I converted itConst $FONTS = &H14& Local $objShell = ObjCreate("Shell.Application") Local $ofso = ObjCreate("Scripting.FileSystemObject") Local $SourceFolder = $ofso.GetParentFolderName(@ScriptFullPath) Local $oSource = $objShell.Namespace($SourceFolder) Local $oWinFonts = $objShell.Namespace($FONTS) $regEx = $New $RegExp $regEx.IgnoreCase = 1 $regEx.Pattern = "([ws]+?)(_[^_]*)?(.(ttf|otf|pfm|fon))$" For $FontFile IN $oSource.Items() $fontFileName = $ofso.GetFileName($FontFile.Path) IF $regEx.Test($fontFileName) THEN $objMatch = $regEx.Execute($fontFileName) $win7FontFileName = $objMatch.Item(0).Submatches(0) & $objMatch.Item(0).Submatches(2) $localFontPath = $oWinFonts.Self.Path & "" & $fontFileName $win7LocalFontPath = $oWinFonts.Self.Path & "" & $win7FontFileName IF NOT $ofso.FileExists($localFontPath) AND NOT $ofso.FileExists($win7LocalFontPath) THEN $oWinFonts.CopyHere ($FontFile.Path) EndIf EndIf NEXTBut when I run it,I get a errorWhat's wrong? I don't understand my mistake! Link to comment Share on other sites More sharing options...
JohnOne Posted July 1, 2012 Share Posted July 1, 2012 (edited) That part will probably just beConst $FONTS = "" & "H14" & "" Edited July 1, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
BrewManNH Posted July 1, 2012 Share Posted July 1, 2012 The vbscript number &h14 is 0x14 in AutoIt, the &H tells the script the number is in Hex, the trailing & tells you it's in the "Long" format. &h14& is equal to 20 in decimal. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
warezoogle3 Posted July 3, 2012 Author Share Posted July 3, 2012 (edited) At last it works! Const $FONTS = 0x14 $oShell = ObjCreate("Shell.Application") $oWinFonts = $oShell.Namespace($FONTS) ; The fonts must be in the same directory $sFirstFile = FileFindFirstFile("*.*") If $sFirstFile = -1 Then Exit EndIf While 1 Local $sFile = FileFindNextFile($sFirstFile) If @error Then ExitLoop Switch StringRight($sFile, 3) Case 'ttf', 'otf', 'pfm', 'fon' $sWinFontsPath = @WindowsDir & 'Fonts' & $sFile $sLocFontsPath = @ScriptDir & '' & $sFile If NOT FileExists($sWinFontsPath) Then $oWinFonts.CopyHere($sLocFontsPath) Else MsgBox(262144, $sFile, 'The file is already installed', 1) EndIf EndSwitch WEnd Thank you very much! God bless you! Edited July 3, 2012 by warezoogle3 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now