FireLordZi Posted February 7, 2008 Share Posted February 7, 2008 I have a script that creates a gui about as small as an icon and I overlayed a picture file onto it so it looks like just like an icon. I move this icon all over my desktop and when I move it from its starting position another one is created in it's place. Well when I place the icon/gui I can't move it anymore. How can I improve my code so I can move it after it is placed? expandcollapse popup#include <GUIConstants.au3> #include <Misc.au3> $hudGUI = GUICreate("", 150, 250) GUISetState() GUISetBkColor(0xF2F2F2, $hudGUI) WinSetOnTop("", "", 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 GUIDelete($hudGUI) ExitLoop Case $msg = $exit GUISetState(@SW_HIDE, $hudGUI) 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 WEnd If Not ($cPosX = "5" And $cPosY = "5") Then $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 GUISetState() EndIf EndSelect Wend Help and suggestions would be greatly appreciated... While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
FireLordZi Posted February 8, 2008 Author Share Posted February 8, 2008 bump While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
Achilles Posted February 8, 2008 Share Posted February 8, 2008 Could you provide the pictures? My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
FireLordZi Posted February 8, 2008 Author Share Posted February 8, 2008 (edited) Tell me if it appears ok. Edited February 8, 2008 by FireLordZi While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
FireLordZi Posted February 8, 2008 Author Share Posted February 8, 2008 (edited) What did you need it for? Edited February 8, 2008 by FireLordZi While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
Achilles Posted February 8, 2008 Share Posted February 8, 2008 What did you need it for?I was trying to replicate the problem, and there were pictures in your script so I thought they might help. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Achilles Posted February 8, 2008 Share Posted February 8, 2008 Alright, your code has an extra part that is causing your problem. I commented it out, try this: (I also changed the picture directory so you might need to change that back.) expandcollapse popup#include <GUIConstants.au3> #include <Misc.au3> $hudGUI = GUICreate("", 150, 250) GUISetState() GUISetBkColor(0xF2F2F2, $hudGUI) WinSetOnTop("", "", 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 & "\calling.gif", 0, 0, 24, 24) GUISetState(@SW_SHOW,$calling) $cPosX = 0 $cPosY = 0 While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_Event_Close GUIDelete($hudGUI) ExitLoop Case $msg = $exit GUISetState(@SW_HIDE, $hudGUI) 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 WEnd ;~ If Not ($cPosX = "5" And $cPosY = "5") Then ;~ $calling = GUICreate("calling", 24, 24, 5, 5, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hudGUI) ;~ $callingpic = GUICtrlCreatePic(@ScriptDir & "\calling.gif", 0, 0, 24, 24); Create new pic ;~ GUISetState() ;~ EndIf EndSelect Wend My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
FireLordZi Posted February 8, 2008 Author Share Posted February 8, 2008 You took out the most important and necessary part in the code. The code you commented out re-creates the picture when it is moved and I put that there on purpose. I need to find a way to edit it where it still re-creates a picture and the placed ones can still move. While Alive() { DrinkWine(); }AutoIt Programmer Link to comment Share on other sites More sharing options...
FireLordZi Posted February 8, 2008 Author Share Posted February 8, 2008 Problem solved. Big thanks to Qsek. 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