ed0 Posted August 1, 2007 Share Posted August 1, 2007 Hi, I've got about two weeks experience with AutoIt now, and I have to say it is an amazing macro system. Good job, everyone! Everything has been going fine with my current project, but I've come across one curious thing; I would have expected to find a ControlGetStyle() function to get the style info that shows up for controls in the AutoIt Window Info app, but there doesn't appear to be such a function in the documentation. Am I missing something obvious? I've found a workaround for the moment, but if I could directly read the $ES_READONLY state of a control I'd have cleaner code... Thanks, Ed Link to comment Share on other sites More sharing options...
MrCreatoR Posted August 1, 2007 Share Posted August 1, 2007 Hi, wellcome to forum! There is ControlCommand() function, that you can use to check some states - but for checking if control is read only it's not usefull Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: 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 ProgramUDFs: 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 Examples: 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 ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
ed0 Posted August 1, 2007 Author Share Posted August 1, 2007 Hi, wellcome to forum!There is ControlCommand() function, that you can use to check some states - but for checking if control is read only it's not usefull Ah well, at least I still have my workaround.And perhaps more importantly, I haven't gone batty and missed something obvious.Thanks for the reply,Ed Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 2, 2007 Share Posted August 2, 2007 You can get styles from controls. The problem appears to be that the constants required are peculiar to the class of control, so you get a different function for each class. For example, this is the _GUICtrlListViewGetExtendedListViewStyle() function from GuiListView.au3: ;=============================================================================== ; ; Description: _GUICtrlListViewGetExtendedListViewStyle ; Parameter(s): $h_listview - controlID ; Requirement: None ; Return Value(s): Returns a DWORD that represents the styles currently in use for a given list-view control. ; This value can be a combination of Extended List-View Styles ; User CallTip: _GUICtrlListViewGetExtendedListViewStyle($h_listview) Retrieves the extended styles that are currently in use for a given list-view control (required: <GuiListView.au3>) ; Author(s): Gary Frost (custompcs at charter dot net) ; Note(s): : ; ;=============================================================================== Func _GUICtrlListViewGetExtendedListViewStyle($h_listview) If Not _IsClassName ($h_listview, "SysListView32") Then Return SetError($LV_ERR, $LV_ERR, $LV_ERR) If IsHWnd($h_listview) Then Return _SendMessage($h_listview, $LVM_GETEXTENDEDLISTVIEWSTYLE) Else Return GUICtrlSendMsg($h_listview, $LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0) EndIf EndFunc ;==>_GUICtrlListViewGetExtendedListViewStyle Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ed0 Posted August 2, 2007 Author Share Posted August 2, 2007 You can get styles from controls. The problem appears to be that the constants required are peculiar to the class of control, so you get a different function for each class. For example, this is the _GUICtrlListViewGetExtendedListViewStyle() function from GuiListView.au3: [...] I see that there are functions to get extended styles from ListView and tab controls, but $ES_READONLY is a non-extended style property of an edit field. I don't see any _GUI...GetStyle() functions for any controls at all. Besides, would it not make sense to have an API function that gets the style bit field for any valid control and then leaves it up to the user to determine what the various bits mean? Maybe it should be called something like... ControlGetStyle()? The AutoIt Window Info app makes me think it should be possible, but I could be wrong. Anyway, thanks for the pointer PsaltyDS. Ed Link to comment Share on other sites More sharing options...
JohnBailey Posted August 2, 2007 Share Posted August 2, 2007 Does this help? http://msdn2.microsoft.com/en-us/library/ms672100.aspx A decision is a powerful thing Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 2, 2007 Share Posted August 2, 2007 (edited) Does this help? http://msdn2.microsoft.com/en-us/library/ms672100.aspxThat will set the value of that one Style attribute. But the original question was about reading ("Get") the Style. There is this: LVM_GETEXTENDEDLISTVIEWSTYLE Message for listview, but doesn't appear to be any equivalent for Edit controls, and as was pointed out, that appears to read only extended Style, with no command message fro regular Styles.Seems kind of arbitrary that some do and some don't. Edited August 2, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
JohnBailey Posted August 2, 2007 Share Posted August 2, 2007 That will set the value of that one Style attribute. But the original question was about reading ("Get") the Style. There is this: LVM_GETEXTENDEDLISTVIEWSTYLE Message for listview, but doesn't appear to be any equivalent for Edit controls.Seems kind of arbitrary that some do and some don't. Yeah, on both accounts. I have limited knowledge and just thought that it may help. I tried a few things, but I don't really understand how many things work. I just want to lend any information that might help.It doesn't make much sense on how come there isn't a command for GET. Maybe I should look through the source code for the SETStyle... do you know if that's a good idea to start there? A decision is a powerful thing Link to comment Share on other sites More sharing options...
ed0 Posted August 2, 2007 Author Share Posted August 2, 2007 Yeah, on both accounts. I have limited knowledge and just thought that it may help. I tried a few things, but I don't really understand how many things work. I just want to lend any information that might help.It doesn't make much sense on how come there isn't a command for GET. Maybe I should look through the source code for the SETStyle... do you know if that's a good idea to start there?Don't be too hard on yourself... that page you referred to had this nice bit: "To determine whether an edit control has the ES_READONLY style, use the GetWindowLong function with the GWL_STYLE flag."So it seems it is possible. I'm not that much of a Windows programmer myself, so I think I'll stick with my workaround (I'm trying to figure out which control is which on a pre-existing GUI, and since 'get style' is hard, I'm using position information instead). But this definitely looks like the right direction otherwise.Thanks,Ed Link to comment Share on other sites More sharing options...
JohnBailey Posted August 2, 2007 Share Posted August 2, 2007 Thanks for the encouragement. I'm very slowly catching on to the WinAPI stuff.Have you tried out ANYGui ?http://www.autoitscript.com/forum/index.ph...7&hl=AnyGui A decision is a powerful thing Link to comment Share on other sites More sharing options...
ed0 Posted August 2, 2007 Author Share Posted August 2, 2007 Thanks for the encouragement. I'm very slowly catching on to the WinAPI stuff.Have you tried out ANYGui ?http://www.autoitscript.com/forum/index.ph...7&hl=AnyGuiNo, but it looks like _TargetStyle() might do the trick! Thanks! I guess I should look at some other stuff in the Example Scripts forum, I've only used Auto3Lib so far.OK, that's not quite true... I tried to use LibCsv but had performance issues so I wrote my own CSV parser. I really should post it - it only reads CSV files but it is mighty quick.Thanks again,Ed Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 3, 2007 Share Posted August 3, 2007 Oh, wooooooOOOOOOW! How did I miss that? When you call quaizywabbit's _TargetStyle() with no parameters, it returns a 2-element array with both Style, and ExStyle. That is achieved basically by this: Local $ostyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $TargethWnd, "int", -16);get existing Style Local $oexstyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $TargethWnd, "int", -20);get existing ExStyle I'm going to try some testing demos to make sure I didn't just misunderstand in a whole new way here... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 3, 2007 Share Posted August 3, 2007 Demo done. This brings up a GUI with an edit control that has $ES_READONLY set for a style. The buttons display either the Style or ExStyle of the Edit control, and bit out the number so you can look up the values in the help file. expandcollapse popup#include <guiconstants.au3> #include <A3LConstants.au3> #include <A3LWinAPI.au3> Opt("GuiOnEventMode", 1) ; Create GUI $hGUI = GUICreate("Edit Styles Test", 600, 420) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") ; Add controls GUICtrlCreateEdit("", 10, 10, 580, 290, $ES_READONLY) $hEdit = GUICtrlGetHandle(-1) $Button_Style = GUICtrlCreateButton("Get Style", 120, 310, 120, 40) GUICtrlSetOnEvent(-1, "_ButtonHit") $Button_ExStyle = GUICtrlCreateButton("Get ExStyle", 360, 310, 120, 40) GUICtrlSetOnEvent(-1, "_ButtonHit") $Label_1 = GUICtrlCreateLabel("", 10, 360, 580, 50, $SS_CENTER) GUISetState() While 1 Sleep(20) WEnd Func _ButtonHit() Local $StyleWord Switch @GUI_CtrlId Case $Button_Style $StyleWord = _API_GetWindowLong ($hEdit, $GWL_STYLE) GUICtrlSetData($Label_1, "Current Style Of Edit Control: 0x" & Hex($StyleWord, 8) & @CRLF & "Bit breakdown: " & _BitItOut($StyleWord)) Case $Button_ExStyle $StyleWord = _API_GetWindowLong ($hEdit, $GWL_EXSTYLE) GUICtrlSetData($Label_1, "Extended Style Of Edit Control: 0x" & Hex($StyleWord, 8) & @CRLF & "Bit breakdown: " & _BitItOut($StyleWord)) EndSwitch EndFunc ;==>_ButtonHit Func _BitItOut($i) Local $RET = "", $b, $n For $b = 0 To 31 $n = 2 ^ $b If BitAND($i, $n) Then $RET &= $n & " = 0x" & Hex($n, 8) & ", " $i -= $n EndIf Next If StringRight($RET, 2) = ", " Then $RET = StringTrimRight($RET, 2) Return $RET EndFunc ;==>_BitItOut Func _Quit() Exit EndFunc ;==>_Quit It's amazing the things I didn't know! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
JohnBailey Posted August 3, 2007 Share Posted August 3, 2007 First of all, PsaltyDS of course you rock! I couldn't get API_GetWindowLong or the _TargetStyle to work for me. I did some testing but obviously I was missing things. I didn't know $GWL_STYLE was already defined! Thanks for posting this it was good to explore this with you guys. Good questioning!!! Not sure why this isn't a standard function in the standard UDFs. Secondly, ed0 I would REALLY like to see your CSV parser! I think you should post it in the example files. A decision is a powerful thing Link to comment Share on other sites More sharing options...
ed0 Posted August 3, 2007 Author Share Posted August 3, 2007 Secondly, ed0 I would REALLY like to see your CSV parser! I think you should post it in the example files.OK, I finally got around to posting it:http://www.autoitscript.com/forum/index.php?showtopic=50680Hope it works for someone...Ed 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