Jump to content
Sign in to follow this  
CounterSpell

Program improvement

Recommended Posts

CounterSpell

As you can probable see ive been registered for 2 minutes lol but i have been reading the forums for 3 days. I am making a large program but for it I needed an odd smaller program and i couldn't find where anyone had make it. Now I take to computer languages very quickly (learned most of c++ in 1.5 weeks) so im becoming better every hour with this programming. Hopefully these will be the only types of posts you should see. Now on to the program.

What it does:

gets me coordinates and pixel color.

Options that i have enabled:

stores the info it collects in clipboard when you press the shortcut key. (all the info, so if you press the shortcut 5 times and then paste the info, it will give you all 5.)

Allows for all 3 types of mouse coodinates you select the one you want.

Displays the info that will be placed into the clipboard.

Let me know:

of improvements i can make

if there is a better version already made

if you can break it

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <GUIConstants.au3>
HotKeySet("^5", "record");Ctrl + 5
Dim $cood
Dim $var
Dim $clip_mesg_no
$cood = MouseGetPos()
$var = PixelGetColor($cood[0], $cood[1])
GUICreate("Coodinate Finder", 200, 100)
Local $statuslabel, $statuslabel2, $statuslabel3, $defaultstatus = "press ctrl and 5 to record info",$defaultstatus2 = "stores all in clipboard until program ended", $status, $msg, $checkCN
        $statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 0, 200, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))
        $checkCN1 = GUICtrlCreateCheckbox ("Relative coord when checked", 0, 16, 200, 16)
        $checkCN3 = GUICtrlCreateCheckbox ("Absolute coord when checked", 0, 32, 200, 16)
        $checkCN2 = GUICtrlCreateCheckbox ("Client coord when checked", 0, 46, 200, 16)
        $statuslabel2 = GUICtrlCreateLabel($defaultstatus, 0, 62, 200, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))
        $statuslabel3 = GUICtrlCreateLabel($defaultstatus2, 0, 78, 200, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))

GUISetState ()
While 1
$msg = GUIGetMsg()
if GUICtrlRead ($checkCN1) = "1" Then
    GUICtrlSetState($checkCN3, $GUI_UNCHECKED)
    GUICtrlSetState($checkCN2, $GUI_UNCHECKED)
Opt("MouseCoordMode", 0)
EndIf
if GUICtrlRead ($checkCN3) = "1" then
    GUICtrlSetState($checkCN1, $GUI_UNCHECKED)
    GUICtrlSetState($checkCN2, $GUI_UNCHECKED)
Opt("MouseCoordMode", 1)    
EndIf
if GUICtrlRead ($checkCN2) = "1" then
    GUICtrlSetState($checkCN3, $GUI_UNCHECKED)
    GUICtrlSetState($checkCN1, $GUI_UNCHECKED)
Opt("MouseCoordMode", 1)    
EndIf
if $cood <> MouseGetPos() then
$cood = MouseGetPos()
$var = PixelGetColor($cood[0], $cood[1])
GUICtrlSetData ( $statuslabel, "Coordinates's: " & $cood[0] & "," & $cood[1] & " Color: " & $var)
EndIf

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Func record()
    if $clip_mesg_no = "" Then
        $clip_mesg_no = "Coordinates's: " & $cood[0] & "," & $cood[1] & " Color: " & $var
    Else
        $clip_mesg_no =$clip_mesg_no & @CRLF & "Coordinates's: " & $cood[0] & "," & $cood[1] & " Color: " & $var
    EndIf
ClipPut($clip_mesg_no)
EndFunc

Share this post


Link to post
Share on other sites
storme

G'day CounterSpell

Very nice little util.

Suggestions

Use Radio buttons instead of check boxes. You can only select one at a time so it's a logical choice.

Also show the colour code in HEX. Lots of routines use HEX notation.

Add a text window and put the results in there as well as the clip board. It would be easier to cut adn paste just what is needed (ie Colour Code).

But these are only additions the script works very well that way it is. :-)

John Morrison

aka

Storm-E

Share this post


Link to post
Share on other sites
CounterSpell

thanks for your reply!

