Fossil Rock Posted June 18, 2006 Share Posted June 18, 2006 Is there an easy way to test when an image is clicked on? I specifically want to be able to determine which image is clicked on out of several images. I'm working on a card game where all the cards are face down and when you click on a card it will flip over to reveal what it is. This is still in the concept stage, so I don't have much code to show. Thanks Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
Valuater Posted June 18, 2006 Share Posted June 18, 2006 $pic = guictrlcreatepic() while 1 $msg = guigetmsg() if $msg = $pic then ; do something 8) Link to comment Share on other sites More sharing options...
Fossil Rock Posted June 18, 2006 Author Share Posted June 18, 2006 Thanks ... I'll give it a shot. Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
Fossil Rock Posted June 18, 2006 Author Share Posted June 18, 2006 This isn't very smooth, can you give me hint as too way? #include <GUIConstants.au3> $C1 = "C:\Documents and Settings\All Users\Documents\Playing Cards\Card.gif"; Use any graphic $C2 = "C:\Documents and Settings\All Users\Documents\Playing Cards\Cardback.gif"; Use any graphic $C = $C2 $Form1 = GUICreate("Match Card Game", 251, 149, 413, 306) $Pic1 = GUICtrlCreatePic($C, 32, 24, 40, 56, BitOR($SS_NOTIFY,$WS_GROUP)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() $msg = GUIGetMsg($GUI_EVENT_PRIMARYDOWN) Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch Switch $msg = $Pic1 Case $C = $C1 $C = $C2 Case $C = $C2 $C = $C1 EndSwitch GUICtrlSetImage($Pic1,$C) WEnd Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 18, 2006 Moderators Share Posted June 18, 2006 Hmm, I can say that that makes no sense lol... what is this:$nMsg = GUIGetMsg() $msg = GUIGetMsg($GUI_EVENT_PRIMARYDOWN)? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Fossil Rock Posted June 18, 2006 Author Share Posted June 18, 2006 (edited) $nMsg = GUIGetMsg() - checks for close event $msg = GUIGetMsg($GUI_EVENT_PRIMARYDOWN) - supposed to check for the mouse click down guess it works with or without $GUI_EVENT_PRIMARYDOWN Edited June 18, 2006 by Fossil Rock Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 18, 2006 Moderators Share Posted June 18, 2006 (edited) $nMsg = GUIGetMsg() - checks for close event $msg = GUIGetMsg($GUI_EVENT_PRIMARYDOWN) - supposed to check for the mouse click down guess it works with or without $GUI_EVENT_PRIMARYDOWNWell $nMsg is going to be the same as $Msg, to check if $GUI_EVENT_PRIMARYDOWN was used you would do something like: $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $GUI_EVENT_PRIMARYDOWN ;Do something Case $nMsg = $Pic1 ;Do something EndSelectYou only need one GUIGetMsg() Edit: Maybe you were trying for this type of affect?#include <GUIConstants.au3> Global $Down Dim $CardUp = @DocumentsCommonDir & '\My Pictures\Sample Pictures\Sunset.jpg';"C:\Documents and Settings\All Users\Documents\Playing Cards\Card.gif"; Use any graphic Dim $CardDown = @DocumentsCommonDir & '\My Pictures\Sample Pictures\Blue hills.jpg';"C:\Documents and Settings\All Users\Documents\Playing Cards\Cardback.gif"; Use any graphic $Form1 = GUICreate("Match Card Game") $Pic1 = GUICtrlCreatePic($CardDown, 10, 10, 300, 300) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = - 3 Exit Case $msg = $Pic1 $Down = Not $Down If $Down Then GUICtrlDelete($Pic1) $Pic1 = GUICtrlCreatePic($CardUp, 10, 10, 300, 300) Else GUICtrlDelete($Pic1) $Pic1 = GUICtrlCreatePic($CardDown, 10, 10, 300, 300) EndIf EndSelect WEnd Edited June 18, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Fossil Rock Posted June 18, 2006 Author Share Posted June 18, 2006 Thanks Smoke, It helped me understand better what I was doing and trying to accomplish. This works much better, but still has a lag in it .... #include <GUIConstants.au3> $C1 = "C:\Documents and Settings\All Users\Documents\Playing Cards\2C.gif" $C2 = "C:\Documents and Settings\All Users\Documents\Playing Cards\Cardback.bmp" $C = $C2 $Form1 = GUICreate("Match Card Game", 251, 149, 413, 306) $Pic1 = GUICtrlCreatePic($C, 32, 24, 40, 56, BitOR($SS_NOTIFY,$WS_GROUP)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Pic1 Select Case $C = $C1 $C = $C2 GUICtrlSetImage($Pic1,$C) Case $C = $C2 $C = $C1 GUICtrlSetImage($Pic1,$C) EndSelect EndSelect WEnd Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
Fossil Rock Posted June 18, 2006 Author Share Posted June 18, 2006 (edited) Well $nMsg is going to be the same as $Msg, to check if $GUI_EVENT_PRIMARYDOWN was used you would do something like: $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $GUI_EVENT_PRIMARYDOWN ;Do something Case $nMsg = $Pic1 ;Do something EndSelectYou only need one GUIGetMsg() Edit: Maybe you were trying for this type of affect?#include <GUIConstants.au3> Global $Down Dim $CardUp = @DocumentsCommonDir & '\My Pictures\Sample Pictures\Sunset.jpg';"C:\Documents and Settings\All Users\Documents\Playing Cards\Card.gif"; Use any graphic Dim $CardDown = @DocumentsCommonDir & '\My Pictures\Sample Pictures\Blue hills.jpg';"C:\Documents and Settings\All Users\Documents\Playing Cards\Cardback.gif"; Use any graphic $Form1 = GUICreate("Match Card Game") $Pic1 = GUICtrlCreatePic($CardDown, 10, 10, 300, 300) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = - 3 Exit Case $msg = $Pic1 $Down = Not $Down If $Down Then GUICtrlDelete($Pic1) $Pic1 = GUICtrlCreatePic($CardUp, 10, 10, 300, 300) Else GUICtrlDelete($Pic1) $Pic1 = GUICtrlCreatePic($CardDown, 10, 10, 300, 300) EndIf EndSelect WEnd uh, yep .... thanks EDIT: your's is much faster ... thanks Edited June 18, 2006 by Fossil Rock Agreement is not necessary - thinking for one's self is! 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