Diana (Cda) Posted November 16, 2008 Share Posted November 16, 2008 (edited) I found this today: http://www.autoitscript.com/forum/index.ph...07&hl=bingo which is great. Every Christmas I try to come up with something fun for the family to do. Since we're playing Bingo at the office and half of our $2 cost to play is going to charity, it's gotten me interested in this as this year's game. But I haven't been able to find any freeware card creators so this script is doubly a godsend. I added a "New Card" button which seems to reliably create a new card each time it's pressed. It's the "Send to clipboard" I don't know how to do. Ideally, that button will send a graphical representation of the card to the clipboard or, perhaps, will just automatically create a file on the desktop with an automatic sequential # attached to a generic name. I don't know. The rest are details. It's just to know if AI can generate an image of the interface.Here's the modified script, which I've renamed "Bingo Card Creator.au3":expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> ;========================================================================= ;Global Const $GUI_EVENT_CLOSE = -3 ; by using this constant, could leave out reference to "#include <GUIConstants.au3>", which in turn referenced this variable, with this exact value, from "GUIConstantsEx.au3" GUISetOnEvent($GUI_EVENT_CLOSE, "Close") ; "X" closes app, line "Global Const $GUI_EVENT_CLOSE = -3" above. / You need to have a "Func Close()" below ;--------------------------------------- Opt("GUIOnEventMode", 1) Global $sType = 1 Global $sCard[5][5] Global $sChose[5][5] $sChose[2][2] = 1 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 633, 535, 193, 115) ;--------------------------------------- ; Buttons: $Button1 = GUICtrlCreateButton("New Card", 410, 495, 80, 25, 0) GUICtrlSetOnEvent(-1, "NewCard_Click") $Clipboard = GUICtrlCreateButton("Image to Clipboard", 500, 495, 105, 25, 0) GUICtrlSetOnEvent(-1, "ToClipboard_Click") ;--------------------------------------- GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Form1) ; put this in so that no need to have UDF present when compiling ;--------------------------------------- GUISetFont(28, 800, 0, "Tahoma", $Form1) GUISetBkColor(0xFFFFFF, $Form1) ;-=-B-=- GUICtrlCreateLabel("B", 104, 8, 48, 81) GUICtrlSetFont(-1, 48, 800, 0, "Tahoma") $sCard[0][0] = GUICtrlCreateLabel("", 88, 96, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[0][1] = GUICtrlCreateLabel("", 88, 176, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[0][2] = GUICtrlCreateLabel("", 88, 256, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[0][3] = GUICtrlCreateLabel("", 88, 336, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[0][4] = GUICtrlCreateLabel("", 88, 416, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") ;-=-I-=- GUICtrlCreateLabel("I", 192, 8, 35, 81) GUICtrlSetFont(-1, 48, 800, 0, "Tahoma") $sCard[1][0] = GUICtrlCreateLabel("", 168, 96, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[1][1] = GUICtrlCreateLabel("", 168, 176, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[1][2] = GUICtrlCreateLabel("", 168, 256, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[1][3] = GUICtrlCreateLabel("", 168, 336, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[1][4] = GUICtrlCreateLabel("", 168, 416, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") ;-=-N-=- GUICtrlCreateLabel("N", 264, 8, 53, 81) GUICtrlSetFont(-1, 48, 800, 0, "Tahoma") $sCard[2][0] = GUICtrlCreateLabel("", 248, 96, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[2][1] = GUICtrlCreateLabel("", 248, 176, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[2][2] = GUICtrlCreateLabel("FREE", 248, 256, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFFFF00) GUICtrlSetOnEvent(-1, "NumPick") GUICtrlSetFont(-1, 20, 800, 0, "Tahoma") $sCard[2][3] = GUICtrlCreateLabel("", 248, 336, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[2][4] = GUICtrlCreateLabel("", 248, 416, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") ;-=-G-=- GUICtrlCreateLabel("G", 344, 8, 52, 81) GUICtrlSetFont(-1, 48, 800, 0, "Tahoma") $sCard[3][0] = GUICtrlCreateLabel("", 328, 96, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[3][1] = GUICtrlCreateLabel("", 328, 176, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[3][2] = GUICtrlCreateLabel("", 328, 256, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[3][3] = GUICtrlCreateLabel("", 328, 336, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[3][4] = GUICtrlCreateLabel("", 328, 416, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") ;-=-O-=- GUICtrlCreateLabel("O", 421, 10, 53, 81) GUICtrlSetFont(-1, 48, 800, 0, "Tahoma") $sCard[4][0] = GUICtrlCreateLabel("", 408, 96, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[4][1] = GUICtrlCreateLabel("", 408, 176, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[4][2] = GUICtrlCreateLabel("", 408, 256, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[4][3] = GUICtrlCreateLabel("", 408, 336, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $sCard[4][4] = GUICtrlCreateLabel("", 408, 416, 80, 80, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetOnEvent(-1, "NumPick") $i = 1 For $r = 0 To 4 Step 1 For $c = 0 To 4 Step 1 If $r = 2 AND $c = 2 Then ContinueLoop While 1 $a = Round(Random($i, $i+14),0) For $z = 0 To 4 Step 1 If GUICtrlRead($sCard[$r][$z]) = $a Then ContinueLoop 2 Next ExitLoop WEnd GUICtrlSetData($sCard[$r][$c], $a) Next $i += 15 Next GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func NumPick () If @GUI_CtrlId = $sCard[2][2] Then Return While 1 For $r = 0 To 4 Step 1 For $c = 0 To 4 Step 1 If $sCard[$r][$c] = @GUI_CtrlId Then Local $sP = _ArrayCreate($r, $c, GUICtrlRead(@GUI_CtrlId)) ExitLoop 3 EndIf Next Next Return 0 WEnd If $sChose[$sP[0]][$sP[1]] = 0 Then GUICtrlSetBkColor(@GUI_CtrlId, 0xFFFF00) $sChose[$sP[0]][$sP[1]] = 1 ElseIf $sChose[$sP[0]][$sP[1]] = 1 Then GUICtrlSetBkColor(@GUI_CtrlId, 0xFFFFFF) $sChose[$sP[0]][$sP[1]] = 0 EndIf Check () EndFunc Func Check () Local $sNum For $r = 0 To 4 Step 1 For $c = 0 To 4 Step 1 If $sChose[$r][$c] = 0 Then ExitLoop If $c = 4 Then For $i = 0 To 4 GUICtrlSetBkColor($sCard[$r][$i], 0x0000FF) $sNum &= GUICtrlRead($sCard[$r][$i]) & ", " Next $sNum = StringTrimRight($sNum, 2) MsgBox(1, "BINGO", "You have a BINGO!" & @CRLF & "The numbers on row " & _NumToLet($r) & " Numbers " & $sNum) Reset () EndIf Next Next For $c = 0 To 4 Step 1 For $r = 0 To 4 Step 1 If $sChose[$r][$c] = 0 Then ExitLoop If $r = 4 Then For $i = 0 To 4 GUICtrlSetBkColor($sCard[$i][$c], 0x0000FF) $sNum &= GUICtrlRead($sCard[$i][$c]) & ", " Next $sNum = StringTrimRight($sNum, 2) MsgBox(1, "BINGO", "You have a BINGO!" & @CRLF & "The numbers on column " & $c+1 & " Numbers " & $sNum) Reset () EndIf Next Next For $a = 0 To 4 Step 1 If $sChose[$a][$a] = 0 Then ExitLoop If $a = 4 Then For $i = 0 To 4 Step 1 GUICtrlSetBkColor($sCard[$i][$i], 0x0000FF) $sNum &= GUICtrlRead($sCard[$i][$i]) & ", " Next $sNum = StringTrimRight($sNum, 2) MsgBox(1, "BINGO", "You have a BINGO!" & @CRLF & "The numbers on diagonal Top-Left to Bottom-Right Numbers " & $sNum) Reset () EndIf Next $q = 4 For $a = 0 To 4 Step 1 If $sChose[$a][$q] = 0 Then ExitLoop If $a = 4 Then $z = 4 For $i = 0 To 4 Step 1 GUICtrlSetBkColor($sCard[$i][$z], 0x0000FF) $sNum &= GUICtrlRead($sCard[$i][$z]) & ", " $z -= 1 Next $sNum = StringTrimRight($sNum, 2) MsgBox(1, "BINGO", "You have a BINGO!" & @CRLF & "The numbers on diagonal Top-Left to Bottom-Right Numbers " & $sNum) Reset () EndIf $q -= 1 Next EndFunc Func _NumToLet($i) Switch $i Case 0 Return "B" Case 1 Return "I" Case 2 Return "N" Case 3 Return "G" Case 4 Return "O" Case Else Return $i EndSwitch EndFunc Func Reset () For $r = 0 To 4 Step 1 For $c = 0 To 4 Step 1 GUICtrlSetBkColor($sCard[$r][$c], 0xFFFFFF) GUICtrlSetData($sCard[$r][$c], "") Next Next ReDim $sChose[1][1] ReDim $sChose[5][5] $sChose[2][2] = 1 GUICtrlSetBkColor($sCard[2][2], 0xFFFF00) GUICtrlSetData($sCard[2][2], "FREE") $i = 1 For $r = 0 To 4 Step 1 For $c = 0 To 4 Step 1 If $r = 2 AND $c = 2 Then ContinueLoop While 1 $a = Round(Random($i, $i+14),0) For $z = 0 To 4 Step 1 If GUICtrlRead($sCard[$r][$z]) = $a Then ContinueLoop 2 Next ExitLoop WEnd GUICtrlSetData($sCard[$r][$c], $a) Next $i += 15 Next EndFunc ;--------------------------------------- Func NewCard_Click() Reset () EndFunc Func ToClipboard_Click() ???? EndFunc Func Close() Exit ; finished EndFunc ;==>close ;---------------------------------------Thanks, guys! Much appreciated. Edited November 17, 2008 by Diana (Cda) Link to comment Share on other sites More sharing options...
Malkey Posted November 16, 2008 Share Posted November 16, 2008 You could try a variation of this inserted into your script. #include <GUIConstants.au3> #include <Array.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ScreenCapture.au3> #include <ClipBoard.au3> Func ToClipboard_Click() Local $hBitmap = _ScreenCapture_CaptureWnd("", $Form1) _ClipBoard_Open($Form1) _ClipBoard_Empty() _ClipBoard_SetDataEx($hBitmap, $CF_BITMAP) _ClipBoard_Close() If Not _ClipBoard_IsFormatAvailable($CF_BITMAP) Then MsgBox(0, "", "There was an error while pasting the bitmap to the clipboard!") EndIf EndFunc ;==>ToClipboard_Click Then paste to something like MSPaint. Link to comment Share on other sites More sharing options...
Diana (Cda) Posted November 16, 2008 Author Share Posted November 16, 2008 That's very interesting, thanks! Good to know that this may somehow be possible. I did get an error. I'm wondering about that; when that happens, is it because there's so much code, we can't always know ahead of time if something will conflict (i.e., re the extra UDFs?). At any rate, when I click on the clipboard button, this is what I get: --------------------------- AutoIt Error --------------------------- Line 70 (File "L:\AutoIt\APP- AutoIt v3.2.10.0\Include\ScreenCapture.au3"): _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, $SRCCOPY) _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, ^ ERROR Error: Variable used without being declared. --------------------------- OK --------------------------- Can this be fixed? Thanks! Link to comment Share on other sites More sharing options...
Diana (Cda) Posted November 16, 2008 Author Share Posted November 16, 2008 Thought I'd try again. I have family coming to visit so thought I'd look at this one last time before this visit. Is there nothing that can be done to fix the above? I'm good to go except for this clipboard part. If that could be fixed, then I can handle the rest, I think <g>. Thanks. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 16, 2008 Moderators Share Posted November 16, 2008 Thought I'd try again. I have family coming to visit so thought I'd look at this one last time before this visit.Is there nothing that can be done to fix the above? I'm good to go except for this clipboard part. If that could be fixed, then I can handle the rest, I think <g>.Thanks. It's telling you how to fix it. Find the value for $SRCCOPY and create a global constant with that value. 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...
Diana (Cda) Posted November 17, 2008 Author Share Posted November 17, 2008 It's telling you how to fix it. Find the value for $SRCCOPY and create a global constant with that value.Okay, here's where I start to feel stupid again <sigh>. Well, I went to the UDF and did a search but $SRCCOPY only appears once in that file. And nowhere in the bingo card file is that variable** to be found. I'm at a loss to know what to do next. I also, unfortunately, don't understand what is meant by "create a global constant with that value". I'm guessing (hoping) that it's a terminology issue again and that it's something I've already done. But at this stage, no help there.I guess I'll have to shelve this one for now until I learn more down the road. I managed to make the additions to the script all by myself initially and then managed to incorporate the bits so kindly provided by Malkey; I'll just have to go with a fiddly workaround of making screenshots to get the cards themselves <sigh>. Clunky and I may not always get the same-sized cards so even more fiddles. But I don't know what I don't know until I know it, and that's the case with getting the output <g>. Ah well. The outcome is more than what I started out with, so I'll have to be happy with that <g>.Thanks.(** I believe 'variable' is the right term. No one's corrected me all this time, so I'm guessing that I have it right.) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 17, 2008 Moderators Share Posted November 17, 2008 (edited) #include <WindowsConstants.au3>Edit:You know the funny thing. Would have taken you 3 seconds in google:Search term: SRCCOPY+VALUEhttp://www.google.com/search?hl=en&cli...amp;btnG=SearchBut you've always got to make a big deal on how hard things are . Edited November 17, 2008 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...
Diana (Cda) Posted November 17, 2008 Author Share Posted November 17, 2008 #include <WindowsConstants.au3>Edit:You know the funny thing. Would have taken you 3 seconds in google:Search term: SRCCOPY+VALUEhttp://www.google.com/search?hl=en&cli...amp;btnG=SearchBut you've always got to make a big deal on how hard things are .Look, you are such an unpleasant man to me. I know how it must feel, some stupid nobody comes onboard and has a hard time .. I get that that's all you see. Why don't you really do me a favour and ignore my posts. Please.There's only one difference between me and someone else coming on to this board for the first time, I don't give up. There's too much at stake. But it is hard for me. You want me to admit that? Fine. I do, in anticipation for the small handful of mean people like you who have to stick it to a person rather than turn an indulgent, blind eye.I DON'T find AutoIt easy. It's one of the hardest things I've ever learned computer-wise. And why do I bother? Because it's so valuable. I'm not a person to repeatedly cause myself pain but the results have been worth it. I automate a HUGE portion of my daily work and home computer now off of AI so I'm sure glad I keep coming back to it to try whenever there is a need to make my life easier.So, pls, I ask you again, in fact, I beg you ... just ignore my posts. There are very kind people on this board who put up with my limitations without making me feel worse than I already do, something that is hard when you're an otherwise intelligent person except when it comes to scripting.Thank you for the information. I do appreciate it, you have no idea. Not the delivery of it, of course. But this represents a new means of learning how to cope with an unknown in AI. It seems I spend well over 9/10ths of my time searching and researching ... despite what people like you think. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 17, 2008 Moderators Share Posted November 17, 2008 Look, you are such an unpleasant man to me. I know how it must feel, some stupid nobody comes onboard and has a hard time .. I get that that's all you see. Why don't you really do me a favour and ignore my posts. Please.There's only one difference between me and someone else coming on to this board for the first time, I don't give up. There's too much at stake. But it is hard for me. You want me to admit that? Fine. I do, in anticipation for the small handful of mean people like you who have to stick it to a person rather than turn an indulgent, blind eye.I DON'T find AutoIt easy. It's one of the hardest things I've ever learned computer-wise. And why do I bother? Because it's so valuable. I'm not a person to repeatedly cause myself pain but the results have been worth it. I automate a HUGE portion of my daily work and home computer now off of AI so I'm sure glad I keep coming back to it to try whenever there is a need to make my life easier.So, pls, I ask you again, in fact, I beg you ... just ignore my posts. There are very kind people on this board who put up with my limitations without making me feel worse than I already do, something that is hard when you're an otherwise intelligent person except when it comes to scripting.Thank you for the information. I do appreciate it, you have no idea. Not the delivery of it, of course. But this represents a new means of learning how to cope with an unknown in AI. It seems I spend well over 9/10ths of my time searching and researching ... despite what people like you think.Fortunately for you, I probably won't ignore your posts (Simply because of others looking for possible solutions to the same type of questions). I can't see what type of limitation would keep you from reading the plain English text output pain that you posted here with the actual error in it, and still have the mentality to post articulate questions. 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...
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