CodeMaster Rapture Posted April 3, 2006 Share Posted April 3, 2006 Hey all, I got really bored and decided to try something a little different. I made this script as an example of a neat feature you can add to your scripts in the future, a built-in magnifying glass! It's a pretty simple script, but I've never seen anyone else use au3 this way. I'm sure there are plenty of other better methods (DLL calls), but I thought this was quite cool when I got it working. So, without further adue: expandcollapse popup; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.1.1 Beta ; Author: CodeMaster Rapture <Rapture2k4@Netscape.net> ; Language: English ; Script Function: A little application that magnifies a 20x20 area under the ; mouse. This is just an example of what CAN be done in Au3. ; ; ------------------------------------------------------------------------------ #include <GUIConstants.au3> HotKeySet("{ESC}", "Quit") ;Magnifying a 20x20 area of the screen Global $GUI_Pixel[400] Global $GUI = GUICreate("Zoom x2 Au3",80,80,0,0,$WS_POPUP+$WS_BORDER,$WS_EX_TOPMOST) $count = 0 ;Let's create a bunch of labels and make them 4x4 pixels in size. For $iterX = 0 To 79 Step 4 For $iterY = 0 To 79 Step 4 $GUI_Pixel[$count] = GUICtrlCreateLabel("",$iterX,$iterY,4,4) $count += 1 Next Next GUISetState(@SW_SHOW) Global $LastPos[2] = [0,0] While 1 $count = 0 $MousePos = MouseGetPos() ;Got creative here, since we want to magnify a 20x20 area around the mouse, ;I just start with a negative number for each loop. It still counts 20x20, merely ;starts at a strange index. :) For $iterX = -10 To 9 For $iterY = -10 To 9 GUICtrlSetBkColor($GUI_Pixel[$count],PixelGetColor($MousePos[0]+$iterX,$MousePos[1]+$iterY)) $count += 1;Loop thru our Pixel Array (20 * 20 == 400 elements) Next Next ;I placed this in to remove some choppiness. One less API call == good. ;This also allows for animation over an area of the screen. If ($LastPos[0] <> $MousePos[0] Or $LastPos[1] <> $MousePos[1]) Then WinMove("Zoom x2 Au3","",$MousePos[0]+15,$MousePos[1]) $LastPos[0] = $MousePos[0] $LastPos[1] = $MousePos[1] EndIf ;Sleeping 1-10 ms takes 70-60% (respectively) CPU usage on my machine Sleep(10) WEnd Func Quit() Exit EndFunc Tell me whatcha think , CMR Link to comment Share on other sites More sharing options...
greenmachine Posted April 3, 2006 Share Posted April 3, 2006 Wow, that's actually quite cool. Nice work. Link to comment Share on other sites More sharing options...
CodeMaster Rapture Posted April 3, 2006 Author Share Posted April 3, 2006 Thanx. I need to add in some collision detection for the edges of the screen, zoom level, zoom box size, and so on. -CMR Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 3, 2006 Moderators Share Posted April 3, 2006 Love it!! Now you just need the Cross hairs 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...
greenmachine Posted April 3, 2006 Share Posted April 3, 2006 Customized a bit by using a DllCall that I found earlier today on the forum. expandcollapse popup#include <GUIConstants.au3> $MagWidth = InputBox ("Magnify Area", "What should the WIDTH of the magnified area be?") $MagHeight = InputBox ("Magnify Area", "What should the HEIGHT of the magnified area be?") $MagZoom = InputBox ("Magnify Area", "What should the ZOOM of the magnified area be?", 2) Global $SRCCOPY = 0x00CC0020 Global $dll[3], $DeskHDC, $GUIHDC $dll[1] = DllOpen ( "user32.dll") $dll[2] = DllOpen ( "gdi32.dll") Global $GUI = GUICreate ("Zoom x2 Au3", $MagWidth * $MagZoom, $MagHeight * $MagZoom, _ MouseGetPos (0), MouseGetPos (1), $WS_POPUP+$WS_BORDER, $WS_EX_TOPMOST) GUISetState(@SW_SHOW) Global $LastPos[2] = [0,0] While 1 MAG() $MousePos = MouseGetPos() If ($LastPos[0] <> $MousePos[0] Or $LastPos[1] <> $MousePos[1]) Then WinMove("Zoom x2 Au3", "", $MousePos[0] + $MagWidth/2 + 5, $MousePos[1]) $LastPos[0] = $MousePos[0] $LastPos[1] = $MousePos[1] EndIf Sleep(10) WEnd Func MAG() $DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0) $GUIHDC = DLLCall("user32.dll","int","GetDC","hwnd",$GUI) If Not @error Then DLLCall("gdi32.dll", "int", "StretchBlt", "int", $GUIHDC[0], "int", _ 0, "int", 0, "int", $MagWidth * $MagZoom, "int", $MagHeight * $MagZoom, "int", $DeskHDC[0], "int", _ MouseGetPos (0) - $MagWidth/2, "int", MouseGetPos (1) - $MagHeight/2, "int", $MagWidth ,"int", $MagHeight, _ "long", $SRCCOPY) DLLCall("user32.dll","int","ReleaseDC","int",$DeskHDC[0],"hwnd",0) DLLCall("user32.dll","int","ReleaseDC","int",$GUIHDC[0],"hwnd",$GUI) EndIf EndFunc Func OnAutoItExit() DllClose ( $dll[1] ) DllClose ( $dll[2] ) EndFunc Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 3, 2006 Moderators Share Posted April 3, 2006 Ha... Very Nice! 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...
RazerM Posted April 3, 2006 Share Posted April 3, 2006 very good i like it My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
Emperor Posted April 3, 2006 Share Posted April 3, 2006 This is pretty cool, nice work. Link to comment Share on other sites More sharing options...
rakudave Posted April 3, 2006 Share Posted April 3, 2006 very good! i was looking for something like this, thx! Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table Link to comment Share on other sites More sharing options...
ConsultingJoe Posted April 3, 2006 Share Posted April 3, 2006 (edited) very cool, I like how the gui is small and simple Edited April 5, 2006 by zerocool60544 Check out ConsultingJoe.com Link to comment Share on other sites More sharing options...
GaryFrost Posted April 3, 2006 Share Posted April 3, 2006 I believe if you search hard enough you'll find it's been done a few times before, but nothing wrong with learning how to do it on your own. SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Tukata Posted April 4, 2006 Share Posted April 4, 2006 Please help ! I am trying to run the two script in this topic but get error messages. If I compile them with Beta I get errors. What am I doing wrong ? Thank you Tuk Link to comment Share on other sites More sharing options...
greenmachine Posted April 4, 2006 Share Posted April 4, 2006 Please help !I am trying to run the two script in this topic but get error messages. If I compile them with Beta I get errors. What am I doing wrong ?Thank youTukYou're not being descriptive enough - that's what you're doing wrong. Link to comment Share on other sites More sharing options...
Tukata Posted April 5, 2006 Share Posted April 5, 2006 You're not being descriptive enough - that's what you're doing wrong.My question is simple: How do I run or compile the above scripts ?Do I have to include them in existing project or they are stand-alone ?Running the first script I get error on line 23: $count += 1Error: Expected a "=" operator is assignment statement.If run compiled (Beta) I get same error in line 0.Running the second script I get three times InputBox, but after entering the third box I get error on line 13 saying " Incorrect number of paramerers in function call", then a second error on line 13 sayin "Error in expression"If I compile the second script I get: "Unable to open the script file".Thank you for helpingTuk Link to comment Share on other sites More sharing options...
greenmachine Posted April 5, 2006 Share Posted April 5, 2006 My question is simple: How do I run or compile the above scripts ?Do I have to include them in existing project or they are stand-alone ?Running the first script I get error on line 23: $count += 1Error: Expected a "=" operator is assignment statement.If run compiled (Beta) I get same error in line 0.Running the second script I get three times InputBox, but after entering the third box I get error on line 13 saying " Incorrect number of paramerers in function call", then a second error on line 13 sayin "Error in expression"If I compile the second script I get: "Unable to open the script file".Thank you for helpingTukWell it works fine when I use it. Are you using Scite? If so, make sure you run scripts with Alt+F5 and compile with Alt+F7. Also, make sure that you answer each of the input prompts, because I didn't declare the vars beforehand (as I should have, but it was late). Link to comment Share on other sites More sharing options...
Apzo Posted April 5, 2006 Share Posted April 5, 2006 I will try it with Counter Strike, it's a headshot powertool Apzo. All the pop3 functions.Rsync your files on your USB key (or anywhere else) Link to comment Share on other sites More sharing options...
ConsultingJoe Posted April 5, 2006 Share Posted April 5, 2006 I will try it with Counter Strike, it's a headshot powertool Apzo.Good idea, did it work? Check out ConsultingJoe.com Link to comment Share on other sites More sharing options...
Tukata Posted April 5, 2006 Share Posted April 5, 2006 Are you using Scite?No.Thank youTuk Link to comment Share on other sites More sharing options...
CodeMaster Rapture Posted April 5, 2006 Author Share Posted April 5, 2006 (edited) Good idea, did it work?I couldn't get it to work. I actually designed this to see if I could make a zoom application for fullscreen satallite imaging software (DirectX 9). The only thing I can get to work is a flickering tooltip :/. I'm working on a DLL in VC++ that will solve this problem tho. It will also have a bunch of other neat things like Onscreen Display text boxes, shapes, scrolling banners, etc (think xFire for Au3). I'm just torn between using OpenGL or DirectX for this.-CMR Edited April 5, 2006 by CodeMaster Rapture Link to comment Share on other sites More sharing options...
Lakes Posted April 5, 2006 Share Posted April 5, 2006 Great Job! Has anyone done a tutorial for calling and using these wonderfull gdi32.dll functions?? 2015 - Still no flying cars, instead blankets with sleeves. 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