sixtors3 Posted May 3, 2014 Share Posted May 3, 2014 I have this script WinWaitActive("SomeKindOfProgram") $hWnd1 = WinGetHandle("[ACTIVE]") Sleep(1000) $flag = True $timer1 = TimerInit() $timer2 = TimerInit() While 1 $seconds1 = TimerDiff($timer1) * 1000 if $seconds1 > 10 Then If $flag = True Then Send("{LEFT DOWN}") Sleep(3000) Send("{LEFT UP}") $flag = False Else Send("{RIGHT DOWN}") sleep(3000) Send("{RIGHT UP}") $flag = True EndIf $timer1 = TimerInit() EndIf $seconds2 = TimerDiff($timer2) * 1000 If $seconds2 > 120 Then MouseClick("primary", 235, 260, 1) $timer2 = TimerInit() EndIF WEnd I have to problems with this at first I wanted to use instead of Send Func, SendControl and it worked with various keys such as UP / y (those I tested) and when I told it to send LEFT / RIGHT it didnt work, any chance the program is blocking it somehow ? So the only way I find to fix it as for now is to use the Send Func .. but anyways I tried to make a program that simultantly will go left wait 10 seconds then right then wait 10 seconds then left and so on .. and also after each 120 seconds press the primary mouse button at fixed location. The result is that it first goes left right left right (without stopping) and click the primary button before 120 seconds passed every like 5 seconds, why is that? Link to comment Share on other sites More sharing options...
GordonFreeman Posted May 3, 2014 Share Posted May 3, 2014 Messy script. Explain by steps what you want to do Frabjous Installation Link to comment Share on other sites More sharing options...
sixtors3 Posted May 3, 2014 Author Share Posted May 3, 2014 Messy script. Explain by steps what you want to do This is what I wanted to do at first : 1. Get the handle of some program's window 2. Make the script push down the left button for 3 seconds (in the program's window itself, by using ControlSend) 3. After pushing down left wait 10 seconds 4. After 10 seconds passed push down the right button for 3 seconds (in the program's window itself, by using ControlSend) 5. While all this happening make your mouse click in a specific coordinate on the screen each 120 seconds. What was the problems I encountered ? 1. For some reason ControlSend with Left and Right didn't work but with other keys it did (I tried Up and Y and it worked for those and for Left and Right it didn't) so I decided to use normal Send function.. 2. The script isn't waiting 10 seconds between each key push down 3. The script click the mouse at the coordinate I provided every 5 seconds or so instead of 120 Link to comment Share on other sites More sharing options...
JohnOne Posted May 3, 2014 Share Posted May 3, 2014 Let's deal one step at a time. . After pushing down left wait 10 seconds Where in your script have you tried to implement this? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
sixtors3 Posted May 3, 2014 Author Share Posted May 3, 2014 Let's deal one step at a time. Where in your script have you tried to implement this? if $seconds1 > 10 Then everytime I get into the if the timer1 get initalized again and I check every loop that the difftime * 1000 (10 seconds) passed Link to comment Share on other sites More sharing options...
JohnOne Posted May 3, 2014 Share Posted May 3, 2014 I'd say that is not correct. If TimerDiff($timer1) is just one millisecond and you times it by 1000 then it's 1000 straight away and your code enters the if condition. You should look again at your logic and correct that first. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
sixtors3 Posted May 3, 2014 Author Share Posted May 3, 2014 (edited) I'd say that is not correct. If TimerDiff($timer1) is just one millisecond and you times it by 1000 then it's 1000 straight away and your code enters the if condition. You should look again at your logic and correct that first. oh should've used / 1000 .. derp what about the other problem with the ControlSend ? Edited May 3, 2014 by sixtors3 Link to comment Share on other sites More sharing options...
JohnOne Posted May 3, 2014 Share Posted May 3, 2014 Well first you need to get the info from exact window control you want to use, advanced class from window info tool will tell you that. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
sixtors3 Posted May 3, 2014 Author Share Posted May 3, 2014 Well first you need to get the info from exact window control you want to use, advanced class from window info tool will tell you that. The problem is this works : WinWaitActive("ProgramName") $hWnd = WinGetHandle("[ACTIVE]") Sleep(1000) While 1 ControlSend($hWnd, "", "", "{UP}") WEnd This doesnt : WinWaitActive("ProgramName") $hWnd = WinGetHandle("[ACTIVE]") Sleep(1000) While 1 ControlSend($hWnd, "", "", "{LEFT}") WEnd WinWaitActive("ProgramName") $hWnd = WinGetHandle("[ACTIVE]") Sleep(1000) While 1 ControlSend($hWnd, "", "", "{RIGHT}") WEnd can the program block certain keys from programs like autoit ? Link to comment Share on other sites More sharing options...
JohnOne Posted May 3, 2014 Share Posted May 3, 2014 can the program block certain keys from programs like autoit ? Yes. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
sixtors3 Posted May 3, 2014 Author Share Posted May 3, 2014 Yes. but Send() can send the left keys so is it really blocking it ? also anyway to overcome the block ? because if I need to send the left and right keys inside the program and when the program use mouseclick the focus go out of the program so what can i do Link to comment Share on other sites More sharing options...
JohnOne Posted May 3, 2014 Share Posted May 3, 2014 but Send() can send the left keys so is it really blocking it ? also anyway to overcome the block ? because if I need to send the left and right keys inside the program and when the program use mouseclick the focus go out of the program so what can i do Well first you need to get the info from exact window control you want to use, advanced class from window info tool will tell you that. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
sixtors3 Posted May 3, 2014 Author Share Posted May 3, 2014 could u gimme example how to do it / some article that tells you how to do it ? Link to comment Share on other sites More sharing options...
JohnOne Posted May 3, 2014 Share Posted May 3, 2014 (edited) Open window info tool from autoit install folder, and drag the finder tool right onto the control inside target window on which you wish to act. Post the full content of the window info tool summary tab here. Edited May 3, 2014 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
sixtors3 Posted May 3, 2014 Author Share Posted May 3, 2014 Open window info tool from autoit install folder, and drag the finder tool right onto the control inside target window on which you wish to act. Post the full content of the window info tool summary tab here. >>>> Window <<<< Title: Class: MapleStoryClass Position: 336, 222 Size: 1372, 796 Style: 0x14CA0000 ExStyle: 0x00000100 Handle: 0x0000000000020C1C >>>> Control <<<< Class: Instance: ClassnameNN: Name: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: >>>> Mouse <<<< Position: 1154, 505 Cursor ID: 0 Color: 0x66CCFF >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< >>>> Hidden Text <<<< Link to comment Share on other sites More sharing options...
JohnOne Posted May 3, 2014 Share Posted May 3, 2014 (edited) I see there is no control recognized, so your current code is the way I would advise if I never knew it did not work. EDIT: Also, you made a mistake in showing this is for a game which is barred from discussion on the forum, so unfortunately I can't help any further even if I could, which I can't. Edited May 3, 2014 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 3, 2014 Moderators Share Posted May 3, 2014 sixtors3,JohnOne is quite right - please read the Forum rules (the link is also at bottom right of each page) - particularly the bit about not discussing game automation - before you post again. Thread locked. But welcome to the AutoIt forum - and see you soon with a legitimate question I hope. 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...
Recommended Posts