Jump to content

Mehomic

Members
  • Posts

    13
  • Joined

  • Last visited

About Mehomic

  • Birthday 02/21/1941

Profile Information

  • Location
    All Over The World
  • Interests
    Still using AutoIt to improve silver-surfers lives.
    What do you use?

Mehomic's Achievements

  1. I have just noticed the OP wanted details for a .docx file. I've not tried one, only an ODF file as a test. All works as it should. I have adapted my code with the details recently posted by @Heiko #include <MsgBoxConstants.au3> $fname = "full/file path/and filename/with.extension" $cURL = Convert2URL($fname) $oServiceManager = ObjCreate("com.sun.star.ServiceManager") ;< create the service manager $oDesktop = $oServiceManager.createInstance("com.sun.star.frame.Desktop") ;< create the desktop object Global $args[3] ;< set the array of properties $args[0] = MakePropertyValue("ReadOnly", False) $args[1] = MakePropertyValue("Password", "") $args[2] = MakePropertyValue("Hidden", False) $oDoc = $oDesktop.loadComponentFromURL($cURL, "_blank", 0, $args) ;< open an existing document #cs WARNING: Selecting the ViewCursor from PageStyles, the cursor must be on the page you want details returned. A single page document will always show the default settings. A document can have many pages formatted as portrait or landscape or a mixture of both. #ce $ViewCursor = $oDoc.CurrentController.getViewCursor() $PageStyle = $ViewCursor.PageStyleName $Style = $oDoc.StyleFamilies.getByName("PageStyles").getByName($PageStyle) $PageHeight = $Style.height $PageWidth = $Style.width $PageOrientation = $Style.isLandscape ConsoleWrite($PageHeight & " x " & $PageWidth &@LF) ConsoleWrite("Page is landscape: " & $PageOrientation &@LF) MsgBox($MB_SYSTEMMODAL, "RESULTS", "Is Landscape: " & $PageOrientation & @CRLF & _ "Page Width: " & $PageWidth & @CRLF & _ "Page Height: " & $PageHeight & @CRLF & _ "Page/Paper Size: " & $PageHeight/100 & "x " & $PageWidth/100) if @error or Not IsObj($oDoc) then SetError(1, 0, 0) EndIf Func MakePropertyValue($cName, $uValue) Local $Pstruc $Pstruc = $oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") $Pstruc.Name = $cName $Pstruc.Value = $uValue Return $Pstruc EndFunc Func Convert2URL($fname) $fname = StringReplace($fname, ":", "|") $fname = StringReplace($fname, " ", "%20") $fname = "file:///" & StringReplace($fname, "\", "/") Return $fname EndFunc code Mehomic
  2. Does this do what ya want? #include <MsgBoxConstants.au3> $fname = "full/path/to/your/filename/with.Extension" $cURL = Convert2URL($fname) $oServiceManager = ObjCreate("com.sun.star.ServiceManager") ;< create the service manager $oDesktop = $oServiceManager.createInstance("com.sun.star.frame.Desktop") ;< create the desktop object Global $args[3] ;< set the array of properties $args[0] = MakePropertyValue("ReadOnly", False) $args[1] = MakePropertyValue("Password", "") $args[2] = MakePropertyValue("Hidden", False) $oDoc = $oDesktop.loadComponentFromURL($cURL, "_blank", 0, $args) ;< open an existing document $StyleFamilies = $oDoc.StyleFamilies ;< select the style families from the open document $PageStyles = $StyleFamilies.getByName("PageStyles") ;< get the page styles $DefPage = $PageStyles.getByName("Default") ;< return default page styles MsgBox($MB_SYSTEMMODAL, "RESULTS", "Is Landscape: " & $DefPage.IsLandscape & @CRLF & _ "Page Width: " & $DefPage.Width & @CRLF & _ "Page Height: " & $DefPage.Height & @CRLF) if @error or Not IsObj($oDoc) then SetError(1, 0, 0) EndIf Func MakePropertyValue($cName, $uValue) Local $Pstruc $Pstruc = $oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") $Pstruc.Name = $cName $Pstruc.Value = $uValue Return $Pstruc EndFunc Func Convert2URL($fname) $fname = StringReplace($fname, ":", "|") $fname = StringReplace($fname, " ", "%20") $fname = "file:///" & StringReplace($fname, "\", "/") Return $fname EndFunc code Mehomic
  3. Wonderful script UEZ, would look nice with a spaceship and/or meteors floating by. Would it be too difficult to add these? Thanks again Mehomic
  4. If you had studied the AOO API documentation you will find that there are many 'properties' that can be utilised. The code below originally by LEAGNUS, has been adapted by me, works just how I need. #cs FileName: RunOOoCalc.au3 Description: Run a Calc file 'hidden' #ce #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Add_Constants=y Opt ("WinTitleMatchMode",4) Opt("TrayIconHide", 1) ;0=show 1=hide Opt('TrayAutoPause', 0) ;0=no pause 1=pause #Include <Array.au3> _Run_OOoCalc() ;=============================================================================== ; ; Function Name: _Run_OOoCalc() ; Description: Opens a Scalc workbook and returns its object identifier. ; Parameter(s): $fn = full UNC File Name of the workbook file ; Requirement(s): AutoIt3 with COM support (post 3.1.1) ; On Success - Returns an object variable pointing to ; active com.sun.star.frame.Desktop Component object ; On Failure - Returns 0 and sets @ERROR = 1 ; Author(s): Leagnus ; Adapted by: Code Mehomic (6 Jan 2011) ; Added: The AOO API 'hidden' properties to the open spreadsheet (display 'hidden') ;=============================================================================== ; Func _Run_OOoCalc() Local $oDesktop, $f_num Local $OpenPar[2] ;<< set array $OpenPar[0] = _setProp("ReadOnly", False) ;<< set to true for read only $OpenPar[1] = _setProp("Hidden", True) ; <<-- set to false to make visible $oSM = Objcreate("com.sun.star.ServiceManager") ;<< create the service manager $oDesktop = $oSM.createInstance("com.sun.star.frame.Desktop") ;<< create a desktop object: $oCurCom = $oDesktop.loadComponentFromURL( "private:factory/scalc", "_blank", 0, $OpenPar) ;<< create blank document if @error or Not IsObj($oCurCom) then SetError(1, 0, 0) else Return EndIf EndFunc ;------------------------------------------------------------------------------------------ ; Function Name: setProp() ; Description: Function to set properties of the OOo service Manager ; Requirement(s): AutoIt3 with COM support (post 3.1.1) ; On Success - Returns an object variable pointing to ; active com.sun.star.frame.Desktop Component object ; On Failure - Returns 0 and sets @ERROR = 1 ; Author(s): Leagnus ; ---------------------------------------------------------------------------------------- Func _setProp($cName, $uValue) Local $oPropertyValue Local $oSM, $setOOoProp $oSM = Objcreate("com.sun.star.ServiceManager") ;<< create the service manager $oPropertyValue = $oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue") ;<< create the property value $oPropertyValue.Name = $cName $oPropertyValue.Value = $uValue $setOOoProp = $oPropertyValue ;<< create 'name=value' pairs Return $setOOoProp EndFunc ; ; --------------------------------------- end of file ---------------------------------------------------- ; Enjoy....... Merry Christmas and a Happy New Year to all. Code Mehomic
  5. kylomas: Thanks for your reply and, casting your expert eye over my script. I was unaware of the GUICtrlSetData() and this has fixed it, also the #include <StaticConstants.au3> Again many thanks for your input and help. Kind regards Code Mehomic
  6. I have a problem in displaying the output to the gui from the following script. Can someone cast their beady eyes over it and suggest a suitable way around it. Also, is there a way to 'reset' the script without re-starting it? Enabling the re-use. Any ideas for improvement would be greatfully received. TIA #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs A GUI to display the VAT content FileName: VATcalc.au3 Version: 1.0.0 Author: Code Mehomic Date: 20-May 2012 Autoit Version: 3.3.6.1 Scite: 2.27 #ce #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <Constants.au3> #include <Math.au3> Opt('MustDeclareVars', 1) Global $nMsg, $Input_VatRate, $Calc_IncVat, $VatRate, $NetRate, $Vat1, $Gross1, $Vat2, $Gross2, $Convert1 GUICreate("VAT Calculator by Mehomic 2012", 400, 400, -1, -1) ;>> will create a dialog box that when displayed is centered ;>> INPUT THE VAT RATE AS A PERCENTAGE $Input_VatRate = GUICtrlCreateGroup(" Input Vat Rate ", 8, 16, 384, 55) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("Vat Rate:", 16, 42, 45, 17) GUICtrlSetTip(-1, "Input the VAT rate without percentage sign") $VatRate = GUICtrlCreateInput("", 70, 37, 40, 21) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFFFFFF) ;>> CALCULATE VAT INCLUSIVE $Calc_IncVat = GUICtrlCreateGroup(" Calculate VAT Inclusive ", 8, 75, 384, 55) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("Net Rate:", 16, 101, 50, 17) GUICtrlSetTip(-1, "Input the Net rate") $NetRate = GUICtrlCreateInput("", 70, 96, 65, 21) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateLabel("Vat:", 154, 101, 45, 17) $Vat1 = GUICtrlCreateInput("0.00", 180, 96, 65, 21) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateLabel("Gross:", 250, 101, 45, 17) $Gross1 = GUICtrlCreateInput("0.00", 285, 96, 65, 21) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFFFFFF) $convert1 = GUICtrlCreateButton("Convert", 50, 257, 75, 25) GUISetState(@SW_SHOW) ;>> will display an empty dialog box ;>> Run the GUI until the dialog is closed While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Convert1 $VatRate = GUICtrlRead($VatRate, 1) ;>> read the VatRate input by user $NetRate = GUICtrlRead($NetRate, 1) ;>> read the NetRate input by user ;>> CALCULATE THE FIGURES $Vat1 = $NetRate / 100 * $VatRate $Gross1 = $NetRate + $Vat1 $Vat2 = Round($Vat1, 2) ;>> round output vat amount to two decimal figures $Gross2 = Round($Gross1, 2) ;>> round output gross amount to two decimal figures ;>> NOW DISPLAY THE OUTPUT MsgBox(0, "CALCULATED VAT RATE", "Net Rate: £" & $NetRate & @CRLF & "Vat: £" & $Vat2 & @CRLF & "Gross Paid: £" & $Gross2 & @CRLF) EndSwitch WEnd GUIDelete() ; ; ----------------------------------------------- end of file -------------------------------------------------------------------------------- ; Code Mehomic
  7. GMK: Thanks for posting this 'updated' version of the OOCalc UDF? I can confirm that your demo file works well in the current stable Apache OpenOffice v 3.4.1 version. It did not report any errors. I am sure there will be a use for this script. Again, Many thanks for sharing.
  8. Is there a function in this midiUDF to convert binary midi to/from human readable text? It would make editing a midi file a lot easier. Has anyone got any ideas if this adaptation is even possible? mehomic
  9. Worked for me on Vista Thanks for sharing.........
  10. I would'nt have the clue. but someone will surely come to the rescue. Good thing come to he who waits Good the best
  11. Sorry... No idea what happening here. Maybe this can not be done.... but who knows?
  12. Yes, I did peruse your script but I found it overly complicated for the simple task of opening and closing the CDTray. There must be thousands of users who have trouble in operating their CD Tray in the same manner that I had. Code Mehomic
  13. Hi Everybods, Since my CD fascia button does not engage with the CD Tray button, obvious misalignment from the usual movement in plastics. I decided I needed some way of "controlling" access to the said drive. Upon extensive googling and searching here at the AutoIt forum; I did not find any thing suitable that would fit my needs. I decided to script my "own" from the Scite help file and the many tips and tricks I have learned from this forum. CDTray.au3 #cs============================================================== Filename: cdtray.au3 Author: Mehomic Date: 02-Mar-2012 Version: 1.0.5.0 #ce============================================================== #NoTrayIcon #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Opt("TrayIconHide", 1) Opt("TrayAutoPause", 0) $my_gui = GUICreate("OPEN/CLOSE CD Tray", 300, 160, (@DesktopWidth - 300) / 2, (@DesktopHeight - 160) / 2) ; w=130 GUISetBkColor("0xDADADA") ; set gui background colour $filemenu = GUICtrlCreateMenu("&File") $exititem = GUICtrlCreateMenuItem("E&xit (Alt + F4)", $filemenu) $helpmenu = GUICtrlCreateMenu("About") $infoitem = GUICtrlCreateMenuItem("Info", $helpmenu) $opencdtray = GUICtrlCreateButton("Open CD Tray", 28, 20, 95, 25) GUICtrlSetState(-1, $GUI_ENABLE) $closecdtray = GUICtrlCreateButton("Close CD Tray", 177, 20, 95, 25) GUICtrlSetState(-1, $GUI_ENABLE) $cancelbutton = GUICtrlCreateButton("Cancel", 103, 70, 95, 25) GUICtrlSetState(-1, $GUI_ENABLE)[/size] [size=3]$status = GUICtrlCreateLabel("Ready to start...", 35, 110, 230, 17, $SS_SUNKEN + $SS_CENTER) ;GUICtrlSetBkColor(-1, -2); sets background color of label transparent GUICtrlSetFont(-1, 9, 300, 0, "Arial") ;<< set font, size, weight GUICtrlSetColor(-1, 0x000000) ;<< set font color (black) GUICtrlSetBkColor(-1, 0xDDDDDD) ;<< set backgorund color of label (grey)[/size] [size=3]GUISetState() Global $GETCDDRIVE = DriveGetDrive("CDROM") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $cancelbutton ExitLoop Case $exititem ExitLoop Case $infoitem MsgBox(0, "About", " Open and Close the CDTray") Case $opencdtray If @error Then ; An error occurred when retrieving the drives. MsgBox(4096, "Open/Close CD Drive", "It appears an error has occurred in" & @CRLF & "retrieving the CDROM drive letter.") Else GUICtrlSetData($status, "Opening CD Tray") GUICtrlSetColor(-1, 0x006600) ; font color green ;$GETCDDRIVE = DriveGetDrive("CDROM") CDTray($GETCDDRIVE[1] & "\", "open") GUICtrlSetData($status, "Please insert/remove your media") Sleep(1500) EndIf Case $closecdtray If @error Then ; An error occurred when retrieving the drives. MsgBox(4096, "Open/Close CD Drive", "It appears an error has occurred in" & @CRLF & "retrieving the CDROM drive letter.") Else GUICtrlSetData($status, "Closing the CD Tray") GUICtrlSetColor(-1, 0x006600) ; font color green ;$GETCDDRIVE = DriveGetDrive("CDROM") CDTray($GETCDDRIVE[1] & "\", "close") GUICtrlSetData($status, "Thank You") Sleep(4000) GUICtrlSetData($status, "Ready to start.....") GUICtrlSetColor(-1, 0x000000) ;<< set font color (black) EndIf EndSwitch WEnd GUIDelete() Exit[/size] [size=3]; ; ------------------------------------------ end of file ----------------------------------------------- ;[/size] [size=3] Enjoy........ PS This is my first attempt at using Autoit Mehomic
×
×
  • Create New...