Tomb Posted December 12, 2007 Share Posted December 12, 2007 i am trying to make a basic gui that creates a picture and can move it around the gui freely with just up down left and right hotkeys. i so far har have this. I can move the image somewhat, the only problem is that i can only seem to move it to 4 different places. expandcollapse popup#include <GUIConstants.au3> $x = 200 $y = 100 GUICreate("GUI", 600, 600, -1, -1) GUISetBkColor(0x000000) GUISetState(@SW_SHOW) HotKeySet("{up}", "_UpArrow") HotKeySet("{down}", "_DownArrow") HotKeySet("{left}", "_LeftArrow") HotKeySet("{right}", "_RightArrow") HotKeySet("{ESC}", "_zExitScript") Func _UpArrow() HotKeySet ("{up}") $u = ($x + 0) $ub = ($y - 100) GUICtrlSetPos("3", $u, $ub ) HotKeySet ( "{up}" , "_UpArrow" ) EndFunc Func _DownArrow() HotKeySet ("{down}") $d = ($x + 0) $db = ($y + 100) GUICtrlSetPos("3", $d, $db ) HotKeySet ( "{down}" , "_DownArrow" ) EndFunc Func _LeftArrow() HotKeySet ("{left}") $l = ($x - 100) $lb = ($y + 0) GUICtrlSetPos("3", $l, $lb ) HotKeySet ( "{left}" , "_LeftArrow" ) EndFunc Func _RightArrow() HotKeySet ("{right}") $r = ($x + 100) $rb = ($y + 0) GUICtrlSetPos("3", $r, $rb ) HotKeySet ( "{right}" , "_RightArrow" ) EndFunc Func _zExitScript() Exit EndFunc ;==>_zExitScript GuiCtrlCreatePic("1.jpg",$x, $y, 0, 0) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Link to comment Share on other sites More sharing options...
The Ape Posted December 12, 2007 Share Posted December 12, 2007 Not based of your code... Just an example I already had. expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Global $dot $GUI = GUICreate("Test", 500, 500, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $dot = GUICtrlCreateLabel(".", 50, 50, 5, 5) GUICtrlSetBkColor(-1, 0x000000) HotKeySet("{DOWN}", "_ScrollDown") HotKeySet("{UP}", "_ScrollUp") HotKeySet("{LEFT}", "_ScrollLeft") HotKeySet("{RIGHT}", "_ScrollRight") GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Func _ScrollDown() $GetPos = ControlGetPos($GUI, "", $dot) ControlMove($GUI, "", $dot, $GetPos[0], $GetPos[1]+5) EndFunc Func _ScrollUp() $GetPos = ControlGetPos($GUI, "", $dot) ControlMove($GUI, "", $dot, $GetPos[0], $GetPos[1]-5) EndFunc Func _ScrollLeft() $GetPos = ControlGetPos($GUI, "", $dot) ControlMove($GUI, "", $dot, $GetPos[0]-5, $GetPos[1]) EndFunc Func _ScrollRight() $GetPos = ControlGetPos($GUI, "", $dot) ControlMove($GUI, "", $dot, $GetPos[0]+5, $GetPos[1]) EndFunc Func _Exit() Exit EndFunc FixJaw.comTriad-Art.com Link to comment Share on other sites More sharing options...
Tomb Posted December 12, 2007 Author Share Posted December 12, 2007 (edited) hmm i will try integrating this into my code. Edited December 12, 2007 by Tomb616 Link to comment Share on other sites More sharing options...
The Ape Posted December 12, 2007 Share Posted December 12, 2007 (edited) i saw that in the helpfile. the only problem is, i want the image to just move in the gui, and the example in the helpfile allows the image to move anywhere at all.I wrote that myself. Where is that in the help file?It's the same basic concept, just replace the label with your pic. Edited December 12, 2007 by The Ape FixJaw.comTriad-Art.com Link to comment Share on other sites More sharing options...
The Ape Posted December 12, 2007 Share Posted December 12, 2007 (edited) In each move function, you need to get the position of the pic... then move it (slightly if desired). Right now, your functions just tell your pic to move to one specific location. Edited December 12, 2007 by The Ape FixJaw.comTriad-Art.com Link to comment Share on other sites More sharing options...
Tomb Posted December 12, 2007 Author Share Posted December 12, 2007 I think this will work. Thank you for your assistance. Link to comment Share on other sites More sharing options...
Tomb Posted December 12, 2007 Author Share Posted December 12, 2007 (edited) now i have another question. can i change the 1.jpg to appear as another image, such as 2.jpg i have in my folder if i press a hotkey. like if i press up, my 1.jpg will now be 2.jpg, and move to the new location. if i press down it can be 3.jpg, and move down to the new location. Edited December 12, 2007 by Tomb616 Link to comment Share on other sites More sharing options...
Tomb Posted December 13, 2007 Author Share Posted December 13, 2007 is there a way? Link to comment Share on other sites More sharing options...
therks Posted December 13, 2007 Share Posted December 13, 2007 GUICtrlSetImage. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Tomb Posted December 13, 2007 Author Share Posted December 13, 2007 i am reading about it in the help file, and i am somewhat confused Link to comment Share on other sites More sharing options...
therks Posted December 13, 2007 Share Posted December 13, 2007 Maybe because your code is a little weird anyway. I see you using this: GUICtrlSetPos("3", $u, $ub )Where is that "3" coming from? You should not be using that value directly, as it could change, you should instead be using the variable returned from GUICtrlCreatePic.$picture = GUICtrlCreatePic('c:\pic.gif', 0, 0, 100, 100) GUICtrlSetPos($picture, $u, $ub )oÝ÷ ظ¤zØZ´¢± +k'"f z+wöÈî²Ö¬²)©æ®¶sbb33c·7GW&RÒuT7G&Ä7&VFU2b33¶3¢b3#·2ævbb33²Â¤uT7G&Å6WDÖvRb33c·7GW&RÂb33¶3¢b3#¶æWw2ævbb33²Just like that. My AutoIt Stuff | My Github 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