gottygolly Posted December 10, 2014 Share Posted December 10, 2014 I know that the _WinAPI_RedrawWindow() function is making everything blink but it's the only thing I could find to draw a line and keep all the controls. Is there something I'm missing so it won't blink so much? expandcollapse popup#include<misc.au3> #include<guiconstants.au3> #include<gdiplus.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> $gui = GUICreate(@HOUR&":"&@MIN&":"&@SEC,640,480,-1,-1) GUISetBkColor(0x000000) Opt("GUIOnEventMode",1) GUISetOnEvent(-3,"_Exit") Local $sec = @SEC $xc = Random(1,590) $yc = Random(1,430) $xt = Random(1,590) $yt = Random(1,430) $random_x = Round(Random(1,590),0) $random_y = Round(Random(1,430),0) $box = GUICtrlCreateButton("",$xc,$yc,50,50) $target = GUICtrlCreateButton("",$xt,$yt,50,50) GUICtrlSetBkColor($box,0x0000FF) GUICtrlSetBkColor($target,0xFF0000) $hits = 0 $hit = GUICtrlCreateLabel("Hits: "&$hits,5,5,100,15) GUICtrlSetFont($hit,12,700) GUICtrlSetColor($hit,0xFFFFFF) $move = True $i = 0 $stopped = False $t_pos_x = $random_x $t_pos_y = $random_y $t_pos = GUICtrlCreateLabel("Target Pos: "&$t_pos_x&","&$t_pos_y,0,25,150,20) GUICtrlSetColor($t_pos,0xFFFFFF) GUICtrlSetFont($t_pos,12,700) GUISetState() _GDIPlus_Startup() $hwnd = _GDIPlus_GraphicsCreateFromHWND($gui) $pen = _GDIPlus_PenCreate(0xFFFFFFFF, 2) $tRect = DllStructCreate($tagRECT) DllStructSetData($tRect, "Left", 0) DllStructSetData($tRect, "Top", 0) DllStructSetData($tRect, "Right", 640) DllStructSetData($tRect, "Bottom", 480) While 1 $mp = GUIGetCursorInfo($gui) $s = @SEC If $s <> $sec Then If $i >= 15 Then $random_x = Round(Random(1,590),0) $random_y = Round(Random(1,430),0) $i = 0 $stopped = False GUICtrlSetData($t_pos,"Target Pos: "&$random_x&","&$random_y) EndIf $i += 1 WinSetTitle($gui,"",@HOUR&":"&@MIN&":"&@SEC) $sec = $s EndIf attack() If $move = False Then test() EndIf If _IsPressed("01") Then test() EndIf $cp = ControlGetPos($gui,"",$target) $cp2 = ControlGetPos($gui,"",$box) _WinAPI_RedrawWindow($GUI,$tRect,0,BitOR($RDW_ERASE,$RDW_INVALIDATE)) $line = _GDIPlus_GraphicsDrawLine($hwnd,$cp[0]+25,$cp[1]+25,$cp2[0]+25,$cp2[1]+25,$pen) Sleep(10) WEnd Func _Exit() _GDIPlus_PenDispose($Pen) _GDIPlus_GraphicsDispose($hwnd) _GDIPlus_Shutdown() Exit EndFunc Func attack() $cp = ControlGetPos($gui,"",$target) $cp2 = ControlGetPos($gui,"",$box) If $move = True Then ;~ If $cp2[0] > $cp[0] Then ControlMove($gui,"",$box,$cp2[0]-1,$cp2[1]) EndIf If $cp2[1] > $cp[1] Then ControlMove($gui,"",$box,$cp2[0],$cp2[1]-1) EndIf If $cp2[0] < $cp[0] Then ControlMove($gui,"",$box,$cp2[0]+1,$cp2[1]) EndIf If $cp2[1] < $cp[1] Then ControlMove($gui,"",$box,$cp2[0],$cp2[1]+1) EndIf ;~ If $stopped = False Then If $cp[0] > $random_x Then ControlMove($gui,"",$target,$cp[0]-1,$cp[1]) EndIf If $cp[1] > $random_y Then ControlMove($gui,"",$target,$cp[0],$cp[1]-1) EndIf If $cp[0] < $random_x Then ControlMove($gui,"",$target,$cp[0]+1,$cp[1]) EndIf If $cp[1] < $random_y Then ControlMove($gui,"",$target,$cp[0],$cp[1]+1) EndIf If $cp[0] = $random_x And $cp[1] = $random_y Then $stopped = True EndIf EndIf ;~ If $cp2[0] <= $cp[0]+$cp[2] And $cp2[1] <= $cp[1]+$cp[3] And $cp2[0]+$cp2[2] >= $cp[0] And $cp2[1]+$cp2[3] >= $cp[1] Then ControlMove($gui,"",$target,9999,-9999) ControlMove($gui,"",$target,Random(1,590),Random(1,430)) $hits = $hits + 1 GUICtrlSetData($hit,"Hits: "&$hits) $random_x = Round(Random(1,590),0) $random_y = Round(Random(1,430),0) $i = 0 GUICtrlSetData($t_pos,"Target Pos: "&$random_x&","&$random_y) $stopped = False EndIf EndIf EndFunc Func test() $cp = ControlGetPos($gui,"",$box) $mp = GUIGetCursorInfo($gui) If $mp[0] >= $cp[0] And $mp[1] >= $cp[1] And $mp[0] <= $cp[0]+$cp[2] And $mp[1] <= $cp[1]+$cp[3] Then ControlMove($gui,"",$box,$mp[0]-25,$mp[1]-25) EndIf EndFunc Thanks in advance. Link to comment Share on other sites More sharing options...
MikahS Posted December 10, 2014 Share Posted December 10, 2014 (edited) Looks like game automation It is a game you made! My apologies EDIT: pretty cool, but what OS are you using? Edited December 10, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 10, 2014 Moderators Share Posted December 10, 2014 MikahS,How can this be game automation when it is an entirely self-contained script with no link to any third party app? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MikahS Posted December 10, 2014 Share Posted December 10, 2014 Exactly why I corrected myself Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
kylomas Posted December 10, 2014 Share Posted December 10, 2014 gottygolly, It do NOT blink at all for me (Win7 SP1 x64 NVidia controller)... Very slick, but how do you play? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
gottygolly Posted December 10, 2014 Author Share Posted December 10, 2014 Its something im working on to implent into a bigger script. I think i fixed it though thanks for the support. Link to comment Share on other sites More sharing options...
MikahS Posted December 10, 2014 Share Posted December 10, 2014 How did you fix it? Please post your solution so that if others have the same problem, they can see what you did to solve it. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
gottygolly Posted December 10, 2014 Author Share Posted December 10, 2014 I didn't fix it as it turns out so i'll keep trying different stuff. Before I thought maybe it was the computer I was running on but turns out to be the actual script instead (Or the computer still). 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