Indigo Posted March 15, 2009 Share Posted March 15, 2009 I am trying to automate a login process, but the screen I see while logging in does not register any pixel colors. All PixelGetColor(x,y) return white for the entire window. The screen does some checking for updates and the login button is disabled until the updates are complete. This update process can take 15 second or several minutes. The only difference I can see between disabled and enabled is the Control's Style property changes from 0x5E00000D (disabled) to 0x5600000D (enabled). How can I access this property from my AutoIt script?I have the handle to the button(/image):$handle = ControlGetHandle("Magic Online", "", "[CLASS:WindowsForms10.STATIC.app.0.378734a; INSTANCE:3]") Link to comment Share on other sites More sharing options...
trancexx Posted March 15, 2009 Share Posted March 15, 2009 Something like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $hButton1, $hButton2, $hButton3, $iIs, $iStyle GUICreate("GUI", -1, 120) $hButton1 = GUICtrlCreateButton("Check State", 10, 30, 110) $hButton2 = GUICtrlCreateButton("Change Style/State", 10, 70, 110) $hButton3 = GUICtrlCreateButton("Test Button", 200, 40, 130, 40) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton1 $iStyle = _GetWindowStyle(GUICtrlGetHandle($hButton3)) ConsoleWrite("Style of Test Button " & Ptr($iStyle) & @CRLF) If BitAND($iStyle, $WS_DISABLED) Then MsgBox(64, "Test Button is...", "Disabled") Else MsgBox(64, "Test Button is...", "Enabled") EndIf Case $hButton2 If $iIs Then GUICtrlSetState($hButton3, $GUI_ENABLE) $iIs = False Else GUICtrlSetState($hButton3, $GUI_DISABLE) $iIs = True EndIf Case $hButton3 ; nothing EndSwitch WEnd Func _GetWindowStyle($hWnd) Local $a_iCall = DllCall("user32.dll", "int", "GetWindowLong", _ "hwnd", $hWnd, _ "int", -16) ; GWL_STYLE If @error Or Not $a_iCall[0] Then Return SetError(1, 0, 0) EndIf Return SetError(0, 0, $a_iCall[0]) EndFunc ;==>_GetWindowStyle ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Indigo Posted March 16, 2009 Author Share Posted March 16, 2009 trancexx, Thanks for the quick reply. I attempted to add your _GetWindowStyle function to my code. Attached is a screen print of the results. As you can see this application is far from a normal windows program, but somehow the AutoIt Windows Info application can see the Style of it. It seems as if I am getting the correct handle for the control, but the _GetWindowStyle simply return 0x00000000. I would appreciate any further thought you might have on the subject. Indigo Link to comment Share on other sites More sharing options...
Indigo Posted March 16, 2009 Author Share Posted March 16, 2009 ooops, the image would help... #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $handle, $iStyle, $Paused ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; HotKeySet("^{PAUSE}", "Terminate") HotKeySet("{PAUSE}", "TogglePause") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Run("C:\Program Files\Wizards of the Coast\Magic Online III\Renamer.exe", "C:\Program Files\Wizards of the Coast\Magic Online III") WinActivate("Magic Online") WinActive("Magic Online") Do Sleep(500) $handle = ControlGetHandle("Magic Online", "", "[CLASS:WindowsForms10.STATIC.app.0.378734a; INSTANCE:3]") Until @error = 0 Sleep(1000) ConsoleWrite("Handle " & Ptr($handle) & @CRLF) Do $iStyle = _GetWindowStyle(GUICtrlGetHandle($handle)) ConsoleWrite("Style " & Ptr($iStyle) & @CRLF) Sleep(2000) Until $iStyle = 0x5600000D msgbox(0,"autoit", $iStyle) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _GetWindowStyle($hWnd) Local $a_iCall = DllCall("user32.dll", "int", "GetWindowLong", _ "hwnd", $hWnd, _ "int", -16) ; GWL_STYLE If @error Or Not $a_iCall[0] Then Return SetError(1, 0, 0) EndIf Return SetError(0, 0, $a_iCall[0]) EndFunc ;==>_GetWindowStyle Link to comment Share on other sites More sharing options...
Authenticity Posted March 16, 2009 Share Posted March 16, 2009 Try to call it with the handle without GuiCtrlGetHandle, just with the handle you got: $iStyle = _GetWindowStyle($handle) Link to comment Share on other sites More sharing options...
NinjaJeff Posted January 16, 2010 Share Posted January 16, 2010 Something like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $hButton1, $hButton2, $hButton3, $iIs, $iStyle GUICreate("GUI", -1, 120) $hButton1 = GUICtrlCreateButton("Check State", 10, 30, 110) $hButton2 = GUICtrlCreateButton("Change Style/State", 10, 70, 110) $hButton3 = GUICtrlCreateButton("Test Button", 200, 40, 130, 40) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton1 $iStyle = _GetWindowStyle(GUICtrlGetHandle($hButton3)) ConsoleWrite("Style of Test Button " & Ptr($iStyle) & @CRLF) If BitAND($iStyle, $WS_DISABLED) Then MsgBox(64, "Test Button is...", "Disabled") Else MsgBox(64, "Test Button is...", "Enabled") EndIf Case $hButton2 If $iIs Then GUICtrlSetState($hButton3, $GUI_ENABLE) $iIs = False Else GUICtrlSetState($hButton3, $GUI_DISABLE) $iIs = True EndIf Case $hButton3 ; nothing EndSwitch WEnd Func _GetWindowStyle($hWnd) Local $a_iCall = DllCall("user32.dll", "int", "GetWindowLong", _ "hwnd", $hWnd, _ "int", -16) ; GWL_STYLE If @error Or Not $a_iCall[0] Then Return SetError(1, 0, 0) EndIf Return SetError(0, 0, $a_iCall[0]) EndFunc ;==>_GetWindowStyle I am having the exact same problem with an automated login script for Magic Online. The Launch Button is not enabled until the downloads are complete. AutoIt v3 Window Info detects only one change in the properties of the control. The style changes from 0x5E00000D (disabled) to 0x5600000D (enabled). However, when I use DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -16) to get that value, it returns 0x5600000D whether the control is actually enabled or not. I also tried to use PixelChecksum() to test for the change in the pixels when the button goes from grayed to not grayed, but PixelCheckSum() seems to completely ignore the Magic Online window. I've exhausted my ideas. Any help would be appreciated. Link to comment Share on other sites More sharing options...
NinjaJeff Posted January 19, 2010 Share Posted January 19, 2010 bump please help me. Link to comment Share on other sites More sharing options...
NinjaJeff Posted January 24, 2010 Share Posted January 24, 2010 bump for great justice Link to comment Share on other sites More sharing options...
NinjaJeff Posted January 29, 2010 Share Posted January 29, 2010 Still can't do it. Link to comment Share on other sites More sharing options...
Sam83 Posted August 9, 2010 Share Posted August 9, 2010 (edited) Hi,I encountered the same problem (I couldn't get the correct value with the above function) and found a solution so I post it here in case it can help anyone.I wrote this little function (quick & dirty) that uses the GetWindowInfo function of user32.dll (MSDN GetWindowInfo).It can be improved by adding error control, but it shows you how to get the info you want.You must use the handle to your control as parameter (e.g. with ControlGetHandle). It returns the style value as it can be seen in Au3info, but you can change it to get the ExStyle or anything else returned by GetWindowInfo.$hnd = ControlGetHandle('MyWindow', '', 'MyButton') GetButtonStyle($hnd) Func GetButtonStyle($handle) Local $PWINDOWINFO = "DWORD cbSize;" & _ "LONG left1;" & _ "LONG top1;" & _ "LONG right1;" & _ "LONG bottom1;" & _ "LONG left2;" & _ "LONG top2;" & _ "LONG right2;" & _ "LONG bottom2;" & _ "DWORD dwStyle;" & _ "DWORD dwExStyle;" & _ "DWORD dwWindowStatus;" & _ "UINT cxWindowBorders;" & _ "UINT cyWindowBorders;" & _ "UINT atomWindowType;" & _ "WORD wCreatorVersion;" Local $Struct = DllStructCreate($PWINDOWINFO) DllCall("user32.dll", "int", "GetWindowInfo", "hwnd", $hnd, "ptr", DllStructGetPtr($Struct)) Return Hex(DllStructGetData($Struct, "dwStyle")) EndFunc Edited August 9, 2010 by Sam83 n3250 1 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