chssoccer Posted January 19, 2008 Share Posted January 19, 2008 How do I check if an image is in a specific location in a gui? and if so take a certain action? Link to comment Share on other sites More sharing options...
martin Posted January 19, 2008 Share Posted January 19, 2008 How do I check if an image is in a specific location in a gui? and if so take a certain action?ControlGetPos? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
chssoccer Posted January 20, 2008 Author Share Posted January 20, 2008 (edited) ControlGetPos?$calling = GUICreate("", 24, 24, 5, 5,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$hudGUI) $callingpic = GUICtrlCreatePic(@scriptdir & "\poker icons\calling.gif", 0, 0, 24, 24) Case $msg = $callingpic $cPos = ControlGetPos("Full Tilt Buddy List - v1.0", "", $calling) MsgBox(0, "", $cPos[0] & "," & $cPos[1]) All it ever returns is 0,0 How do I fix this? Edited January 20, 2008 by chssoccer Link to comment Share on other sites More sharing options...
jokke Posted January 20, 2008 Share Posted January 20, 2008 Try with WinGetPos. UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt. Link to comment Share on other sites More sharing options...
chssoccer Posted January 20, 2008 Author Share Posted January 20, 2008 (edited) Try with WinGetPos.It returns like 443,261 which I think are the Screen Coords of the pic. But how can I get the relative active client coords?EDIT:Never mind, I subracted its starting coords from the screen coords. Edited January 20, 2008 by chssoccer Link to comment Share on other sites More sharing options...
chssoccer Posted January 20, 2008 Author Share Posted January 20, 2008 Ok, the first question is solved but now I have another problem. I create a moveable picture and what I want is once I move that picture out of its starting location which is 5,5 in window coords it will automatically re-create a new picture in the other pictures place while leaving the other picture where it was moved to. But when I do this it messes up. Case $msg = $callingpic $gp = WinGetPos($calling) $mp = MouseGetPos() While _IsPressed("1") $cp = MouseGetPos() WinMove($calling,'',$gp[0] - $mp[0] + $cp[0],$gp[1] - $mp[1] + $cp[1]) $cPos = WinGetPos("calling", "") $cPosX = $cPos[0] - 438 $cPosY = $cPos[1] - 256 If $cPosX = "5" AND $cPosY = "5" Then; If pic is in place ; do nothing Else $calling = GUICreate("calling", 24, 24, 5, 5,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$hudGUI) $callingpic = GUICtrlCreatePic(@scriptdir & "\poker icons\calling.gif", 0, 0, 24, 24); Create new pic EndIf WEnd Link to comment Share on other sites More sharing options...
chssoccer Posted January 20, 2008 Author Share Posted January 20, 2008 any suggestions? Link to comment Share on other sites More sharing options...
FreeFry Posted January 20, 2008 Share Posted January 20, 2008 (edited) I think it would be great if you provided us with the full code you have. :} Edited January 20, 2008 by FreeFry Link to comment Share on other sites More sharing options...
FireLordZi Posted January 20, 2008 Share Posted January 20, 2008 It's over 700 lines long. Still want it? While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
FreeFry Posted January 20, 2008 Share Posted January 20, 2008 (edited) Does it require it all to reproduce the problem you're having? Edit: Also, why're you creating a new GUI on the line just above the GuiCtrlCreatePic, that might be what's messing up(because that window will not be shown, unless you do GuiSetState()) Edited January 20, 2008 by FreeFry Link to comment Share on other sites More sharing options...
FireLordZi Posted January 20, 2008 Share Posted January 20, 2008 Does it require it all to reproduce the problem you're having? Edit: Also, why're you creating a new GUI on the line just above the GuiCtrlCreatePic, that might be what's messing up(because that window will not be shown, unless you do GuiSetState()) No, but I think this is all that has to do with my question. expandcollapse popupFunc CreateHudGUI(); Creates the HUD interface $hudGUI = GUICreate("Heads-up Display Stickers", 150, 250) GUISetState() GUISetBkColor(0xF2F2F2, $hudGUI) WinSetOnTop("Heads-up Display Stickers", "", 1) $exit = GUICtrlCreateButton("Close", 5, 233, 40, 15) GUICtrlSetFont(-1, 8, 400, -1, "Arial Bold") $calling = GUICreate("calling", 24, 24, 5, 5,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$hudGUI) $callingpic = GUICtrlCreatePic(@scriptdir & "\poker icons\calling.gif", 0, 0, 24, 24) GUISetState(@SW_SHOW,$calling) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_Event_Close GUISetState(@SW_HIDE, $hudGUI) Case $msg = $exit GUIDelete($hudGUI) ExitLoop Case $msg = $callingpic $gp = WinGetPos($calling) $mp = MouseGetPos() While _IsPressed("1") $cp = MouseGetPos() WinMove($calling,'',$gp[0] - $mp[0] + $cp[0],$gp[1] - $mp[1] + $cp[1]) $cPos = WinGetPos("calling", "") $cPosX = $cPos[0] - 438 $cPosY = $cPos[1] - 256 If $cPosX = "5" AND $cPosY = "5" Then; If pic is in place ; do nothing Else MsgBox(0, "", "") $calling = GUICreate("calling", 24, 24, 5, 5,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$hudGUI) $callingpic = GUICtrlCreatePic(@scriptdir & "\poker icons\calling.gif", 0, 0, 24, 24); Create new pic EndIf WEnd Wend EndFunc While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
FireLordZi Posted January 20, 2008 Share Posted January 20, 2008 Does it require it all to reproduce the problem you're having?Edit:Also, why're you creating a new GUI on the line just above the GuiCtrlCreatePic, that might be what's messing up(because that window will not be shown, unless you do GuiSetState())I have no idea. While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
FreeFry Posted January 20, 2008 Share Posted January 20, 2008 I have no idea. Hmm, you're wanting to be able to move the picture outside of the "main" gui's window, am I correct? If that's the case then it explains why you're creating a new Gui to be able to do that. Still, have you tried adding a GuiSetState() (to make the new gui visible) after creating the picture? Might solve the problem... Link to comment Share on other sites More sharing options...
FireLordZi Posted January 20, 2008 Share Posted January 20, 2008 (edited) Hmm, you're wanting to be able to move the picture outside of the "main" gui's window, am I correct? If that's the case then it explains why you're creating a new Gui to be able to do that. Still, have you tried adding a GuiSetState() (to make the new gui visible) after creating the picture? Might solve the problem...Edit:-Solved-Much thanks to FreeFry.8) Edited January 20, 2008 by FireLordZi While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
FreeFry Posted January 20, 2008 Share Posted January 20, 2008 (edited) Hihi, no problemo. Was a little slow to catch on what you where trying to do at first. Edit: I took the libery to optimize/clean it up a little(and also add a few features, like being able to move the newly created "stickys" after they have been created and positonized), I hope you don't mind: expandcollapse popup#include <guiconstants.au3> #include <misc.au3> #include <array.au3> Dim $Picture = @ScriptDir & "\toot.gif" Dim $aGUIHandles[1] = [GUICreate("Heads-up Display Stickers", 150, 250)] $exit = GUICtrlCreateButton("Close", 5, 233, 40, 15) $pic = GUICtrlCreatePic(@ScriptDir & "\toot.gif", 0, 0, 24, 24) GUISetBkColor(0xF2F2F2, $aGUIHandles[0]) GUICtrlSetFont($exit, 8, 400, -1, "Arial Bold") WinSetOnTop($aGUIHandles[0], "", 1) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_Event_Close GUISetState(@SW_HIDE, $aGUIHandles[0]) Case $exit Exit Case $pic _HandleChildGui() EndSwitch If _IsPressed("1") Then For $i = 1 To UBound($aGUIHandles) - 1 If WinActive($aGUIHandles[$i]) Then _HandleChildGui($aGUIHandles[$i]) Next EndIf WEnd Func _HandleChildGui($i_ChildHandle = 0) If $i_ChildHandle Then GUISwitch($i_ChildHandle) Else $i_ChildHandle = GUICreate("", 24, 24, 5, 5, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $aGUIHandles[0]) GUICtrlCreatePic($Picture, 0, 0, 24, 24) GUISetState() EndIf While _IsPressed("1") WinMove($i_ChildHandle, "", MouseGetPos(0), MouseGetPos(1)) WEnd ReDim $aGUIHandles[UBound($aGUIHandles) + 1] $aGUIHandles[UBound($aGUIHandles) - 1] = $i_ChildHandle GUISwitch($aGUIHandles[0]) EndFunc ;==>_HandleChildGui Edited January 20, 2008 by FreeFry Link to comment Share on other sites More sharing options...
FireLordZi Posted January 20, 2008 Share Posted January 20, 2008 That's some awesome code. Very neat btw And very nice on being able to move the newly created stickies. Great job. While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
FreeFry Posted January 21, 2008 Share Posted January 21, 2008 Hehe, thanks. I hope it's what you where looking for. My guess is right about this being used to be able to create several "sticky" images for example right? Like notices perhaps? Link to comment Share on other sites More sharing options...
FireLordZi Posted January 22, 2008 Share Posted January 22, 2008 Exactly While Alive() { DrinkWine(); }AutoIt Programmer 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