Jump to content

Can't close gui


Recommended Posts

I added a color picker to the analog clock project from Scripts and Scraps, but when I try to close the color picker, it will not close. It seems to be due to the fact that it is a gui that is launched from another gui. It is now fixed. To test it you would run the clock program and then right click the clock and choose "Change face color".

Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

You trying to use loop in your function, though script is in onevent mode. Use Opt("GUIOnEventMode", 0) to switch to loop mode.

BTW, why not use standard Windows color choose function? This will save bunch of code lines.

Edited by Lazycat
Link to comment
Share on other sites

BTW, why not use standard Windows color choose function? This will save bunch of code lines.

What would that look like?
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

What would that look like?

Try this function:

$nColor = 0x00FF00 ; initial color
_ChooseColor(0,  $nColor)
MsgBox (0, "Color", "0x"&Hex($nColor, 6))

Func _ChooseColor($hWnd, ByRef $nColor)
    $cp = DllStructCreate("dword[16]")
    $p = DllStructCreate("dword;dword;dword;dword;dword;dword;dword;dword;dword")
    DllStructSetData($p, 1, DllStructGetSize($p))
    DllStructSetData($p, 2, $hWnd)
    DllStructSetData($p, 4, $nColor)
    DllStructSetData($p, 5, DllStructGetPtr($cp))
    DllStructSetData($p, 6, 2 + 1)
    $ret = DllCall("comdlg32.dll", "long", "ChooseColorA", "ptr", DllStructGetPtr($p))
    If IsArray($ret) and $ret[0] <> 0 Then $nColor = DllStructGetData($p, 4)
EndFunc

$hWnd - handle of parent GUI, $nColor - variable with color. Function take color from this var as default and change it if user choose OK.

Link to comment
Share on other sites

Try this function:

Thanks LazyCat and Chris95219- I'll try those ideas out right away. Also, LazyCat, thanks for the tip on GuiEvent mode. It took me a while to get it, but the script works. During my color picker function, I change event mode to "while", and then change it back to "event driven" when I leave my function.

This was another perfect case of me trying to do something the hard way when AutoIT already had the function built-in! I have read the manual from top to bottom several times, and I still am surprised by the hidden treasures that others point out to me with AutoIT...

Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...