jaberwacky Posted January 24, 2011 Posted January 24, 2011 (edited) I'm trying to use System.Convert.ToBoolean just for no good reason other than to learn. Here is what I tried: With this $convert is an object... Global $convert = ObjCreate("System.Object") If IsObj($convert) Then ConsoleWrite("$convert is an object." & @LF) ConsoleWrite($convert.ToBoolean(23.15) & @LF) EndIf Error: C:\Users\Matthew\Desktop\New AutoIt v3 Script.au3 (13) : ==> The requested action with this object has failed.: ConsoleWrite($convert.ToBoolean(23.15) & @LF) ConsoleWrite($convert.ToBoolean(23.15) ^ ERROR $convert is not an object... Global $convert = ObjCreate("System.Convert") If IsObj($convert) Then ConsoleWrite("$convert is an object." & @LF) ConsoleWrite($convert.ToBoolean(23.15) & @LF) EndIf I tried this variation too: Global $convert = ObjCreate("System.Object") If IsObj($convert) Then ConsoleWrite("$convert is an object." & @LF) ConsoleWrite($convert.Convert.ToBoolean(23.15) & @LF) EndIf Here is the error message: C:\Users\Matthew\Desktop\New AutoIt v3 Script.au3 (13) : ==> The requested action with this object has failed.: ConsoleWrite($convert.System.Convert.ToBoolean(23.15) & @LF) ConsoleWrite($convert.System^ ERROR As well as this one: Global $convert = ObjCreate("System.Convert") If IsObj($convert) Then ConsoleWrite("$convert is an object." & @LF) ConsoleWrite($convert.ToBoolean(23.15) & @LF) EndIf And quite a few other things I could think of but none of them seem to work. If you could just give me a pointer in the right direction? Edited January 24, 2011 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
spudw2k Posted January 25, 2011 Posted January 25, 2011 (edited) It appears you are trying to use a .NET class which isn' as simple as cut and paste for AutoIt. Based on the example in the here, it would not be difficult to make your own function to do the conversions described.ConsoleWrite(_ToBoolean(16.33)&@CRLF) ConsoleWrite(_ToBoolean(-24)&@CRLF) ConsoleWrite(_ToBoolean(0)&@CRLF) ConsoleWrite(_ToBoolean("12")&@CRLF) ConsoleWrite(_ToBoolean("12.7")&@CRLF) ConsoleWrite(_ToBoolean("")&@CRLF) ConsoleWrite(_ToBoolean("1String")&@CRLF) ConsoleWrite(_ToBoolean("True")&@CRLF) ConsoleWrite(_ToBoolean("false")&@CRLF) Func _ToBoolean($obj) If Not $obj Then SetError(1,0,0) If IsArray($obj) Then SetError(2,0,0) If IsString($obj) then If Not StringCompare("true",$obj) Then Return True If Not StringCompare("false",$obj) Then Return False SetError(3,0,0) EndIf If IsNumber($obj) then If $obj <> 0 Then Return True Else Return False EndIf EndIf EndFunc Edited January 25, 2011 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
jaberwacky Posted January 25, 2011 Author Posted January 25, 2011 (edited) Yeah, this is true. I was just wondering if I could have access to all of the other things the class provides, but that's a no go then. So, there's no way or it's just complicated? I didn't need to use any of those functions, just trying to learn more about windows and programming. Ok, I think I'm beginning to understand a little more. If it isn't WIndows API or COM then you can't do it with a scripting language? Edited January 25, 2011 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
spudw2k Posted January 25, 2011 Posted January 25, 2011 Ok, I think I'm beginning to understand a little more. If it isn't WIndows API or COM then you can't do it with a scripting language?As far as what AutoIt is designed for, yes (and dll calls); but that's not to say that some folks do some crazy stuff with AutoIt. (Resources, Embedded DLL and EXE, Object Oriented Programming, Service Control Manager, etc...) Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
KaFu Posted January 25, 2011 Posted January 25, 2011 (edited) Reading this about the IAccessible interface my wild guess is that it should be possible using AutoItObject... but don't ask me how ... Edited January 25, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
jaberwacky Posted January 25, 2011 Author Posted January 25, 2011 Well, I appreciate that you two took the time to post a response. I have to say that I am way out of my league because I'm in the early stages of learning about Windows. I have to go back to the grindstone. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
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