confused2gether Posted April 18, 2008 Posted April 18, 2008 Hi, I was wondering, is there a way to map out an image in AutoIT similar to how you would map an image out in HTML? Essentially its only square or rectangular mapping areas so there isnt a need for any weird polygonal shapes/coordinates. What I am planning on doing is creating a program that manages our current internal network. What is going to happen is that I am going to put our cubicle layouts in a picture and map each one out. When you hover over each cube, it will give you the name of the person sitting there and if you click on it, it will expand a new window that will go into more detail and have a button for launching a VNC connection to their computer. At some point, I was also planning on having the floorplan show in colors if a computer is on or off by using a ping or something of the sort (ex. if the ping fails, then that cubicle area would go red) One thing at a time though Image Mapping Thanks!
ProgAndy Posted April 18, 2008 Posted April 18, 2008 I would use an _IECreateEmbedded THen On When you Click on a Imagemap-Link, set a hidden Form filed to a specified value. In AutoiT-Script, Read the Filed in a while-Loop and do the Actions depending on this value *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
confused2gether Posted April 18, 2008 Author Posted April 18, 2008 I would use an _IECreateEmbedded THen On When you Click on a Imagemap-Link, set a hidden Form filed to a specified value.In AutoiT-Script, Read the Filed in a while-Loop and do the Actions depending on this value I'd rather not do anything with the web-browser and would like to keep it just within AutoIT and not calling any other programs. Plus, HTML is yucky lol. I just would rather map it out somehow in AutoIT rather than in HTML and then calling the file.
Zedna Posted April 18, 2008 Posted April 18, 2008 (edited) It sounds very interesting.Post your image.I think it could be done quite easily also in native AutoIt without embeded IE.EDIT: Look here at similar approach (map) Edited April 18, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
ProgAndy Posted April 19, 2008 Posted April 19, 2008 You can either use the Control from Here directly: http://www.freevbcode.com/ShowCode.asp?ID=2988or you use it as base and write it native in AutoIT This is an example with the oxc (needs Paintx.dll, too)expandcollapse popup#include <GUIConstants.au3> Global $RegisteredTheOCXImageMapVB = False Func _RegisterImageMap() ConsoleWrite("->> Register ImageMap"&@CRLF) RunWait("regsvr32 ImageMapVB.ocx /s",@ScriptDir,@SW_HIDE) EndFunc Func _CreateImageMapObj() Local $map = ObjCreate("ImageMapVB.VBImageMap") If @error Then $RegisteredTheOCXImageMapVB = True _RegisterImageMap() $map = ObjCreate("ImageMapVB.VBImageMap") If @error Then Exit MsgBox(0, '', "Needs ImageMapVB from http://www.freevbcode.com/ShowCode.asp?ID=2988") EndIf Return $map EndFunc #region - GUI Create $map = _CreateImageMapObj() GUICreate('test') $obj = GUICtrlCreateObj($map,10,10,250,136) $map.ControlMode = 1 ;Mode 1: Runtime, Mode 2-4 different Design-Modes. $map.BackColor = 0xFFFFFF $map.HTMLText='<map id="Demo1" name="MerrionComputing_ImageMap"><area id="Yellow Square" shape="rectangle" coords="9,9,39,39"><area id="Red Square" shape="rectangle" coords="51,9,79,39"><area id="Green Square" shape="rectangle" coords="96,9,122,39"><area id="Dark Blue Square" shape="rectangle" coords="140,9,169,39"><area id="Pink Square" shape="rectangle" coords="186,9,215,39"><area id="Red Circle" shape="circle" coords="23,64,15,15"><area id="Blue Circle" shape="circle" coords="67,64,15,15"><area id="Yellow Circle" shape="circle" coords="108,64,15,15"><area id="Green Circle" shape="circle" coords="155,64,15,15"><area id="Beige Circle" shape="circle" coords="201,64,15,15"><area id="Green Triangle" shape="polygon" coords="10,93,35,93,23,117"></map>' GUISetState() #endregion _ImageMapSetImage($map,"TestOne.bmp") ObjEvent($map,"VBImageMap1_") ; Set the Events #region - GUI SelectLoop While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd #endregion Func OnAutoItExit() If $RegisteredTheOCXImageMapVB Then RunWait("regsvr32 ImageMapVB.ocx /s /u",@ScriptDir,@SW_HIDE) ConsoleWrite("->> Unregister ImageMap"&@CRLF) EndIf EndFunc Func VBImageMap1_MapItemClicked($Item); ImageMapVB.ImageMapItem MsgBox(0,"MapItemClicked()", "You clicked on " & $Item.ImageMapItemId) EndFunc Func VBImageMap1_MapItemMouseOver($Item); As ImageMapVB.ImageMapItem) If Not IsObj($Item) Then ToolTip("Over nothing") Else ToolTip("Over " & $Item.ImageMapItemId) EndIf EndFunc Func _ImageMapSetImage(ByRef $map,$value) If Not FileExists($value) Then Return SetError(2,0,0) Local $TPictureLoad = ObjCreate("PaintX.PictureDecoder") Local $loaded = 0 If @error Then Local $loaded = 1 ConsoleWrite("->> Register ImageLodaer (PaintX)"&@CRLF) RunWait("regsvr32 PaintX.dll /s",@ScriptDir,@SW_HIDE) $TPictureLoad = ObjCreate("PaintX.PictureDecoder") If @error Then Exit MsgBox(0, '', "Needs PaintX from http://www.paintlib.de/paintlib/download.html") EndIf $map.Picture = $TPictureLoad.LoadPicture($value) $TPictureLoad = 0 If $loaded Then ConsoleWrite("->> UnRegister ImageLodaer (PaintX)"&@CRLF) RunWait("regsvr32 PaintX.dll /s /u",@ScriptDir,@SW_HIDE) EndIf EndFunc *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
confused2gether Posted April 21, 2008 Author Posted April 21, 2008 You can either use the Control from Here directly: http://www.freevbcode.com/ShowCode.asp?ID=2988 or you use it as base and write it native in AutoIT This is an example with the oxc (needs Paintx.dll, too)expandcollapse popup#include <GUIConstants.au3> Global $RegisteredTheOCXImageMapVB = False Func _RegisterImageMap() ConsoleWrite("->> Register ImageMap"&@CRLF) RunWait("regsvr32 ImageMapVB.ocx /s",@ScriptDir,@SW_HIDE) EndFunc Func _CreateImageMapObj() Local $map = ObjCreate("ImageMapVB.VBImageMap") If @error Then $RegisteredTheOCXImageMapVB = True _RegisterImageMap() $map = ObjCreate("ImageMapVB.VBImageMap") If @error Then Exit MsgBox(0, '', "Needs ImageMapVB from http://www.freevbcode.com/ShowCode.asp?ID=2988") EndIf Return $map EndFunc #region - GUI Create $map = _CreateImageMapObj() GUICreate('test') $obj = GUICtrlCreateObj($map,10,10,250,136) $map.ControlMode = 1 ;Mode 1: Runtime, Mode 2-4 different Design-Modes. $map.BackColor = 0xFFFFFF $map.HTMLText='<map id="Demo1" name="MerrionComputing_ImageMap"><area id="Yellow Square" shape="rectangle" coords="9,9,39,39"><area id="Red Square" shape="rectangle" coords="51,9,79,39"><area id="Green Square" shape="rectangle" coords="96,9,122,39"><area id="Dark Blue Square" shape="rectangle" coords="140,9,169,39"><area id="Pink Square" shape="rectangle" coords="186,9,215,39"><area id="Red Circle" shape="circle" coords="23,64,15,15"><area id="Blue Circle" shape="circle" coords="67,64,15,15"><area id="Yellow Circle" shape="circle" coords="108,64,15,15"><area id="Green Circle" shape="circle" coords="155,64,15,15"><area id="Beige Circle" shape="circle" coords="201,64,15,15"><area id="Green Triangle" shape="polygon" coords="10,93,35,93,23,117"></map>' GUISetState() #endregion _ImageMapSetImage($map,"TestOne.bmp") ObjEvent($map,"VBImageMap1_") ; Set the Events #region - GUI SelectLoop While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd #endregion Func OnAutoItExit() If $RegisteredTheOCXImageMapVB Then RunWait("regsvr32 ImageMapVB.ocx /s /u",@ScriptDir,@SW_HIDE) ConsoleWrite("->> Unregister ImageMap"&@CRLF) EndIf EndFunc Func VBImageMap1_MapItemClicked($Item); ImageMapVB.ImageMapItem MsgBox(0,"MapItemClicked()", "You clicked on " & $Item.ImageMapItemId) EndFunc Func VBImageMap1_MapItemMouseOver($Item); As ImageMapVB.ImageMapItem) If Not IsObj($Item) Then ToolTip("Over nothing") Else ToolTip("Over " & $Item.ImageMapItemId) EndIf EndFunc Func _ImageMapSetImage(ByRef $map,$value) If Not FileExists($value) Then Return SetError(2,0,0) Local $TPictureLoad = ObjCreate("PaintX.PictureDecoder") Local $loaded = 0 If @error Then Local $loaded = 1 ConsoleWrite("->> Register ImageLodaer (PaintX)"&@CRLF) RunWait("regsvr32 PaintX.dll /s",@ScriptDir,@SW_HIDE) $TPictureLoad = ObjCreate("PaintX.PictureDecoder") If @error Then Exit MsgBox(0, '', "Needs PaintX from http://www.paintlib.de/paintlib/download.html") EndIf $map.Picture = $TPictureLoad.LoadPicture($value) $TPictureLoad = 0 If $loaded Then ConsoleWrite("->> UnRegister ImageLodaer (PaintX)"&@CRLF) RunWait("regsvr32 PaintX.dll /s /u",@ScriptDir,@SW_HIDE) EndIf EndFunc Hmmm...I like how that looks. I plan on putting this program into an installer form so I might do the registration of the dll and ocx file in there. My problem right now with that code is that it will not register the ocx file. When I manually run the regsrv32 to see whats the deal, it will not register the file either and instead will give me an error as noted in the attached screenshot. Looking through your code though, it looks as if it would be exactly what I would need to get this up and running. Let me know if there are other missing DLL files or whatnot associated with that ocx file so that I can run your sample code and try it out. (BTW, I have already downloaded the PaintX DLL as well as the sample VB ImageMap zip file which is where I got the ImageMap ocx file.)
confused2gether Posted April 21, 2008 Author Posted April 21, 2008 Nevermind I used a dependency walker to see that I was missing the old VB 5 Runtime files. I will try to run it again and go from there.
confused2gether Posted April 21, 2008 Author Posted April 21, 2008 Very nice. I like how that works. A couple of things though that I did notice: 1- the tooltips seem to flicker while you move the mouse and even when the mouse lays dormant. Any suggestions? 2- Im guessing that the "GUICtrlCreateObj($map,10,10,250,136)" is basically just telling the program where it is to be using that image mapping control? Now are the coordinates that you put in for each object relative to within the coordinates of the window or are they relative to the coordinates of the picture? Thanks for the great post BTW. I hope to get some pics finished up from my old CAD drawings soon.
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