Sander Posted May 11, 2009 Share Posted May 11, 2009 I'm making a tiny script that will help getting the hex code of a color, im just doing it to learn and its my first program so i guess there will be alot of sloppy code So im trying to get it to show the hex in another window, Form2, when i press the key to get the hex, Form1 will close, and form 2 will open with the hex in input1. However when i try to make it so that when i press "Copy to clipboard" it exits form2 and re-enters form1 it just goes straight trough it without me needing to press anything, which means it goes right trough form2 without letting me do anything. The way i have it now both is there when i press the key and its kinda annoying expandcollapse popup#include-once #include <GUIConstants.au3> $version = "v1.1" $title = "PixelGet " $strek = " - " $helps = "Instructions" $Form1 = GUICreate($title & $version, 179, 157, 285, 227) GUISetFont(8, 800, 0, "MS Sans Serif") GUISetBkColor(0x000000) $Label1 = GUICtrlCreateLabel("PixelGet v1.0", 40, 0, 109, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) $Label3 = GUICtrlCreateLabel("Use:", 72, 24, 30, 17) GUICtrlSetColor(-1, 0x0000FF) $Label4 = GUICtrlCreateLabel("Hold you're mouse over", 24, 40, 137, 17) GUICtrlSetColor(-1, 0x00FF00) $Label5 = GUICtrlCreateLabel("what you want the hex code of", 16, 56, 155, 17) GUICtrlSetColor(-1, 0x00FF00) $Label6 = GUICtrlCreateLabel("and press F10 to get it.", 24, 72, 136, 17) GUICtrlSetColor(-1, 0x00FF00) $Label7 = GUICtrlCreateLabel("Hold down F9 for information", 8, 88, 167, 17) GUICtrlSetColor(-1, 0xFFFFFF) $Label8 = GUICtrlCreateLabel("Press ESC to exit the program!", 0, 104, 177, 17) GUICtrlSetColor(-1, 0xFF00FF) $Label9 = GUICtrlCreateLabel("MMOwned", 88, 128, 75, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) $Label2 = GUICtrlCreateLabel("Zordin @", 8, 128, 78, 17) GUICtrlSetColor(-1, 0xFFFF00) GUISetState(@SW_SHOW) HotKeySet("{F10}", "grab") HotKeySet("{ESC}", "foo") HotKeySet("{F9}", "help") While 1 Sleep(100) WEnd Func grab() $pos = MouseGetPos() $pixel_hex = '0x' & Hex(PixelGetColor($pos[0], $pos[1]), 6) $pixel_dec = Dec($pixel_hex) WinSetState($form1, '', @SW_HIDE) $Form2 = GUICreate("Hex Code:", 237, 82, 193, 125) $copy = GUICtrlCreateButton("Copy to Clipboard", 0, 40, 235, 41, 0) $Input1 = GUICtrlCreateInput($pixel_hex, 0, 0, 233, 45) GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) WinSetState($form2, '', @SW_SHOW) if $copy Then ClipPut(GuiCtrlread($input1)) WinSetState($form1, '', @SW_SHOW) EndIf Sleep(2000) ToolTip("") EndFunc ;==>grab Func foo() Exit EndFunc ;==>foo func help() if $helps then msgbox(48, "PixelGet v1.0 - Info", "This will help you get the hex codes of colors, its easy to use all you have to do it take the pointer over the color you want the hex code of and press F10. This was made by Zirdon at MMOwned") endif EndFunc Any1 here that can help out a newb? Link to comment Share on other sites More sharing options...
enaiman Posted May 11, 2009 Share Posted May 11, 2009 Func grab() $pos = MouseGetPos() $pixel_hex = '0x' & Hex(PixelGetColor($pos[0], $pos[1]), 6) $pixel_dec = Dec($pixel_hex) WinSetState($form1, '', @SW_HIDE) $Form2 = GUICreate("Hex Code:", 237, 82, 193, 125) $copy = GUICtrlCreateButton("Copy to Clipboard", 0, 40, 235, 41, 0) $Input1 = GUICtrlCreateInput($pixel_hex, 0, 0, 233, 45) GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) WinSetState($form2, '', @SW_SHOW) if $copy Then ClipPut(GuiCtrlread($input1)) WinSetState($form1, '', @SW_SHOW) ;here is your mistake EndIf Sleep(2000) ToolTip("") EndFunc ;==>grab Corrected function: Func grab() $pos = MouseGetPos() $pixel_hex = '0x' & Hex(PixelGetColor($pos[0], $pos[1]), 6) $pixel_dec = Dec($pixel_hex) WinSetState($form1, '', @SW_HIDE) $Form2 = GUICreate("Hex Code:", 237, 82, 193, 125) $copy = GUICtrlCreateButton("Copy to Clipboard", 0, 40, 235, 41, 0) $Input1 = GUICtrlCreateInput($pixel_hex, 0, 0, 233, 45) GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) WinSetState($form1, '', @SW_HIDE) WinSetState($form2, '', @SW_SHOW) if $copy Then ClipPut(GuiCtrlread($input1)) EndIf Sleep(2000) ToolTip("") EndFunc ;==>grab SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Sander Posted May 11, 2009 Author Share Posted May 11, 2009 (edited) Ok, some improvement Now the form1 doesnt show up after i get the color, but i want it so that when u press "Copy to Clipboard" it copies it, then exits form2 and enters form1 Edited May 11, 2009 by Sander Link to comment Share on other sites More sharing options...
Skruge Posted May 11, 2009 Share Posted May 11, 2009 First off, is it Zordin or Zirdon? You're not reading GUI messages or responding to GUI events, so that's why it's not doing what you expect. $copy is the handle to the button you created, so it's going to be non-zero. That means this line is always true, not just when you click the button:if $copy ThenTry this instead:Func grab() $pos = MouseGetPos() $pixel_hex = '0x' & Hex(PixelGetColor($pos[0], $pos[1]), 6) $pixel_dec = Dec($pixel_hex) WinSetState($Form1, '', @SW_HIDE) $Form2 = GUICreate("Hex Code:", 237, 82, 193, 125) $copy = GUICtrlCreateButton("Copy to Clipboard", 0, 40, 235, 41, 0) $Input1 = GUICtrlCreateInput($pixel_hex, 0, 0, 233, 45) GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) GUISetState(@SW_SHOW, $Form2) GUISwitch($Form2) ; Activate Second Form Do Until GUIGetMsg() = $copy ; Wait until button is pressed ClipPut(GUICtrlRead($Input1)) WinSetState($Form1, '', @SW_SHOW) GUIDelete($Form2) GUISwitch($Form1) ToolTip("") EndFunc ;==>grab Other suggestions: It's better to create the windows ahead of time and show/hide them as needed, so you don't leave any orphan windows behind. [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
Sander Posted May 11, 2009 Author Share Posted May 11, 2009 (edited) Thanks, that worked! Guess ill experiment with gui events It's Zordin, had a typo there xDOther suggestions: It's better to create the windows ahead of time and show/hide them as needed, so you don't leave any orphan windows behind.How do i do that? ^^ Edited May 11, 2009 by Sander 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