Jump to content

2 problems sending keys


Recommended Posts

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

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

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

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

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 by sixtors3
Link to comment
Share on other sites

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

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

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

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 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

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

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 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

  • Moderators

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. :naughty:

But welcome to the AutoIt forum - and see you soon with a legitimate question I hope. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...