gottygolly Posted November 29, 2014 Share Posted November 29, 2014 (edited) Not sure how to explain this but when I click on the square button it shows up in the button (Square) that it makes. Anyone know how to avoid this problem? (You pretty much have to run the code to understand my problem) expandcollapse popup#include<misc.au3> Global $obj $gui = GUICreate("Box Fun",@DesktopWidth/3,@DesktopHeight/3,-1,-1) Opt("GUIOnEventMode",1) $buy = GUICtrlCreateButton("Square",5,5,100,20) GUISetOnEvent(-3,"_Exit") GUICtrlSetOnEvent($buy,"Buy_Square") $bought_s = False $total = 1 GUISetState() While 1 Sleep(10) If $bought_s = True Then Buy_Square() EndIf WEnd Func _Exit() Exit EndFunc Func Buy_Square() $mp = GUIGetCursorInfo($gui) If $bought_s = False Then $obj = GUICtrlCreateButton("",$mp[0]-25,$mp[1]-25,50,50) GUICtrlSetBkColor($obj,Random(1,0xFFFFFF)) GUICtrlSetState($obj,128) $bought_s = True EndIf If $bought_S = True Then $cp = ControlGetPos($gui,"",$obj) ControlMove($gui,"",$obj,$mp[0]-25,$mp[1]-25) EndIf If _IsPressed("01") Then $bought_s = False ControlMove($gui,"",$obj,$mp[0]-25,$mp[1]-25) EndIf EndFunc Sorry if i'm not explaining it enough or right I just don't know how to explain it properly. Edited November 29, 2014 by gottygolly Link to comment Share on other sites More sharing options...
BrewManNH Posted November 29, 2014 Share Posted November 29, 2014 I ran it, I saw what it's doing, I just have no clue what it is you want it to do. That is some messed up code. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
gottygolly Posted November 29, 2014 Author Share Posted November 29, 2014 (edited) It's something for a different script that i'm working on but I don't know why it's doing that, do you happen to know how to fix that? I just want it to make a button and stuff but when it makes a button it basically takes a snapshot of the background behind it. What do you mean by some messed up code? Edited November 29, 2014 by gottygolly Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 29, 2014 Moderators Share Posted November 29, 2014 1. Figure out how to use While _IsPressed("01"), that backwards loop is only asking for disaster 2. WM_PAINT for that new control button 3. Or disable the $buy button anytime the $obj button is within the $buy buttons rect boundary 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...
alienclone Posted November 29, 2014 Share Posted November 29, 2014 1. Figure out how to use While _IsPressed("01"), that backwards loop is only asking for disaster 2. WM_PAINT for that new control button 3. Or disable the $buy button anytime the $obj button is within the $buy buttons rect boundary disabling the button seems to work good if OP is ok with the temporary flicker of the buy button. expandcollapse popup#include<misc.au3> Global $obj $gui = GUICreate("Box Fun",@DesktopWidth/3,@DesktopHeight/3,-1,-1) Opt("GUIOnEventMode",1) $buy = GUICtrlCreateButton("Square",5,5,100,20) GUISetOnEvent(-3,"_Exit") GUICtrlSetOnEvent($buy,"Buy_Square") $bought_s = False $total = 1 GUISetState() While 1 Sleep(10) If $bought_s = True Then Buy_Square() GUICtrlSetState($buy,64) EndIf WEnd Func _Exit() Exit EndFunc Func Buy_Square() GUICtrlSetState($buy,128) $mp = GUIGetCursorInfo($gui) If $bought_s = False Then $obj = GUICtrlCreateButton("",$mp[0]-25,$mp[1]-25,50,50) GUICtrlSetBkColor($obj,Random(1,0xFFFFFF)) GUICtrlSetState($obj,128);128 $bought_s = True EndIf If $bought_S = True Then $cp = ControlGetPos($gui,"",$obj) ControlMove($gui,"",$obj,$mp[0]-25,$mp[1]-25) EndIf If _IsPressed("01") Then $bought_s = False ControlMove($gui,"",$obj,$mp[0]-25,$mp[1]-25) EndIf EndFunc If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version 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