I wanted to use radio buttons but i already had premade code for checkboxes so that was me being lazy lol (if i decide to post this in the script examples, I will change it)

As for hex not sure how to implement this yet... Although I will figure it out! And your right I know i would like hex.

The text window is a good idea i could seperate the colour from the coord and allow you to just take one then but still have it auto post to the clipboard, as it does now, if your grabbing a bunch of stuff.

Thanks for the suggestions keep em comming!

Share this post


Link to post
Share on other sites
GodlessSinner

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <GUIConstants.au3>
Opt("MouseCoordMode", 0)
HotKeySet("^5", "record");Ctrl + 5
;Dim $cood
Dim $var
Dim $clip_mesg_no
$cood = MouseGetPos()
$var = PixelGetColor($cood[0], $cood[1])
$form = GUICreate("Coodinate Finder", 200, 100)
Local $cood[3], $temp[3]

Local $statuslabel, $statuslabel2, $statuslabel3, $defaultstatus = "press ctrl and 5 to record info",$defaultstatus2 = "stores all in clipboard until program ended", $status, $msg, $checkCN
        $statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 0, 200, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))
        $checkCN1 = GUICtrlCreateRadio ("Relative coord when checked", 0, 16, 200, 16)
        GUICtrlSetState($checkCN1, $GUI_CHECKED)
        $checkCN3 = GUICtrlCreateRadio("Absolute coord when checked", 0, 32, 200, 16)
        $checkCN2 = GUICtrlCreateRadio ("Client coord when checked", 0, 46, 200, 16)
        $statuslabel2 = GUICtrlCreateLabel($defaultstatus, 0, 62, 200, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))
        $statuslabel3 = GUICtrlCreateLabel($defaultstatus2, 0, 78, 200, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))

GUISetState ()
WinSetOnTop($form, "", 1)
While 1
;Sleep(100)
$msg = GUIGetMsg()
Switch $msg

Case $checkCN1
Opt("MouseCoordMode", 0)
Case $checkCN2
Opt("MouseCoordMode", 1)
    Case $checkCN3
Opt("MouseCoordMode", 2)

Case $GUI_EVENT_CLOSE
    Exit

EndSwitch

$cood = MouseGetPos()
If $temp[0] <> $cood[0] And $temp[1] <> $cood[1] Then
    $temp[0] = $cood[0] And $temp[1] = $cood[1]
$var = Hex(PixelGetColor($cood[0], $cood[1]))
;MsgBox(0,$cood[0] & ":" & $cood[1], $temp[0] & ":" & $temp[1])
GUICtrlSetData ( $statuslabel, "Coordinates's: " & $cood[0] & "," & $cood[1] & " Color: " & $var)
EndIf

Wend

Func record()
    if $clip_mesg_no = "" Then
        $clip_mesg_no = "Coordinates's: " & $cood[0] & "," & $cood[1] & " Color: " & $var
    Else
        $clip_mesg_no =$clip_mesg_no & @CRLF & "Coordinates's: " & $cood[0] & "," & $cood[1] & " Color: " & $var
    EndIf
ClipPut($clip_mesg_no)
EndFunc

(Works, but i don't know WHY $temp[0] ALWAYS = FALSE And $temp[1] ALWAYS = "")

Edited by Godless

_____________________________________________________________________________

Share this post


Link to post
Share on other sites
CounterSpell

the reason why your returning wrong values when you cehck the temps is because of the code below when the messagebox pops you didnt have anything in temps yet so 0 will appear in the first one and since the first one was not used yet then the 2nd one appears blank.

$temp[0] = $cood[0] And $temp[1] = $cood[1]
$var = Hex(PixelGetColor($cood[0], $cood[1]))

Switch these 2 lines around and you would not have an issue.

Now i have a few questions you set temp to 3 and cood to 3 was this abitrary or did you actually think you would need 3 as your only using 0 and 1. (I need this explained to further my understanding)

Thanx for cleaning it up abit it allows me to see other ways to do things. btw what is the diff between a case and an if statment? (other than being easier to read and less typing)

You also set it to always be pinned to top wich can be nice at least that what i think winsetontop() does.

and last but not least thanx for showing me how to change it to hex.

Share this post


Link to post
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
Sign in to follow this  

×