jennico Posted May 11, 2008 Posted May 11, 2008 hi there, i want to manipulate the _choosecolor() dialog window (change title, change label text). i would do this by starting another script which retrieves the "edit color" window. but how to retrieve it ? i do not want to use the title or text because my script is supposed to work in any language. i could pass a window definition or handle by using $cmdlineraw parameters to the second script. the autoit window tool gives me a class name ([CLASS:#32770]), but this class is not unique so i cannot use it. so anyone knows an alternative way ? maybe from within the basic script that calls _choosecolor() ? maybe from the comdlg32.dll ? any help appreciated. thx jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
jennico Posted May 11, 2008 Author Posted May 11, 2008 made an example script to make it clearer. it will only work in German because it uses the title name. expandcollapse popupIf StringInStr($cmdlineraw,"Farbe") Then ; $a=StringSplit(StringMid($cmdlineraw,StringInStr($cmdlineraw,"Farbe")),":") MsgBox(0,"My Example"," How do i get the handle to the second gui ?"&@LF&" ( without using the title ) ???") WinWait("Farbe","",10);[CLASS:#32770] WinSetTitle("Farbe",""," New Title ");English Title: 'Edit Color' Exit EndIf #include <GUIConstants.au3> #Include <Misc.au3> Opt("GUIOnEventMode", 1) GUICreate('Choose Color', 500, 500) GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit') GUICtrlCreateButton('Click me to choose a color!', 100, 200, 300, 30) GUICtrlSetOnEvent(-1, '_ChooseColorEvent') GUISetState() While 1 Sleep(300) WEnd Func _ChooseColorEvent() Run(@AutoItExe&' "'&@ScriptFullPath&'" Farbe:') $color = __ChooseColor(2, 255, 2, WinGetHandle('Choose Color','Click me to choose a color!')) GUISetBkColor($color) EndFunc ;==>_ChooseColorEvent Func _Exit() Exit EndFunc ;==>_Exit ;=============================================================================== ; ; Description: _ChooseColor ; Parameter(s): $i_ReturnType - Optional: determines return type ; $i_colorref - Optional: default selected Color ; $i_refType - Optional: Type of $i_colorref passed in ; Requirement: None ; Return Value(s): Returns COLORREF rgbcolor if $i_refType = 0 (default) ; Returns Hex RGB value if $i_refType = 1 ; Returns Hex BGR Color if $i_refType = 2 ; if error occurs, @error is set ; User CallTip: _ChooseColor([$i_ReturnType = 0[, $i_colorref = 0[, $i_refType=0]]]) Creates a Color dialog box that enables the user to select a color. (required: <Misc.au3>) ; Author(s): Gary Frost (custompcs at charter dot net) ; Note(s): $i_ReturnType = 0 then COLORREF rgbcolor is returned (default) ; $i_ReturnType = 1 then Hex BGR Color is returned ; $i_ReturnType = 2 Hex RGB Color is returned ; ; $i_colorref = 0 (default) ; ; $i_refType = 0 then $i_colorref is COLORREF rgbcolor value (default) ; $i_refType = 1 then $i_colorref is BGR hex value ; $i_refType = 2 then $i_colorref is RGB hex value ; ;=============================================================================== Func __ChooseColor($i_ReturnType = 0, $i_colorref = 0, $i_refType = 0, $h_wnd_owner = 0) ;~ typedef struct { ;~ DWORD lStructSize; ;~ HWND hwndOwner; ;~ HWND hInstance; ;~ COLORREF rgbResult; ;~ COLORREF *lpCustColors; ;~ DWORD Flags; ;~ LPARAM lCustData; ;~ LPCCHOOKPROC lpfnHook; ;~ LPCTSTR lpTemplateName; ;~ } CHOOSECOLOR, *LPCHOOSECOLOR; Local $custcolors = "int[16]" Local $struct = "dword;int;int;int;ptr;dword;int;ptr;ptr" Local $p = DllStructCreate($struct) If @error Then ;MsgBox(0,"","Error in DllStructCreate " & @error); SetError(-1) Return -1 EndIf Local $cc = DllStructCreate($custcolors) If @error Then ; MsgBox(0,"","Error in DllStructCreate " & @error); ; DllStructDelete ($p) SetError(-2) Return -1 EndIf If ($i_refType == 1) Then $i_colorref = Int($i_colorref) ElseIf ($i_refType == 2) Then $i_colorref = Hex(String($i_colorref), 6) $i_colorref = '0x' & StringMid($i_colorref, 5, 2) & StringMid($i_colorref, 3, 2) & StringMid($i_colorref, 1, 2) EndIf ConsoleWrite($h_wnd_owner & @LF) DllStructSetData($p, 1, DllStructGetSize($p)) DllStructSetData($p, 2, $h_wnd_owner) DllStructSetData($p, 4, $i_colorref) DllStructSetData($p, 5, DllStructGetPtr($cc)) DllStructSetData($p, 6, BitOR($CC_ANYCOLOR, $CC_FULLOPEN, $CC_RGBINIT)) Local $ret = DllCall("comdlg32.dll", "long", "ChooseColor", "ptr", DllStructGetPtr($p)) If ($ret[0] == 0) Then ; user selected cancel or struct settings incorrect ; DllStructDelete ($p) ; DllStructDelete ($cc) SetError(-3) Return -1 EndIf Local $color_picked = DllStructGetData($p, 4) ; DllStructDelete ($p) ; DllStructDelete ($cc) If ($i_ReturnType == 1) Then ; return Hex BGR Color Return '0x' & Hex(String($color_picked), 6) ElseIf ($i_ReturnType == 2) Then ; return Hex RGB Color $color_picked = Hex(String($color_picked), 6) Return '0x' & StringMid($color_picked, 5, 2) & StringMid($color_picked, 3, 2) & StringMid($color_picked, 1, 2) ElseIf ($i_ReturnType == 0) Then Return $color_picked Else SetError(-4) Return -1 EndIf EndFunc ;==>_ChooseColor Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
jennico Posted May 11, 2008 Author Posted May 11, 2008 well, i made it. the answer was more easy than the question. just wingettitle("") does it. (i hope this is secure enough.) expandcollapse popupIf StringInStr($cmdlineraw,"Farbe:") Then ; $a=StringSplit(StringMid($cmdlineraw,StringInStr($cmdlineraw,"Farbe")),":") $a=WinGetTitle("") ; WinWait("Farbe","",10);[CLASS:#32770] WinSetTitle($a,""," New Title ");English Title: 'Edit Color' MsgBox(0,$a," How do i get the handle to the second gui ?"&@LF&" ( without using the title ) ???"&@LF&@LF&" PROBLEM SOLVED !!!") Exit EndIf #include <GUIConstants.au3> #Include <Misc.au3> Opt("GUIOnEventMode", 1) GUICreate('Choose Color', 500, 500) GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit') GUICtrlCreateButton('Click me to choose a color!', 100, 200, 300, 30) GUICtrlSetOnEvent(-1, '_ChooseColorEvent') GUISetState() While 1 Sleep(300) WEnd Func _ChooseColorEvent() Run(@AutoItExe&' "'&@ScriptFullPath&'" Farbe:') $color = __ChooseColor(2, 255, 2, WinGetHandle('Choose Color','Click me to choose a color!')) GUISetBkColor($color) EndFunc ;==>_ChooseColorEvent Func _Exit() Exit EndFunc ;==>_Exit ;=============================================================================== ; ; Description: _ChooseColor ; Parameter(s): $i_ReturnType - Optional: determines return type ; $i_colorref - Optional: default selected Color ; $i_refType - Optional: Type of $i_colorref passed in ; Requirement: None ; Return Value(s): Returns COLORREF rgbcolor if $i_refType = 0 (default) ; Returns Hex RGB value if $i_refType = 1 ; Returns Hex BGR Color if $i_refType = 2 ; if error occurs, @error is set ; User CallTip: _ChooseColor([$i_ReturnType = 0[, $i_colorref = 0[, $i_refType=0]]]) Creates a Color dialog box that enables the user to select a color. (required: <Misc.au3>) ; Author(s): Gary Frost (custompcs at charter dot net) ; Note(s): $i_ReturnType = 0 then COLORREF rgbcolor is returned (default) ; $i_ReturnType = 1 then Hex BGR Color is returned ; $i_ReturnType = 2 Hex RGB Color is returned ; ; $i_colorref = 0 (default) ; ; $i_refType = 0 then $i_colorref is COLORREF rgbcolor value (default) ; $i_refType = 1 then $i_colorref is BGR hex value ; $i_refType = 2 then $i_colorref is RGB hex value ; ;=============================================================================== Func __ChooseColor($i_ReturnType = 0, $i_colorref = 0, $i_refType = 0, $h_wnd_owner = 0) ;~ typedef struct { ;~ DWORD lStructSize; ;~ HWND hwndOwner; ;~ HWND hInstance; ;~ COLORREF rgbResult; ;~ COLORREF *lpCustColors; ;~ DWORD Flags; ;~ LPARAM lCustData; ;~ LPCCHOOKPROC lpfnHook; ;~ LPCTSTR lpTemplateName; ;~ } CHOOSECOLOR, *LPCHOOSECOLOR; Local $custcolors = "int[16]" Local $struct = "dword;int;int;int;ptr;dword;int;ptr;ptr" Local $p = DllStructCreate($struct) If @error Then ;MsgBox(0,"","Error in DllStructCreate " & @error); SetError(-1) Return -1 EndIf Local $cc = DllStructCreate($custcolors) If @error Then ; MsgBox(0,"","Error in DllStructCreate " & @error); ; DllStructDelete ($p) SetError(-2) Return -1 EndIf If ($i_refType == 1) Then $i_colorref = Int($i_colorref) ElseIf ($i_refType == 2) Then $i_colorref = Hex(String($i_colorref), 6) $i_colorref = '0x' & StringMid($i_colorref, 5, 2) & StringMid($i_colorref, 3, 2) & StringMid($i_colorref, 1, 2) EndIf ConsoleWrite($h_wnd_owner & @LF) DllStructSetData($p, 1, DllStructGetSize($p)) DllStructSetData($p, 2, $h_wnd_owner) DllStructSetData($p, 4, $i_colorref) DllStructSetData($p, 5, DllStructGetPtr($cc)) DllStructSetData($p, 6, BitOR($CC_ANYCOLOR, $CC_FULLOPEN, $CC_RGBINIT)) Local $ret = DllCall("comdlg32.dll", "long", "ChooseColor", "ptr", DllStructGetPtr($p)) If ($ret[0] == 0) Then ; user selected cancel or struct settings incorrect ; DllStructDelete ($p) ; DllStructDelete ($cc) SetError(-3) Return -1 EndIf Local $color_picked = DllStructGetData($p, 4) ; DllStructDelete ($p) ; DllStructDelete ($cc) If ($i_ReturnType == 1) Then ; return Hex BGR Color Return '0x' & Hex(String($color_picked), 6) ElseIf ($i_ReturnType == 2) Then ; return Hex RGB Color $color_picked = Hex(String($color_picked), 6) Return '0x' & StringMid($color_picked, 5, 2) & StringMid($color_picked, 3, 2) & StringMid($color_picked, 1, 2) ElseIf ($i_ReturnType == 0) Then Return $color_picked Else SetError(-4) Return -1 EndIf EndFunc ;==>_ChooseColor thx anyway for annoying (funny, i never get any answer in this forum) :-( j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
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