
james3mg
Active Members-
Posts
714 -
Joined
-
Last visited
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by james3mg
-
Scrollbars Made Easy - New version 27 Jan 22
james3mg replied to Melba23's topic in AutoIt Example Scripts
I'll be getting this first thing in the morning- I'm in the middle of a big script with the potential for up to 6 scrolling child GUIs and was bemoaning my inability to have any confidence that my math would always work out in controlling how far each one scrolled...so a BIG, HUGE THANKS to Melba and everyone who contributed. -
It's that fourth step that I'd always misinterpreted until I wrote this ASCII stereogram script- I hadn't realized that when you shift the pixels/characters left (thus eliminating a character from the sequence), that establishes a new "baseline" for the repeating string. In other words, the eliminated character is NEVER reinstated in the string. Likewise, when you double (or more) a character to bring the region back "down" a plane, that doubled character is now a part of the "baseline" sequence, too. So if my pattern for a particular row was: 1234567890123456789012345678901234567890123456789012345678901234567890 and my depth map required a per-pixel shift of: 0000000000000011111111111111111111111111000000000000000000000000000000 The row will be transformed into: 1234567890123467890123467890123467890123346789012334678901233467890123 (notice that the 5 never appears again once the shift starts, and the three is always doubled once the shift is over). Before, I'd thought the pattern on the background remained unaffected all the way across the stereogram, and only the "forward" regions had shifted bits... more like 1234567890123467890123456789012345678901123456789012345678901234567890 (which really doesn't work...the "forward" region drops back to the background at the first 5, and gets kinda garbled at the doubled 1. I think the only reason my stereograms kinda worked using this method, was that there was ENOUGH transformation across each row that it was constantly adjusting and kind of made up the difference). Interesting stuff...it's REALLY amazing how powerful our brains are, that they can put all this seemingly garbled, random, information together so quickly...can you imagine trying to bot a stereogram game? I don't think there's any way your computer could really grab the pixels, analyze to find the differences and respond ANYWHERE near quickly enough! 'Course, I haven't tried, either ;-) Edit: Andy, I hadn't meant this as a lecture for you telling you what you already know; I was just noting how I'd gotten it wrong in the past, while explaining to others how they work
-
Good catch, thanks! Fixed in the OP by adding If GUICtrlRead($ColsInput)="" Then Return to the top of the UpdatePreview() function. I'm glad everyone's enjoying it Edit: here are a few more that I did up at my dad's request:
-
There was a thread floating around here a while ago in which some scripts were presented which would make various types of stereograms, which I think is always fun. Though I personally tried a few styles to try and get the "random" pattern to be meaningful itself and still let the 3-d show through, I never succeeded (I actually think the formulas I was using may have been flawed- maybe I'll go back and see if I could improve them later). To my surprise two days ago, I discovered that blocks of ASCII text (usually random bits of text) could actually be made into crude stereograms (crude because each "pixel" [in this case, character] is so much larger that the resolution is by necessity much smaller). So I thought, why not use non-random ASCII text and embed a picture in it? Thus, this script. And, thanks to Greenseed, there's no more PixelGetColor(), so no need to jump through hoops in Vista and Windows 7 for the sake of performance. So, what this script does, is to take text (free of line breaks) and wrap it at the width you specify, then capture the region of your screen that you specify as the depth map (as always, black is the background, and the whiter a pixel is, the closer it will appear to be). You can optionally add a space between the columns of text, which makes it easier to read the original text on the left side of the output and lends what I think is kind of a neat look. You can also specify how many layers will show up in front of the background- but ASCII stereograms always work best if you keep it to 1 or 2 layers. It presents you with a preview of your text so you can make sure that the positions of text wrapping don't create any undesired words or phrases when juxtaposed with the adjacent column, and also to make sure that the last line fills the columns (required for best effect). Once it looks like you want and you've specified the region of your screen which defines the depth map, hit the "Create" button, and it will almost instantly ask you to save the output. To see the stereogram, open the text file you saved, and use the "wall-eyed" method (not the cross-eyed method) of viewing stereograms. You'll notice also that the original text you inputted should remain relatively readable down the left side of the text block- the further right you go in the file, the necessarily more jumbled the text will be- this is how the 3d effects are made. So, here's the script: #include <GUIEdit.au3> #include <ScreenCapture.au3> #region GUISetups Global $TGUI = GUICreate("T Screen Capture",50,1,@DesktopWidth/2,@DesktopHeight/2,-2147483648,136);$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW) Global $LGUI = GUICreate("L Screen Capture",1,50,@DesktopWidth/2,@DesktopHeight/2,-2147483648,136);$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW) Global $BGUI = GUICreate("B Screen Capture",50,1,@DesktopWidth/2-30,@DesktopHeight/2+20,-2147483648,136);$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW) Global $RGUI = GUICreate("R Screen Capture",1,50,@DesktopWidth/2+20,@DesktopHeight/2-30,-2147483648,136);$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW) GUISetState(@SW_SHOW,$TGUI) GUISetState(@SW_SHOW,$LGUI) GUISetState(@SW_SHOW,$BGUI) GUISetState(@SW_SHOW,$RGUI) Global $SelectBoxColor[2]=[0xFF0000,0xFFFFFF] Global $SelectBoxCurrColor=0 AdlibRegister("FlashSelectBoxes",1000) Global $GUI=GUICreate("Textual Stereogram",320,@DesktopHeight-100) GUICtrlCreateLabel("Text to use:",0,0,270,20) Global $TextInput=GUICtrlCreateInput("AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying ""runtimes"" required! AutoIt was initially designed for PC ""roll out"" situations to reliably automate and configure thousands of PCs. Over time it has become a powerful language that supports complex expressions, user functions, loops and everything else that veteran scripters would expect. Features: [truncated] AutoIt has been designed to be as small as possible and stand-alone with no external .dll files or registry entries required making it safe to use on Servers. Scripts can be compiled into stand-alone executables with Aut2Exe. Also supplied is a combined COM and DLL version of AutoIt called AutoItX that allows you to add the unique features of AutoIt to your own favourite scripting or programming languages! Best of all, AutoIt continues to be FREE - but if you want to support the time, money and effort spent on the project and web hosting then you may donate at the AutoIt homepage.",0,20,270,20) GUICtrlCreateLabel("Cols:",270,0,50,20) Global $ColsInput=GUICtrlCreateInput("19",270,20,50,20,0x2000);$ES_NUMBER=0x2000 GUICtrlCreateUpDown($ColsInput,0x80);$UDS_NOTHOSANDS=0x80 GUICtrlSetLimit(-1,35,1) GUICtrlCreateLabel("Sample Output:",0,40,160,20) Global $AddSpace=GUICtrlCreateCheckbox("Space between columns",160,40,160,20) Global $TextOutput=GUICtrlCreateEdit("",0,60,320,@DesktopHeight-220) GUICtrlSetFont($TextOutput,8.5,400,0,"Lucida Console") GUICtrlCreateLabel("DepthMap capture region coord: x:",0,@DesktopHeight-160,180,20) Global $CaptureXInput=GUICtrlCreateInput(Round(@DesktopWidth/2),180,@DesktopHeight-160,60,20,0x2000);$ES_NUMBER=0x2000 GUICtrlCreateUpDown($CaptureXInput,0x80);$UDS_NOTHOSANDS=0x80 GUICtrlCreateLabel("y:",250,@DesktopHeight-160,10,20) Global $CaptureYInput=GUICtrlCreateInput(Round(@DesktopHeight/2),260,@DesktopHeight-160,60,20,0x2000);$ES_NUMBER=0x2000 GUICtrlCreateUpDown($CaptureYInput,0x80);$UDS_NOTHOSANDS=0x80 GUICtrlCreateLabel("Output size:",0,@DesktopHeight-140,120,20) Global $ColSetting=GUICtrlCreateInput("0",0,@DesktopHeight-120,60,20) Global $HeightLabel=GUICtrlCreateLabel("x 0 chars",70,@DesktopHeight-120,60,20) GUICtrlCreateLabel("Highest layer:",150,@DesktopHeight-140,170,20) Global $LayersInput=GUICtrlCreateInput("1",150,@DesktopHeight-120,60,20,0x2000);$ES_NUMBER=0x2000 GUICtrlCreateUpDown($LayersInput,0x80);$UDS_NOTHOSANDS=0x80 GUICtrlSetLimit(-1,9,1) Global $GoButton=GUICtrlCreateButton("Create!",250,@DesktopHeight-120,70,20) #endregion GUISetups UpdatePreview() GUISetState() Global $CurrCols=GUICtrlRead($ColsInput) #region main loop While 1 If _GUICtrlEdit_GetModify($TextInput) OR $CurrCols <> GUICtrlRead($ColsInput) Then UpdatePreview() $msg=GUIGetMsg() If $msg=-3 Then Exit;$GUI_EVENT_CLOSE If $msg=$AddSpace Then UpdatePreview() If $msg=$GoButton Then ExitLoop If $msg=$CaptureXInput OR $msg=$CaptureYInput Then ResetCapturePreview() WEnd #endregion main loop GUISetState(@SW_HIDE,$GUI) GUISetState(@SW_HIDE,$TGUI) GUISetState(@SW_HIDE,$BGUI) GUISetState(@SW_HIDE,$LGUI) GUISetState(@SW_HIDE,$RGUI) AdlibUnRegister("FlashSelectBoxes") Global $RepeatCols=GUICtrlRead($ColsInput)+Number(BitAND(GUICtrlRead($AddSpace),1)) Global $CountCols=GUICtrlRead($ColSetting) Global $Layers=GUICtrlRead($LayersInput) #region capturing mask _GDIPlus_Startup();Thank you, Greenseed at http://www.autoitscript.com/forum/index.php?showtopic=62681 for allowing me to eliminate PixelGetColor()! $GDIdll=DLLOpen("gdi32.dll") $MemoryContext=DLLCall($GDIdll,"int","CreateCompatibleDC","int",0) $MemoryContext=$MemoryContext[0] $hBitmap=_ScreenCapture_Capture("",GUICtrlRead($CaptureXInput),GUICtrlRead($CaptureYInput),GUICtrlRead($CaptureXInput)+$CountCols,GUICtrlRead($CaptureYInput)+UBound($strRows),False) DllCall($GDIdll,"hwnd","SelectObject","int",$MemoryContext,"hwnd",$hBitmap) Global $Mask="" For $y=0 To UBound($strRows)-1 For $x=0 To $CountCols-1 $Color=DLLCall($GDIdll,"int","GetPixel","int",$MemoryContext,"int",$x,"int",$y) $Mask&=$Layers-(Round($Color[0]/(16777215/$Layers))) Next $Mask&=@CRLF Next _WinAPI_DeleteObject($hBitmap) DllClose($GDIdll) ;ConsoleWrite($Mask) #endregion capturing mask #region creating stereogram Global $OutputStr="" $Mask=StringSplit($Mask,@CRLF,3) For $i=0 To UBound($strRows)-1 $tmpMask=StringSplit($Mask[$i],"",2) For $_i=0 To $CountCols-1 $strRows[$i]&=StringMid($strRows[$i],StringLen($strRows[$i])-(($RepeatCols-2)+$tmpMask[$_i]),1) Next $OutputStr&=StringTrimLeft($strRows[$i],$RepeatCols*2)&@CRLF Next #endregion creating stereogram ConsoleWrite($OutputStr) $file=FileSaveDialog("Save ASCII stereogram",@WorkingDir,"Text files (*.txt)",16) If @error Then Exit If NOT StringInStr(StringRight($file,StringLen($file)-StringInStr($file,"/",0,-1)),".") Then $file&=".txt" If NOT @error Then $file=FileOpen($file,2) FileWrite($file,$OutputStr) FileClose($file) #region functions Func FlashSelectBoxes() $SelectBoxCurrColor=Number(NOT $SelectBoxCurrColor) GUISetBkColor($SelectBoxColor[$SelectBoxCurrColor],$TGUI) GUISetBkColor($SelectBoxColor[$SelectBoxCurrColor],$BGUI) GUISetBkColor($SelectBoxColor[$SelectBoxCurrColor],$LGUI) GUISetBkColor($SelectBoxColor[$SelectBoxCurrColor],$RGUI) EndFunc Func UpdatePreview() If GUICtrlRead($ColsInput)="" Then Return _GUICtrlEdit_SetModify($TextInput,0) $CurrCols=GUICtrlRead($ColsInput) GUICtrlSetData($TextOutput,"") $currtext=GUICtrlRead($TextInput) If BitAND(GUICtrlRead($AddSpace),1)=1 Then;$GUI_CHECKED=1 $betCols=" " Else $betCols="" EndIf Do If StringLeft($currtext,2)=", " Then $currtext=StringTrimLeft($currtext,2) $currtext=StringStripWS($currtext,1) GUICtrlSetData($TextOutput,GUICtrlRead($TextOutput)&StringLeft($currtext,$CurrCols)&$betCols&StringLeft($currtext,$CurrCols)&$betCols&@CRLF) $currtext=StringTrimLeft($currtext,$CurrCols) Until StringLen($currtext) = 0 Global $strRows=StringSplit(StringStripWS(GUICtrlRead($TextOutput),2),@CRLF,3) GUICtrlSetData($HeightLabel,"x "&UBound($strRows)&" chars") GUICtrlSetData($ColSetting,Round(2.25*UBound($strRows))) ResetCapturePreview() EndFunc Func ResetCapturePreview() WinMove($TGUI,"",GUICtrlRead($CaptureXInput)-1,GUICtrlRead($CaptureYInput)-1) WinMove($LGUI,"",GUICtrlRead($CaptureXInput)-1,GUICtrlRead($CaptureYInput)-1) WinMove($BGUI,"",(GUICtrlRead($CaptureXInput)-49)+GUICtrlRead($ColSetting),GUICtrlRead($CaptureYInput)+1+UBound($strRows)) WinMove($RGUI,"",GUICtrlRead($CaptureXInput)+1+GUICtrlRead($ColSetting),(GUICtrlRead($CaptureYInput)-49)+UBound($strRows)) _GUICtrlEdit_SetModify($CaptureXInput,0) _GUICtrlEdit_SetModify($CaptureYInput,0) EndFunc #endregion ...and here's a sample stereogram I created with the using the logo in the AutoIt website header, and the "typical" autoit description block of text as the ASCII input (masked due to the size of the block of text...I recommend copying it out of the spoiler/code box and pasting it into Notepad so you can see the whole block of text without scrolling). Enjoy!
-
I agree, I don't think that Execute() is probably necessary at all. However, I don't think there is a null at all...look carefully and I *think* what the OP is doing is creating a 0xAARRGGBB type color, where the AA part is set to 00. See after 0x00 he's adding three sets of two characters to the end, as a string. I think the Execute() was meant to kind of "finalize" the string into an actual number, which is usually unnecessary, as AutoIt does its own conversions from string to hex as necessary. I suppose you could always Hex(Dec($i_transcolor),8) if they wanted to ensure it was stored as an actual number, lol
-
Well, the issue wasn't trying to get the button translucent, the button was just to show that I couldn't get the GDIplus lines to be translucent over other lines OR over other GUI elements. I went through your script and compared it to my original script, and analyzing each change you did and thinking about the implications made me realize my problem. I'd been BitOR'ing a fraction of 0xFF000000 with the color that I wanted the lines to really be, intending that it would be a smooth gradient down in the alpha channel, leaving the color intact. When I saw you using a different alpha starting point though, it made me realize I never stopped to calculate what the result of my attempt to subtract 1/15 of 0xFF000000 from 0xFF000000 WAS. It's not 0xEE000000 as I'd intended, but rather 0xFF111112. So the alpha was staying quite solid, and the actual RGB colors were actually being affected, instead of the other way around. So I think I've got some parenthesees issues in there somewhere. Edit: Seems that maybe 0xFF000000 is too high a number for AutoIt or something, as a plain old ConsoleWrite(0xFF000000/15) spits out -1118481.06666667, not 285212672 Edit2: Yep, it's an AutoIt limitation. I thought it would work, since 0xFFFFFFFF only takes 32 bits to render, but I forgot about the fact that they're signed integers...according to the Help File, it only supports hex numbers from -0x80000000 to 0x7FFFFFFF. 0xFF000000 is certainly larger than that, so that's why it doesn't work. At any rate, I confirmed GDIplus alpha actually DOES work the way I'd intended with the following script: #include <ButtonConstants.au3> #include <GdiPlus.au3> _GDIPlus_Startup() Global $hGUI=GUICreate("Alpha test",400,400) $ContextMenu=GUICtrlCreateContextMenu() $SavePicture=GUICtrlCreateMenuItem("Save picture",$ContextMenu) $button=GUICtrlCreateButton("A test button- I thought this should ""show through"" anything with less than full alpha",50,100,300,40,$BS_MULTILINE) $hGraphic=_GDIPlus_GraphicsCreateFromHWND($hGUI) $hBMP=_GDIPlus_BitmapCreateFromGraphics(400,400,$hGraphic) $hImage=_GDIPlus_ImageGetGraphicsContext($hBMP) For $i=1 To 15 $hPen=_GDIPlus_PenCreate(BitOR("0x"&StringRight(Hex($i,1),1)&StringRight(Hex($i,1),1)&"000000",0xFF0000),1) _GDIPlus_GraphicsDrawLine($hImage,0,200-$i,400,200-$i,$hPen) _GDIPlus_GraphicsDrawLine($hImage,0,199+$i,400,199+$i,$hPen) _GDIPlus_PenDispose($hPen) Next For $i=1 To 15 $hPen=_GDIPlus_PenCreate(BitOR("0x"&StringRight(Hex($i,1),1)&StringRight(Hex($i,1),1)&"000000",0x0000FF),1) _GDIPlus_GraphicsDrawLine($hImage,200-$i,0,200-$i,400,$hPen) _GDIPlus_GraphicsDrawLine($hImage,199+$i,0,199+$i,400,$hPen) _GDIPlus_PenDispose($hPen) Next _GDIPlus_GraphicsDispose($hImage) GUISetState() _GDIPlus_GraphicsDrawImageRect($hGraphic,$hBMP,0,0,400,400) Do $msg=GUIGetMsg() If $msg<0 Then ContinueLoop If $msg=$SavePicture Then $SaveFile=FileSaveDialog("Save image as...","","png image (*.png)|jpg image (*.jpg)|gif image (*.gif)",18,"Output.png") If NOT @error Then _GDIPlus_ImageSaveToFile($hBMP, $SaveFile) EndIf sleep(15) Until $msg = -3(the only difference between this one and my original script is a little bit more ... "manual" ... creation of the alpha channel of the pen definition, as well as removing the _GDIPlus_GraphicsDrawImageRect() from the do...until loop. One final thought- copied your removal of _GDIPlus_GraphicsDrawImageRect() from the Do...Until loop, because as it constantly redrew the image over itself, the alpha slowly faded to solid...which makes sense as I think about it. The reason I had it IN the loop, is that if I cover or minimize the GUI with my code, then restore or uncover the window, the graphic is still visible. With your way, the "canvas" gets wiped clean and the drawing is gone. If there's a better way than my way to get the graphic to stick around, I'd love to hear it! Thanks so much for helping me out and also for being my sounding board- sometimes you've just gotta put it out there before you can find your mistakes!
-
Hello all...I have a feeling that others have likely already run across this problem, but I've searched the forums for a few days, a few ways, and can't find anything referencing it. Please feel free to point me to an existing topic if you know of one. What I'm trying to do is to use the GDIplus functions to create translucent (or semi-transparent) shapes in my GUI. I thought GDIplus was the best candidate because of the alpha channel portion of all the color definitions for pens and brushes. However, what I find is that reducing the alpha on a pen or brush does appear to blend the color with the GUI background color as expected, but it doesn't blend with anything else...that is, it doesn't allow objects/colors/lines/etc to "show through" what should be translucent. Here is a script to show what I mean: #include <ButtonConstants.au3> #include <GdiPlus.au3> _GDIPlus_Startup() Global $hGUI=GUICreate("Alpha test",400,400) $ContextMenu=GUICtrlCreateContextMenu() $SavePicture=GUICtrlCreateMenuItem("Save picture",$ContextMenu) $button=GUICtrlCreateButton("A test button- I thought this should ""show through"" anything with less than full alpha",50,100,300,40,$BS_MULTILINE) $hGraphic=_GDIPlus_GraphicsCreateFromHWND($hGUI) $hBMP=_GDIPlus_BitmapCreateFromGraphics(400,400,$hGraphic) $hImage=_GDIPlus_ImageGetGraphicsContext($hBMP) For $i=1 To 15 $hPen=_GDIPlus_PenCreate(BitOR(0xFF000000-((0xFF000000/15)*$i),0xFF0000),1) _GDIPlus_GraphicsDrawLine($hImage,0,200-$i,400,200-$i,$hPen) _GDIPlus_GraphicsDrawLine($hImage,0,199+$i,400,199+$i,$hPen) _GDIPlus_PenDispose($hPen) Next For $i=1 To 15 $hPen=_GDIPlus_PenCreate(BitOR(0xFF000000-((0xFF000000/15)*$i),0x0000FF),1) _GDIPlus_GraphicsDrawLine($hImage,200-$i,0,200-$i,400,$hPen) _GDIPlus_GraphicsDrawLine($hImage,199+$i,0,199+$i,400,$hPen) _GDIPlus_PenDispose($hPen) Next _GDIPlus_GraphicsDispose($hImage) GUISetState() Do _GDIPlus_GraphicsDrawImageRect($hGraphic,$hBMP,0,0,400,400) $msg=GUIGetMsg() If $msg<0 Then ContinueLoop If $msg=$SavePicture Then $SaveFile=FileSaveDialog("Save image as...","","png image (*.png)|jpg image (*.jpg)|gif image (*.gif)",18,"Output.png") If NOT @error Then _GDIPlus_ImageSaveToFile($hBMP, $SaveFile) EndIf sleep(15) Until $msg = -3As you can see, I reduce the alpha channel of the lines as they move away from center, and they appear as intended where they're just over the GUI. However, where they cross each other or another control, they paint right over each other instead of blending and allowing them to be seen "through". Do I not understand how the alpha channel is supposed to work, or am I using it the wrong way, or is this a known problem? Thanks for your input!
-
Glad you both like it (though I'm not sure how logmein manages to "lose" the game ) I thought about adding more features, but I probably won't go beyond a menu bar from which you can launch a new game or configure options- I like that it's a nice 'n small script with nary a single include file and no fileinstalls (I even figured out how to do "graphics" with only pre-installed fonts), and I'm not anxious to change from that setup for such a dinky game. Anyone else would be welcome to run with it though... Anyway, I thought it was fun and just wanted to share. Glad you tried it out and liked it. Have a nice weekend!
-
No problem, do your thing I'm glad you're still around...we'll get back on this eventually. I'm still working on the "design" of my desk, so I haven't gotten to the point of actually implementing the DMX stuff yet. If you would, when you're back and available for some dialog, please send me a PM...my subscription for this topic will probably have expired again so I won't notice when you post. But a PM will e-mail me so I don't miss it. Thanks!
-
Clicked on a Google ad the other day that took me to www.lumosity.com/MindTeasers . They've got some fun mind exercises, and I felt like making one similar to their Memory Matrix, so I could change some of the configuration options. It turned out fine (no animations or sounds, but the gameplay is easy enough and works well), so I just thought I'd share! You can see the options you can set in the first few lines- either change the defaults there or set the options in the .ini file (created in @workingdir when you finish your first game). There's only one thing that doesn't work like I wanted- I really wanted the popup label between levels to have a translucent background, but GDIPlus wasn't doing it for me, and I didn't want to create an actual GUI other than the main one, so I just left it as a white background. Have fun! Global $iShapesBegin=IniRead(@WorkingDir&"\MemoryConfig.ini","config","iShapesBegin",3) Global $iTurnsBegin=IniRead(@WorkingDir&"\MemoryConfig.ini","config","iTurnsBegin",10) Global $iBoxSize=IniRead(@WorkingDir&"\MemoryConfig.ini","config","iBoxSize",50) Global $iMemorizeMS=IniRead(@WorkingDir&"\MemoryConfig.ini","config","iMemorizeMS",1500) Global $iFontSize=IniRead(@WorkingDir&"\MemoryConfig.ini","config","iFontSize",40) Global $aGUISize[2]=[(Ceiling((($iShapesBegin+$iTurnsBegin)-3)/2)+3)*$iBoxSize,(Floor((($iShapesBegin+$iTurnsBegin)-3)/2)+3)*$iBoxSize] Global $hGUI=GUICreate("Memory",$aGUISize[0]-2,$aGUISize[1]+18) GUISetBkColor(0x449944) Global $hStatusBar=GUICtrlCreateLabel("Score: 0"&@TAB&"Shapes: "&$iShapesBegin&"/"&$iShapesBegin&@TAB&"Rounds left: "&$iTurnsBegin&@TAB&"Personal best: "&IniRead(@WorkingDir&"\MemoryConfig.ini","Scores",$iShapesBegin&"-"&$iTurnsBegin,"0"),0,$aGUISize[1],$aGUISize[0],20) GUICtrlSetBkColor(-1,0xCCCCCC) GUISetState(@SW_SHOW,$hGUI) While 1 Global $iShapes=$iShapesBegin, $iScore=0 For $iTurns=$iTurnsBegin To 0 Step -1 GUICtrlSetData($hStatusBar,"Score: "&$iScore&@TAB&"Shapes: "&$iShapes&"/"&$iShapes&@TAB&"Rounds left: "&$iTurns&@TAB&"Personal best: "&IniRead(@WorkingDir&"\MemoryConfig.ini","Scores",$iShapesBegin&"-"&$iTurnsBegin,"0")) Message($iShapes&" boxes") Local $iCols=Ceiling(($iShapes-3)/2)+3 Local $iRows=Floor(($iShapes-3)/2)+3 Local $aBoxes[$iCols][$iRows][2] Local $aBaseCoord[2]=[$aGUISize[0]/2-.5*$iBoxSize*$iCols,$aGUISize[1]/2-.5*$iBoxSize*$iRows] Local $iNumPicked=0 Do $iX=Random(0,$iCols-1,1) $iY=Random(0,$iRows-1,1) If $aBoxes[$iX][$iY][1]<>"y" Then $iNumPicked+=1 $aBoxes[$iX][$iY][1]="y" $aBoxes[$iX][$iY][0]=GUICtrlCreateLabel("",$aBaseCoord[0]+($iX*$iBoxSize),$aBaseCoord[1]+($iY*$iBoxSize),$iBoxSize-2,$iBoxSize-2) GUICtrlSetBkColor(-1,0x000000) GUICtrlSetFont(-1,$iFontSize,Default,Default,"Wingdings") GUICtrlSetColor(-1,0xFF0000) EndIf Until $iNumPicked=$iShapes For $iX=0 To $iCols-1 For $iY=0 To $iRows-1 If $aBoxes[$iX][$iY][1]<>"y" Then $aBoxes[$iX][$iY][1]="n" $aBoxes[$iX][$iY][0]=GUICtrlCreateLabel("",$aBaseCoord[0]+$iX*$iBoxSize,$aBaseCoord[1]+$iY*$iBoxSize,$iBoxSize-2,$iBoxSize-2) GUICtrlSetBkColor(-1,0xFFFFFF) GUICtrlSetFont(-1,$iFontSize,Default,Default,"Wingdings") GUICtrlSetColor(-1,0xFF0000) EndIf Next Next $hTimer=TimerInit() While 1 Sleep(15) If GUIGetMsg()=-3 Then Exit If TimerDiff($hTimer)>$iMemorizeMS Then ExitLoop WEnd For $iX=0 To $iCols-1 For $iY=0 To $iRows-1 If $aBoxes[$iX][$iY][1]="y" Then GUICtrlSetBkColor($aBoxes[$iX][$iY][0],0xFFFFFF) Next Next Local $iNumCorrect=0 While 1 Sleep(15) Local $msg=GUIGetMsg() If $msg=-3 Then Exit If $msg<0 Then ContinueLoop For $iX=0 To $iCols-1 For $iY=0 To $iRows-1 If $aBoxes[$iX][$iY][0]=$msg Then If $aBoxes[$iX][$iY][1]="y" Then GUICtrlSetBkColor($aBoxes[$iX][$iY][0],0x000000) $aBoxes[$iX][$iY][1]="" $iNumCorrect+=1 $iScore+=100 GUICtrlSetData($hStatusBar,"Score: "&$iScore&@TAB&"Shapes: "&$iShapes-$iNumCorrect&"/"&$iShapes&@TAB&"Rounds left: "&$iTurns&@TAB&"Personal best: "&IniRead(@WorkingDir&"\MemoryConfig.ini","Scores",$iShapesBegin&"-"&$iTurnsBegin,"0")) ElseIf $aBoxes[$iX][$iY][1]="n" Then;wrong box clicked: start over on this level GUICtrlSetData($aBoxes[$iX][$iY][0],"N");crossbones If $iShapes > $iShapesBegin Then $iShapes-=1 For $_iX=0 To $iCols-1 For $_iY=0 To $iRows-1 If $aBoxes[$_iX][$_iY][1]="y" Then GUICtrlSetBkColor($aBoxes[$_iX][$_iY][0],0xFF0000) Next Next Sleep($iMemorizeMS) For $_iX=0 To $iCols-1 For $_iY=0 To $iRows-1 GUICtrlDelete($aBoxes[$_iX][$_iY][0]) Next Next ExitLoop 3 EndIf EndIf Next Next If $iNumCorrect=$iShapes Then;all shapes clicked for this level For $_iX=0 To $iCols-1 For $_iY=0 To $iRows-1 If $aBoxes[$_iX][$_iY][1]="" Then GUICtrlSetData($aBoxes[$_iX][$_iY][0],"C");thumbs-up Next Next $iScore+=$iShapes*100 GUICtrlSetData($hStatusBar,"Score: "&$iScore&@TAB&"Shapes: "&$iShapes-$iNumCorrect&"/"&$iShapes&@TAB&"Rounds left: "&$iTurns&@TAB&"Personal best: "&IniRead(@WorkingDir&"\MemoryConfig.ini","Scores",$iShapesBegin&"-"&$iTurnsBegin,"0")) Message("Perfect! +"&$iShapes*100&" points") $iShapes+=1 For $_iX=0 To $iCols-1 For $_iY=0 To $iRows-1 GUICtrlDelete($aBoxes[$_iX][$_iY][0]) Next Next ExitLoop EndIf WEnd Next If IniRead(@WorkingDir&"\MemoryConfig.ini","Scores",$iShapesBegin&"-"&$iTurnsBegin,0)<$iScore Then IniWrite(@WorkingDir&"\MemoryConfig.ini","Scores",$iShapesBegin&"-"&$iTurnsBegin,$iScore) Message("Game over"&@CRLF&@CRLF&"New HIGH SCORE: "&$iScore,0) Else Message("Game over"&@CRLF&@CRLF&"Score: "&$iScore,0) EndIf If MsgBox(4+32,"Play again?","Would you like to play again?")=7 Then Exit For $_iX=0 To $iCols-1 For $_iY=0 To $iRows-1 GUICtrlDelete($aBoxes[$_iX][$_iY][0]) Next Next WEnd Func Message($_sMsg,$_bTimeout=1) Local $_tmp=GUICtrlCreateLabel(@CRLF&$_sMsg,$aGUISize[0]/2-100,$aGUISize[1]/2-70,200,140,0x1) GUICtrlSetBkColor(-1,0xFFFFFF) GUICtrlSetFont(-1,16,600,2,"Swis721 BlkCn BT",5) If $_bTimeout=1 Then Sleep($iMemorizeMS) GUICtrlDelete($_tmp) EndIf EndFunc
-
how to get file product version ?
james3mg replied to dirty's topic in AutoIt General Help and Support
It does work for Vista and 7, but the numbers are all moved around. I've had to go through and poll all the properties to find the number of the property that I want before, then use an @OSVersion switch to make sure and read the correct one. ...though someone else may know of a more reliable way -
Welcome to the forums What Volly gave you is a function- you don't have to modify it at all, just copy the #include lines at the top into the top of your script, and the function (the rest of what he posted) to the bottom of your script. Then you call the function, providing it at least the full path of the file you want to set as your wallpaper: WallpaperSet(@DesktopDir&"\SampleDesktop.bmp") You might want to play with the second option as well: it allows you to specify if the wallpaper is stretched, tiled, etc. For instance: WallpaperSet(@DesktopDir&"\SampleDesktop.bmp",$WALLPAPER_STRETCH)will explicitly tell Windows that it should stretch the image you specify to fit the whole desktop. Give it a shot, and post back codes that you've tried if you need more help.
-
Identifing whether s/w component is uninstalled or not
james3mg replied to User123's topic in AutoIt General Help and Support
The list of programs installed on a computer (at least, those which are listed in Add/Remove programs or Program and Features depending on your version of Windows), are stored in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall You'll need to populate the keys and look for the software in question. Give it a shot, using the help file to understand RegRead() if you don't already, and post back here with your code if you hit another wall. -
IE Control does not resize correctly
james3mg replied to MCornelio's topic in AutoIt General Help and Support
Hey, glad it helped! Thanks for showing an effort, and for listening ...and believe me, I've had my fair share of *duh* moments lately too Fortunately, there's always someone around here willing to help us learn if we're willing to hear it. -
Question about the use of Clipboard function
james3mg replied to Akshay07's topic in AutoIt General Help and Support
Maybe. But it's more likely that the result of clearing the clipboard will result in nothing being available to paste in step 2. My guess is that it's the Ctrl+C that's getting dropped...maybe your script isn't waiting for the "other" window to become fully active before copying? I'd consider checking the contents of the clipboard after you send the Ctrl+C...if it's a bitmap, re-activate the "other" window, wait 100ms or so and re-send a Ctrl+C. Maybe loop that over and over until the contents of the clipboard are a text string before continuing on with the Ctrl+V part of your script. -
IE Control does not resize correctly
james3mg replied to MCornelio's topic in AutoIt General Help and Support
First, welcome to the forums I think you want to set the resizing on $GUIActiveX , not on $oIE. Also, when posting code, please wrap it in [autoit ] and [/autoit ] tags (omit the space prior to each closing bracket) or press the blue button below the "Bold" button when composing your message...it makes it easier to read. -
If you passed the parameters as any number of elements in a single array variable, your function could then extract the parameters from the array. Dim $Parameters[3] = ['Something','Else','Here'] ThisSub ( $Parameters ) Dim $Parameters[Random(1,5,1)];random number of parameters For $i=0 To UBound($Parameters)-1 $Parameters[$i]=Chr(Random(65,90,1));each parameter will be a random uppercase letter, just as an example. Next ThisSub ( $Parameters ) Func ThisSub ( $_params);naturally, you'd do something more useful with the parameters than just count and display them. MsgBox(0,"ThisSub",UBound($_params)&" parameters passed") Local $str="" For $_i=0 To UBound($_params)-1 $str&=$_params[$_i]&@CRLF Next MsgBox(0,"ThisSub Parameters:",$str) EndFunc Edit: looks like you found the solution yourself before I posted...nice job
-
I'm confused by what you want it to do- it looks to me that you're asking the script to click whenever you click. At the most, this might turn every single click into a double-click...is that what you want? Or do you want it to begin repeating whatever physical click you make, at an interval, for a number of repetions?
-
Mouse Script for Windows 7 and others.
james3mg replied to mach42's topic in AutoIt General Help and Support
Rereading your original post, I think this may be more like what you're looking for: #include <Misc.au3> Global $hdll=DllOpen("user32.dll");open the DLL used in _IsPressed so that it doesn't have to open and close the dll every time it runs a check (makes it a much lighter-weight program) Global $ClickState=0;0 indicates left mouse button is "up", 1 indicates left mouse button is "down". While 1 Sleep(15);decrease this number if it's "missing" middle-clicks...this means that it will only check to see if the middle button is pressed once every 15 ms. If _IsPressed("04",$hdll)=1 Then;if middle mouse button is pressed, then: If $ClickState=0 Then;if left mouse button is up, then MouseDown("left");press the left mouse button Else;if left mouse button is down, then MouseUp("left");release the left mouse button EndIf $ClickState=NOT $ClickState;flip 1 to a 0 or 0 to a 1 in $ClickState, so our script can keep track of the new state of the left mouse button Do;now wait until the user releases the middle button, or it will constantly be toggling left-click on/off while they hold the middle button Sleep(15) Until _IsPressed("04",$hdll)=0 EndIf WEndWith this script, you get the behavior I think you're used to; middle-click of the mouse togges a left click hold on/off. This script takes less than 2 MB of RAM (which is nothing), and only took a fraction of a percent of processor power on my machine (which is 32-bit Windows 7, around a year old, and nothing very impressive). You can play with the two Sleep() values if you want to improve performance or reduce system impact, but it seemed very reliable and lightweight at these settings when I tried it out. Edit: added comments to code so you could figure out how this script works...naturally, you can delete the semicolon in each line and everything after it if you just want the pure, clean code. -
Mouse Script for Windows 7 and others.
james3mg replied to mach42's topic in AutoIt General Help and Support
First, x64 shouldn't be a problem- AutoIt can be compiled in 32-bit (which runs on 32-bit systems or 64-bit systems), or in native 64-bit (which only runs on 64-bit systems). Next, AutoIt does not, and will not, work on a Mac OS, but if you have Windows installed on a Mac computer, it will run on Windows, no problem. (I wasn't sure exactly what you might mean by, "Mac"). Finally, others may know of a better way than MouseDown, but it seems to me that method would work fine. However, I don't think you really want to exit the script when you press F5- you just want to release the mouse button, right? If you exited the script, your F3 button wouldn't work again until you started the script again. Instead, try MouseUp("left") instead of Exit. This should be a very lightweight script- I can't imagine it would hurt your system resources at all. It should also work on any version of Windows higher than Windows ME (anything NT-based, such as 2000, XP, Vista and 7) One suggestion (I'm not sure what setup you're used to); if you only wanted a single key to toggle a left click on/off, try using a variable: Global $ClickState=0 HotKeySet ("{F3}", "ClickToggle") While 1 Sleep(500) WEnd Func ClickToggle() If $ClickState=0 Then MouseDown("left") Else MouseUp("left") EndIf $ClickState=NOT $ClickState EndFunc -
Tooltips hitting max. number of GUI controls?
james3mg replied to james3mg's topic in AutoIt General Help and Support
More great suggestions, thanks! I was already having other things happen if the labels are clicked, but following your advice I found this topic, and found that by adding just the following lines to my script: #include <GUICtrlSetOnHover_UDF.au3> Func LabelHover($iCtrlID) ToolTip(GUICtrlRead($iCtrlId)) EndFunc Func LabelMouseOut($iCtrlID) ToolTip("") EndFuncand replacing GUICtrlSetTip(-1,[control-specific_text]) with_GUICtrl_SetOnHover(-1,"LabelHover","LabelMouseOut")I get basically the same effect, but without the byproducts of creating and having to destroy control-specific tooltips. So, I think that solves all my issues, though it's good to have this topic now, so others can be aware of the hazards of using thousands of GUICtrlSetTip() 's -
Tooltips hitting max. number of GUI controls?
james3mg replied to james3mg's topic in AutoIt General Help and Support
Hey, thanks for giving me another chance A status bar is a great idea- may be just the ticket I was looking for. The reason I was using tooltips is that most of my controls (primarily clickable labels), by necessity, are too small to display the entire text they contain. So I was using the tooltips to "expand" the missing labels so I'd know what I was clicking on. But a status bar is kind of an innate behavior in this day and age, so maybe that's enough. Thanks for the idea! -
Reading a word document and seraching for sections
james3mg replied to myk3's topic in AutoIt General Help and Support
Seems to works for me- it highlights then exits. So you can add Send("^c") and $found=ClipGet() to the end of your script, and it will give you the whole first section, as I understand it. Or maybe I misunderstood what you're looking for? Edit: I did notice as I went to close the Word window, that it acts like I'm holding down shift (that is, if I click somewhere, the highlighting is cut back or extended to include everything from the beginning the document to wherever I clicked)...is there a $word.Selection method that cancels out your command to .Extend? Maybe that's your problem, if your cursor for some reason was sent to the end of the document? -
Tooltips hitting max. number of GUI controls?
james3mg replied to james3mg's topic in AutoIt General Help and Support
Thought about that, but I'm not a huge fan of that solution. I'd rather make a second .exe launched from my main script that received the IDs as messages (_SendMessage()) from my main script and put them into a queue, deleting them as quickly as it could and otherwise idling around if there's nothing in the queue. That way, the processes are fully separate, and the main script wouldn't get bogged down unless the whole computer was so underpowered that the "cleanup" exe slowed all of Windows down. But I still consider that a last resort- maybe even behind not having tooltips Thanks for your heap-and-a-half of help! -
_MsgBoxEx gives different returns on XP and Win7
james3mg replied to jp10558's topic in AutoIt General Help and Support
I'm on Windows 7x32, and running: Local $ChangeText[3] = ['', 'Now', 'Later'] ConsoleWrite(_MsgBoxEx(4, 'Install Office 2007', "hi",0,$ChangeText)&@CRLF) Func _MsgBoxEx($iFlag, $sTitle, $sText, $iTime = 0, $sCIDChange = '') Local $_MsgBox_ = '"' & "ConsoleWrite(MsgBox(" & $iFlag & ', ""' & $sTitle & '"", ""' & $sText & '"", ' & $iTime & '"))' Local $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $_MsgBox_, '', @SW_SHOW, 6) Do Sleep(10) Until WinExists($sTitle) If IsArray($sCIDChange) Then For $iCC = 1 To UBound($sCIDChange) - 1 ControlSetText($sTitle, '', 'Button' & $iCC, $sCIDChange[$iCC]) Next Else ControlSetText($sTitle, '', 'Button1', $sCIDChange) EndIf While ProcessExists($iPID) Local $iStdOut = StdoutRead($iPID) If Number($iStdOut) Then Return $iStdOut Sleep(10) WEnd If IsArray($sCIDChange) Then Return SetError(1, 0, 2) Return SetError(1, 0, 1) EndFuncand clicking "Now" returns 6 for me. Maybe it's an x64 thing? What happens on your x64 if you run ConsoleWrite(MsgBox(4,"hi","test")&@CRLF)and click "Yes"?