Jump to content

gottygolly

Active Members
  • Posts

    162
  • Joined

  • Last visited

  • Days Won

    1

gottygolly last won the day on November 27 2014

gottygolly had the most liked content!

Recent Profile Visitors

214 profile views

gottygolly's Achievements

  1. I can get the coords for where to set the PixelCheckSum region, I grab the position and size of the window and do a little calculation $Win = "Chrome" $Win_Pos = WinGetPos($Win) $Pixel_Check = PixelChecksum($Win_Pos[0]+($Win_Pos[2]/8),$Win_Pos[1]+($Win_Pos[3]/1.4),$Win_Pos[0]+($Win_Pos[2]/1.9),$Win_Pos[1]+($Win_Pos[3]/1.2)) If the window changes position or size at any point (Eg. I drag it by accident) the script still checks in the correct position of the window. However, sometimes it doesn't update the change properly and starts grabbing from a different region, I'd like to be able to see the region where the script is currently looking so I'm aware of any changes. Know of anyways to display the region PixelCheckSum is set to? Thank you for the help
  2. Just curious on how you guys determine the region pixelchecksum is looking in. I've been trying to display the region (Basically a box of where it's looking) for ease of use but can't figure out a good way of doing it, I checked through the forums and can't really find anything. My bad if it's something stupid Thanks in advance
  3. Appreciate it I figured out a solution that works, I added another _IsPressed() that waits till it's no longer pressed then it calls the function #include <Misc.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> $gui = GUICreate("Example [Sent: 0]",300,120,-1,-1) Opt("GUIOnEventMode",1) GUISetOnEvent(-3,"_Exit") $text = GUICtrlCreateInput("",5,5,290,20) GUICtrlSendMsg($text,$EM_SETCUEBANNER,False,"Press Left Control To Send Text") $invis = GUICtrlCreateLabel("",-50,-50,0,0) GUICtrlSetState($invis,$GUI_FOCUS) $Counter = 0 GUISetState() While 1 If _IsPressed("A2") Then While _IsPressed("A2") Sleep(10) WEnd $Counter += 1 WinSetTitle($gui,"","Example [Sent: "&$Counter&"]") Send("Beep Bop - ") EndIf Sleep(10) WEnd Func _Exit() Exit EndFunc
  4. Kind of odd what's going on When I press Left Ctrl -_Ispressed("A2")- my computer thinks the key is being held down causing a bunch of problems for me. Even when I stop the script my computer thinks the key is held down. What's even odder is I set it up to count how many times it detected the key being pressed and it would stop then, it only messes up when I try to add a Send or anything else to it. I have tried it with a lot of other keys as well and they all gave the same problem, I also checked sticky keys and they are all turned off. Thank you in advance for any tips or suggestions! Friendly note: If you decide to run the code below it will make your system act odd, a simple fix is to press "Ctrl + Alt + Del" and then cancel. It fixes whatever is causing the problem. #include <Misc.au3> $gui = GUICreate("Auto Typer",300,120,-1,-1) Opt("GUIOnEventMode",1) GUISetOnEvent(-3,"_Exit") $text = GUICtrlCreateInput("",5,5,290,20) GUICtrlSetState($text,1) Global $stunt = False, $p = 0 $send = GUICtrlCreateCheckbox("Send",5,50,100,20) GUISetState() While 1 If _IsPressed("A2") Then If GUICtrlRead($send) = 4 Then $p += 1 GUICtrlSetData($text,$p) EndIf $stunt = True EndIf If $stunt = True And GUICtrlRead($send) = 1 Then Send("Hi") $stunt = False EndIf Sleep(10) WEnd Func _Exit() Exit EndFunc
  5. Thank you for the reply and sharing all that information. I've been very busy at work so I haven't had time to look through all of your code and try to understand it. One quick dumb question however - The line: Global $heart_buffer[$MAX_HEART_COUNT][12] How is that used exactly? I understand the [$MAX_HEART_COUNT] but not the [12] part.
  6. I made this script just out of boredom and started to try and make it so when the boxes hit each other they would bounce like they do on the walls. Any ideas on how to get this done? (I tried nesting another For loop inside the while loop and set it to detect it but it was too demanding on my PC) #include<guiconstants.au3> #include <ButtonConstants.au3> #include <GuiMenu.au3> #include <String.au3> $title = "GUI" $gui = GUICreate($title,640,480,-1,-1) Opt("GUIOnEventMode",1) GUISetOnEvent(-3,"_Exit") $sec = @SEC $msec = @MSEC Local $box[10] Local $speed_x[UBound($box)],$speed_y[UBound($box)] For $i = 0 To UBound($box)-1 $box[$i] = GUICtrlCreateLabel("",random(0,620,1),random(0,460,1),20,20) $random = Random(0,1,1) GUICtrlSetBkColor($box[$i],0x000000) If $random = 1 Then $speed_x[$i] = 1 $speed_y[$i] = 1 ElseIf $random = 0 Then $speed_x[$i] = -1 $speed_y[$i] = -1 EndIf Next GUISetState() While 1 $s = @SEC $m = @MSEC For $i = 0 To UBound($box)-1 $box_cp = ControlGetPos($gui,"",$box[$i]) If $box_cp[0] <= 0 Then $speed_x[$i] *= -1 ElseIf $box_cp[1] <= 0 Then $speed_y[$i] *= -1 ElseIf $box_cp[0] + $box_cp[2] >= 640 Then $speed_x[$i] *= -1 ElseIf $box_cp[1] + $box_cp[3] >= 480 Then $speed_y[$i] *= -1 EndIf GUICtrlSetPos($box[$i],$box_cp[0]-$speed_x[$i],$box_cp[1]-$speed_y[$i]) Next Sleep(10) WEnd Func _Exit() Exit EndFunc
  7. Thank you for the quick reply, I have worked with those functions in the past but I was wondering if it was possible to use GUICtrlSetOnEvent() instead of those. Melba that works and I guess is the only way to do that, thank you for the quick replies EDIT: typo
  8. Out of curiosity is it possible to make this work? GUICtrlSetOnEvent("{LEFT}","_Function") 
  9. I used the guictrlgetbkcolor to get the color since the color can change. It can be blue/green/black/white/brown. And it's just a little game I want to see if I can make it.
  10. I've been working on this every now and then at work and so far this is what I have come up with. #include <WinAPIGdi.au3> #include <File.au3> #include <iniread.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $gui = GUICreate("",640,600,-1,-1) Opt("GUIOnEventMode",1) GUISetOnEvent(-3,"_Exit") $wall = "" $left = GUICtrlCreateDummy() $right = GUICtrlCreateDummy() $down = GUICtrlCreateDummy() $up = GUICtrlCreateDummy() Local $arrow_keys[4][2] = [["{LEFT}",$left],["{RIGHT}",$right],["{Down}",$down],["{UP}",$up]] GUISetAccelerators($arrow_keys,$gui) For $i = 0 To 3 GUICtrlSetOnEvent($arrow_keys[$i][1],"_Keys") Next $color = 0x000000 $w = WinGetPos($gui) $x = 0 $y = 0 Local $label[3072] For $i = 0 To 3071 $label[$i] = GUICtrlCreateLabel("",$x,$y,10,10) GUICtrlSetOnEvent($label[$i],"_Click") $x += 10 If $x = 640 Then $y += 10 $x = 0 EndIf GUICtrlSetBkColor($label[$i],0xFFFFFF) Next $char = GUICtrlCreateLabel("",200,200,10,10) GUICtrlSetBkColor($char,0xa93838) $green = GUICtrlCreateButton("Green",0,500,100,20) GUICtrlSetOnEvent($green,"_Color") $blue = GUICtrlCreateButton("Blue",0,525,100,20) GUICtrlSetOnEvent($blue,"_Color") $eraser = GUICtrlCreateButton("Erase",0,550,100,20) GUICtrlSetOnEvent($eraser,"_Color") $clear = GUICtrlCreateButton("Clear",105,500,100,20) GUICtrlSetOnEvent($clear,"_Clear") $brown = GUICtrlCreateButton("Brown",105,525,100,20) GUICtrlSetOnEvent($brown,"_Color") $default = GUICtrlCreateButton("Default",105,550,100,20) GUICtrlSetOnEvent($default,"_Color") $menu = GUICtrlCreateMenu("Options") $save = GUICtrlCreateMenuItem("Save",-1) GUICtrlSetOnEvent($save,"_Save") $load = GUICtrlCreateMenuItem("Load",-1) GUICtrlSetOnEvent($load,"_Load") $tree_id = "" $wood_total = 0 $wood = GUICtrlCreateLabel("Wood: x"&$wood_total,300,500) GUISetOnEvent($GUI_EVENT_SECONDARYDOWN,"_Right_Click") $tree_pos = "" $chopping = False Local $sec = @SEC $fishing = False ;$file_name = "" $tree = "" $fish_menu = "" GUISetState() While 1 $new_Sec = @SEC If $new_sec <> $sec Then $Sec = $new_Sec EndIf If $chopping = True Then $cp = ControlGetPos($gui,"",$char) $tree_pos = ControlGetPos($gui,"",$tree_id) $cp2 = $tree_pos #cs If $char_pos[0] < $tree_pos[0] Then GUICtrlSetPos($char,$char_pos[0]+10,$char_pos[1]) ElseIf $char_pos[0]-10 > $tree_pos[0] Then GUICtrlSetPos($char,$char_pos[0]-10,$char_pos[1]) ElseIf $char_pos[1]+10 < $tree_pos[1] Then GUICtrlSetPos($char,$char_pos[0],$char_pos[1]+10) ElseIf $char_pos[1]+10 > $tree_pos[1] Then GUICtrlSetPos($char,$char_pos[0],$char_pos[1]-10) EndIf #ce If $cp2[0] < $cp[0] Then If $cp[0] = $cp2[0]+10 And $cp[1] = $cp2[1] Then _chop() $chopping = False Else GUICtrlSetPos($char,$cp[0]-2,$cp[1]) EndIf EndIf If $cp2[1] < $cp[1] Then If $cp[1] = $cp2[1]+10 And $cp[0] = $cp2[0] Then _chop() $chopping = False Else GUICtrlSetPos($char,$cp[0],$cp[1]-2) EndIf EndIf If $cp2[0] > $cp[0] Then If $cp[0]+10 = $cp2[0] And $cp[1] = $cp2[1] Then _chop() $chopping = False Else GUICtrlSetPos($char,$cp[0]+2,$cp[1]) EndIf EndIf If $cp2[1] > $cp[1] Then If $cp[1]+10 = $cp2[1] And $cp[0] = $cp2[0] Then _chop() $chopping = False Else GUICtrlSetPos($char,$cp[0],$cp[1]+2) EndIf EndIf ; #ce If $cp2[0] > $cp[0] And $cp2[1] < $cp[1] Then ;Left Corner GUICtrlSetPos($char,$cp[0]+2,$cp[1]-2) EndIf If $cp2[0] < $cp[0] And $cp2[1] < $cp[1] Then GUICtrlSetPos($char,$cp[0]-2,$cp[1]-2) EndIf If $cp2[0] > $cp[0] And $cp2[1] > $cp[1] Then GUICtrlSetPos($char,$cp[0]+2,$cp[1]+2) EndIf If $cp2[0] < $cp[0] And $cp2[1] > $cp[1] Then GUICtrlSetPos($char,$cp[0]-2,$cp[1]+2) EndIf ;$chopping = False EndIf If $fishing = True Then $cp = ControlGetPos($gui,"",$char) $tree_pos = ControlGetPos($gui,"",$tree_id) $cp2 = $tree_pos If $cp2[0] < $cp[0] Then If $cp[0] = $cp2[0]+10 And $cp[1] = $cp2[1] Then _fish() $fishing = False Else GUICtrlSetPos($char,$cp[0]-2,$cp[1]) EndIf EndIf If $cp2[1] < $cp[1] Then If $cp[1] = $cp2[1]+10 And $cp[0] = $cp2[0] Then _fish() $fishing = False Else GUICtrlSetPos($char,$cp[0],$cp[1]-2) EndIf EndIf If $cp2[0] > $cp[0] Then If $cp[0]+10 = $cp2[0] And $cp[1] = $cp2[1] Then _fish() $fishing = False Else GUICtrlSetPos($char,$cp[0]+2,$cp[1]) EndIf EndIf If $cp2[1] > $cp[1] Then If $cp[1]+10 = $cp2[1] And $cp[0] = $cp2[0] Then _fish() $fishing = False Else GUICtrlSetPos($char,$cp[0],$cp[1]+2) EndIf EndIf If $cp2[0] > $cp[0] And $cp2[1] < $cp[1] Then ;Left Corner GUICtrlSetPos($char,$cp[0]+2,$cp[1]-2) EndIf If $cp2[0] < $cp[0] And $cp2[1] < $cp[1] Then GUICtrlSetPos($char,$cp[0]-2,$cp[1]-2) EndIf If $cp2[0] > $cp[0] And $cp2[1] > $cp[1] Then GUICtrlSetPos($char,$cp[0]+2,$cp[1]+2) EndIf If $cp2[0] < $cp[0] And $cp2[1] > $cp[1] Then GUICtrlSetPos($char,$cp[0]-2,$cp[1]+2) EndIf EndIf Sleep(10) WEnd Func _Exit() Exit EndFunc Func _Color() $id = @GUI_CtrlHandle If $id = GUICtrlGetHandle($blue) Then $color = 0x000FF0 ElseIf $id = GUICtrlGetHandle($green) Then $color = 0x00FF00 ElseIf $id = GUICtrlGetHandle($eraser) Then $color = 0xFFFFFF ElseIf $id = GUICtrlGetHandle($brown) Then $color = 0x8B4513 ElseIf $id = GUICtrlGetHandle($default) Then $color = 0x000000 endif EndFunc Func _Click() $id = @GUI_CtrlId If $color = 0x8B4513 Then $tree = GUICtrlCreateContextMenu($id) $tree_menu = GUICtrlCreateMenuItem("Chop",$tree) GUICtrlSetOnEvent($tree_menu,"_Chop_Start") EndIf If $color = 0x000FF0 Then $fish_menu = GUICtrlCreateContextMenu($id) $fish_menu_item = GUICtrlCreateMenuItem("Fish",$fish_menu) GUICtrlSetOnEvent($fish_menu_item,"_Fish_Start") EndIf GUICtrlSetBkColor($id,$color) $item_pos = ControlGetPos($gui,"",$id) $char_pos = ControlGetPos($gui,"",$Char) $wall = $item_pos[0]+$item_pos[2] <= $char_pos[0] EndFunc Func _save() $file_name = InputBox("File name","Please specify the name of the file you wish to save."&@crlf&"Please do not put "&'".ini"'&" in the name it will mess me up.") For $i = 0 To UBound($label)-1 GUICtrlSetData($blue,"Blue "&(UBound($label)-1)-$i) IniWrite(@ScriptDir&"\"&$file_name&".ini","Save",GUICtrlGetHandle($label[$i]),GUICtrlGetBkColor($label[$i])) Next MsgBox(0,"Success!","You have saved the layout!") EndFunc Func _Keys() $char_pos = ControlGetPos($gui,"",$Char) If @GUI_CtrlId = 3 And $char_pos[0] > 0 Then ;left GUICtrlSetPos($char,$char_pos[0]-2,$char_pos[1]) ElseIf @GUI_CtrlId = 4 And $char_pos[0]+10 < 640 Then ;right GUICtrlSetPos($char,$char_pos[0]+2,$char_pos[1]) ElseIf @GUI_CtrlId = 5 And $char_pos[1]+10 < 480 Then ;down GUICtrlSetPos($char,$char_pos[0],$char_pos[1]+2) ElseIf @GUI_CtrlId = 6 And $char_pos[1] > 0 Then ;up GUICtrlSetPos($char,$char_pos[0],$char_pos[1]-2) EndIf EndFunc Func _clear() For $i = 0 To UBound($label)-1 GUICtrlSetBkColor($label[$i],0x036427) GUICtrlSetBkColor($label[$i],0xFFFFFF) Next EndFunc Func GUICtrlGetBkColor($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) EndIf Local $hDC = _WinAPI_GetDC($hWnd) Local $iColor = _WinAPI_GetPixel($hDC, 0, 0) _WinAPI_ReleaseDC($hWnd, $hDC) Return $iColor EndFunc ;==>GUICtrlGetBkColor Func _Load() $load_file = FileOpenDialog("Map ini",@scriptdir,"Text Files(*.ini)") $ini_read = _IniReadSectionEx($load_file,"Save") $p = 0 For $i = 1 To $ini_read[0][0]-1 GUICtrlSetBkColor($label[$p],$ini_read[$i][1]) $p += 1 Next MsgBox(0,"Success!","The load was successful!") EndFunc Func _Chop() $menu_id = @GUI_CtrlId For $i = 0 To 0 GUICtrlSetBkColor($tree_id,0x8B4513) Sleep(100) GUICtrlSetBkColor($tree_id,0xbf7529) Sleep(100) GUICtrlSetBkColor($tree_id,0xc68441) Sleep(100) GUICtrlSetBkColor($tree_id,0xcd9359) Sleep(100) GUICtrlSetBkColor($tree_id,0xdbb288) Sleep(100) GUICtrlSetBkColor($tree_id,0xFFFFFF) Next $wood_total += Random(1,4,1) GUICtrlSetData($wood,"Wood: x"&$wood_total) GUICtrlDelete($tree) ;EndIf EndFunc Func _Fish() EndFunc Func _Right_Click() If $fishing = True Or $chopping = True Then Else $tree_find = GUIGetCursorInfo($gui) $tree_id = $tree_find[4] EndIf EndFunc Func _Chop_start() $chopping = True EndFunc Func _Fish_start() If GUICtrlGetBkColor($tree_id+63) = 0x000FF0 And GUICtrlGetBkColor($tree_id+65) = 0x000FF0 And GUICtrlGetBkColor($tree_id+64) = 0x000FF0 And GUICtrlGetBkColor($tree_id - 64) = 0x000FF0 And GUICtrlGetBkColor($tree_id - 1) = 0x000FF0 And GUICtrlGetBkColor($tree_id + 1) = 0x000FF0 Then $fishing = True EndIf EndFunc For the most part it works but it uses controls instead of GDI which I hope to re-make this entire things in GDI I just want to make it simple like this before I get real technical with it. I've added water(blue) and trees(brown). I am mainly posting this to get some feedback on it and see what others think of it. In order to fish at a spot the water has to be 3x3, if you run the script you'll understand what I mean by 3x3. I'm planning on trying to get collision detection for the water that way you can right click > fish anywhere on the water and it'll stop on the edge rather than going to the center. Another plan is going to be an auto generated terrain type where it will auto place water and sand and it will also make trees that will regrow. All this is future plans, I'm going to finish it using controls and once I finish here I'll switch over the GDI. Let me know if I should change something to make it flow a lot more smoothly. Thanks!
  11. Thanks for the help man, I guess all that I needed was the $GUI_EVENT_SECONDARYUP variable. Re-made it into GUIOnEventMode form since that is what my script is in. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 438, 192, 124) Opt("GUIOnEventMode",1) GUISetOnEvent(-3,"_exit") $Button1 = GUICtrlCreateButton("Button1", 96, 72, 145, 105) $Button2 = GUICtrlCreateButton("Button2", 316, 232, 145, 105) GUISetOnEvent($GUI_EVENT_SECONDARYUP,"button") GUISetState() While 1 Sleep(10) WEnd Func _exit() Exit EndFunc Func button() $p = GUIGetCursorInfo($Form1) MsgBox(0,"","ID: "&$p[4]&@CRLF&GUICtrlRead($p[4])) EndFuncThanks for the help!
  12. In my script I have labels and if you right click on a label it gives you an option to interact with the label via contextmenu. My problem is I have it setup that you can change the label and based on how you changed it, it will change the contextmenu. If you left click you can get the id of the control through @‌gui_ctrlid, my curiosity lies in whether or not you can get the id off of a right click so I can set the contextmenu information accordingly to the right label. (sorry if I was confusing, currently on my phone)
  13. I realized that the function that I posted I had modified and I modified it to work properly, in my script instead of having this: Func _Click() $id = @GUI_CtrlId GUICtrlSetBkColor($id,$color) EndFunc I had this: Func _Click() $id = @GUI_CtrlId GUICtrlSetBkColor($label[$id],$color) EndFunc A simple mistake but thank you for the help melba, I compared your example code to my script and found the error that way. Appreciate it!
  14. I wasn't sure how to search for this but I did try and couldn't find anything. In my script I have a for loop create a bunch of labels and through this I was wanting to be able to click on any label and call the function "_Click" so that I can change the color of the box accordingly. I originally started using @‌gui_ctrlid to get the id of the label but I realized that once I started adding more code it would mess with getting the correct id. I thought I could use the macro @gui_ctrlhandle but I'm not sure on how to interact with the control through this (normally I would use the ControlId) The code below should hopefully help you understand if you are confused. Func _Click() $id = @GUI_CtrlHandle GUICtrlSetBkColor($id,$color) EndFuncThanks for any help and if you need additional information please let me know so I can aid you in aiding me.
  15. Sorry for not replying sooner, thank you pcjunki I'll look into it when I get home.
×
×
  • Create New...