Jump to content

Quick Dim project is not working.


Recommended Posts

Im started to learn Dim and i get everything but can anyone tell me why this isnt working and give me a script just like it that will work?

Dim $WinWait

    While $WinWait
        If $WinWait = 1 Then
            WinWait("Instruction")
            WinClose("Instruction")
        EndIf
    WEnd

I double click to run and it runs for like 1 second and shuts off. Someone please test it and tell me whats wrong.

Link to comment
Share on other sites

You did not give $WinWait a value. When you do While $WinWait, you assume that it is = to 1, since While 1 is a endless loop.

Try

Dim $WinWait = 1

    While $WinWait
            WinWait("Instruction")
            WinClose("Instruction")
    WEnd

If you want it to exit the loop when its done you can put $winWait = 0 after the WinClose or just an ExitLoop. I'm not sure, but the variable name probably will conflict with the WinWait function, try using a different variable.

Edit: I guess your probably checking to see if a window is open and if it is then you want to close it?

If so, try this..

While 1
If WinActive("Window") then
     WinClose("Window")
     ExitLoop
EndIf
WEnd
Edited by BPBNA
Link to comment
Share on other sites

You did not give $WinWait a value. When you do While $WinWait, you assume that it is = to 1, since While 1 is a endless loop.

Try

Dim $WinWait = 1

    While $WinWait
            WinWait("Instruction")
            WinClose("Instruction")
    WEnd

If you want it to exit the loop when its done you can put $winWait = 0 after the WinClose or just an ExitLoop. I'm not sure, but the variable name probably will conflict with the WinWait function, try using a different variable.

Thank ill try right now get back in min.

Cheers but now i ahve my problem. What if say i have a bunch of the same windows in a group you know? ex: you have internet explorer open up 7 of them they in a group. Well how do i if the window Instruction appears in the group for it to WinClose it? Im trying to make a reconnector for game so if i get lagged out etc it will reconnect me. Well say i have 5 players on over night im viewing player number 1. But then all of a sudden player 3 disconnects...

1.how do i get it to close that insturction.

2.How do i find the window that it disconnected on to reconnect on that number 3 player...?

Any help be great.

p.s. i tried using winsetontop

Edited by BuddyBoy
Link to comment
Share on other sites

  • Moderators

That is really confusing, I can say this, each "window" has a handle, so I would use that to identify what window is doing what.

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

That is really confusing, I can say this, each "window" has a handle, so I would use that to identify what window is doing what.

Hm?? Let me explain alot easier. Ok as everyone knows if you open more of a same window name ex: internet exploer that your taskbar cant hold all of them it goes in a group right?

Well ok say i put 10 miners on, on my game called Conquer (if helps the name of the window is [Conquer2.0] )

well ok my taskbar cannot hold 10 Co windows at the bottom so it groups them in 1 group. Well ok say im mining with miner #1. The CO screen fills the whole screen so all my miner#1 objects and the ground is all around him blah blah. Well say miner #3 (in the group) disconnects so the window Instruction appears. But since Instruction is part of a CO window it goes in the group also. So someitmes it appears on my Miner #1 screen blah blah i use Winclose(instruction) it closes it. BUT the tricky part and this is waht i need help with. ONCE it closes the instruction it remains to view the miner #1's screen. Well then my miner #3 is just sitting tehre on the login screen because he got disconnected. So heres my 2 questions....

1.IF the instruction dont appear on the miner #1 will the winclose still close it even if its in the group?

2. How do i have the program to read which Conquer disconnected, in this case #3 i nee dto know for it can open that #3's Conquer window and it will be at the login screen then logs in...

Any help be great smoke n or anyone else

Link to comment
Share on other sites

  • Moderators

Hm?? Let me explain alot easier. Ok as everyone knows if you open more of a same window name ex: internet exploer that your taskbar cant hold all of them it goes in a group right?

Well ok say i put 10 miners on, on my game called Conquer (if helps the name of the window is [Conquer2.0] )

well ok my taskbar cannot hold 10 Co windows at the bottom so it groups them in 1 group. Well ok say im mining with miner #1. The CO screen fills the whole screen so all my miner#1 objects and the ground is all around him blah blah. Well say miner #3 (in the group) disconnects so the window Instruction appears. But since Instruction is part of a CO window it goes in the group also. So someitmes it appears on my Miner #1 screen blah blah i use Winclose(instruction) it closes it. BUT the tricky part and this is waht i need help with. ONCE it closes the instruction it remains to view the miner #1's screen. Well then my miner #3 is just sitting tehre on the login screen because he got disconnected. So heres my 2 questions....

1.IF the instruction dont appear on the miner #1 will the winclose still close it even if its in the group?

2. How do i have the program to read which Conquer disconnected, in this case #3 i nee dto know for it can open that #3's Conquer window and it will be at the login screen then logs in...

Any help be great smoke n or anyone else

Your first question is the group doesn't matter, that's just how your task bar is stacking them... I use a large taskbar 90 pixels vs the average user that uses 30, so I don't have stacked windows often.

Your second question, you would have to have a way to read the text or options ie... controlgettext()/wingettext() and if those don't work, then your off to making an ocr on your own, unfortunately the last option requires the window to be active to know what's going on in it.

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

Well heres part of my friends program but i want to make my own this is how he did it and i dont get it, so could you explain how he did it?

For $i=1 to $clients Step 1
  WinActivate("[Conquer2." & $i & "]")
  If PixelGetColor($xachse, $yachse) == $enterpixel Then
    Sleep(Random(120000, 360000, 1))
    MouseClick("left", $xachse, $yachse, 1, 1)
    Sleep(10000)
    $xmitte=$clientsize[2]/2+$clientsize[0]
    $ymitte=$clientsize[3]/2+$clientsize[1]
    MouseClick("right", $xmitte, $ymitte, 1, 1)
    Sleep(1000)
  EndIf
  Next
Else
  While $pixelset==0
  Sleep(100)
  Wend
EndIf
WEnd
Edited by BuddyBoy
Link to comment
Share on other sites

  • Moderators

1. For / Next Loop $i = Number currently on in the loop

2. WinActivate you see the $i there, he's telling it to wait for the right client number

3. PixelGetColor() he's using the method "type" I was talking about possibly needing for OCR, he's looking to see if there is a color there that tells him he needs to do something

4. MouseClick() self explanitory probably the coords to start login

5. MouseClick() same I'm sure, probably a submit button.

Just a guess on the last 2.

Edit:

Note as I said before, all PixelFunctions must have the window active to work, that's why he's using WinActivate()

Edited by SmOke_N

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

1. For / Next Loop $i = Number currently on in the loop

2. WinActivate you see the $i there, he's telling it to wait for the right client number

3. PixelGetColor() he's using the method "type" I was talking about possibly needing for OCR, he's looking to see if there is a color there that tells him he needs to do something

4. MouseClick() self explanitory probably the coords to start login

5. MouseClick() same I'm sure, probably a submit button.

Just a guess on the last 2.

Edit:

Note as I said before, all PixelFunctions must have the window active to work, that's why he's using WinActivate()

But if hes afk how does the program activate the right Conquer window?

Link to comment
Share on other sites

  • Moderators

But if hes afk how does the program activate the right Conquer window?

He's activating them always to check it seems. That's what the loop does.

Here run this code and you'll understand a bit more what he's doing:

HotKeySet('{ESC}', '_StopTheMadness')

Global $WinList = ''

While 1
    Sleep(100)
    $ArrayWindowList = _GetWinList()
    For $i = 1 To UBound($ArrayWindowList) - 1 ; gathered all the windows with titles and put them in an array
        If Not WinActive($ArrayWindowList[$i]) Then WinActivate($ArrayWindowList[$i]) ; $i represents what window number I'm on in my array
    Next
WEnd

Func _GetWinList()
    Local $aWinList = WinList(), $aReturnArray = ''
    For $iCount = 1 To $aWinList[0][0]
        If BitAND(WinGetState($aWinList[$iCount][1]), 2) And $aWinList[$iCount][0] <> '' Then
            $aReturnArray = $aReturnArray & $aWinList[$iCount][0] & Chr(01)
        EndIf
    Next
    Return StringSplit(StringTrimRight($aReturnArray, 1), Chr(01))
EndFunc

Func _StopTheMadness()
    Exit 0
EndFunc
Note Esc button will get the function to stop.

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

He's activating them always to check it seems. That's what the loop does.

Here run this code and you'll understand a bit more what he's doing:

HotKeySet('{ESC}', '_StopTheMadness')

Global $WinList = ''

While 1
    Sleep(100)
    $ArrayWindowList = _GetWinList()
    For $i = 1 To UBound($ArrayWindowList) - 1 ; gathered all the windows with titles and put them in an array
        If Not WinActive($ArrayWindowList[$i]) Then WinActivate($ArrayWindowList[$i]) ; $i represents what window number I'm on in my array
    Next
WEnd

Func _GetWinList()
    Local $aWinList = WinList(), $aReturnArray = ''
    For $iCount = 1 To $aWinList[0][0]
        If BitAND(WinGetState($aWinList[$iCount][1]), 2) And $aWinList[$iCount][0] <> '' Then
            $aReturnArray = $aReturnArray & $aWinList[$iCount][0] & Chr(01)
        EndIf
    Next
    Return StringSplit(StringTrimRight($aReturnArray, 1), Chr(01))
EndFunc

Func _StopTheMadness()
    Exit 0
EndFunc
Note Esc button will get the function to stop.
I see what you mean but do you think i could code a script like that? :wacko: Your like highest you can learn on autoit im like in middle still learning lol but with your explantion from last post about his script i mihgt get it working :D
Link to comment
Share on other sites

  • Moderators

I never wrote a script until I tried, and I never finished one, until I didn't give up.

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

Whatever you mean i hope you can answer 1 more question :D

For some reason (have no clue) The autoit window information can red the text in the type in box on the log in screen (but not in game) So i was wondering couldnt there be an easier way?

Is there a function that once it reads hidden text (wingethiddentext) that it will click on that window? I know i can use wingetext wingethiddentext etc but is tehre antoehr function for it will click that log in screen that has the text? Because it would work perfectly because it will read all clients of conquers text so if 1 2 or 3+ Conquer accs disconnect it will go to each one of them click on the enter button and continue mining.

So if there is a function to go to the window of text found that would be great :wacko:

O yeah if that function can also just check the [Conquer2.0] windows?

Edited by BuddyBoy
Link to comment
Share on other sites

  • Moderators

It means, try something... if it doesn't work try again, if it still doesn't work, try 1 more time, when your about to blow up your computer, come here, post everything (code and all) that you've tried and ask for help, get some answers (although all may not be what you want, respect them all the same), if an answer works keep pounding, if not, explain how you tried to use the answer, and why/what isn't working particularly for you, and ask for help again. (shew... all one breath :D )

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

It means, try something... if it doesn't work try again, if it still doesn't work, try 1 more time, when your about to blow up your computer, come here, post everything (code and all) that you've tried and ask for help, get some answers (although all may not be what you want, respect them all the same), if an answer works keep pounding, if not, explain how you tried to use the answer, and why/what isn't working particularly for you, and ask for help again. (shew... all one breath :D )

Because im not outspoken and if you knew all i do on my computer id try and try, maybe 1 less try then you mentioned but i do. Ive searched for 30 mins in the autoit help file jsut for one function, ya not much time but jsut 1 function if it were a script i take longer. But how can i try on my scripts when i dont know how to do it? thats why i come here and ask for help.

Link to comment
Share on other sites

I never wrote a script until I tried, and I never finished one, until I didn't give up.

Just like he said. The best way for you to start would be to start with something simple, like a msgbox, find out the different parameters and remember it. Then look through the help file to find simple things that you could add, eventually you will be able to build up to these types of things. It is much easier to add to one of your own scripts than to try and do it all at once.

Try writing a program that just searches for the error, then after that, one that switches through the windows, then one that checks to see if it crashed and so on.

As for your last question, I don't know any way to do that except checking each window seperatly unless the "Instruction" window has text that identifies the window.

Link to comment
Share on other sites

  • Moderators

Have you taken the interactive tutorial?

http://www.autoitscript.com/forum/index.php?showtopic=21048

That's a start on learning how to do it.

How I learned? Reading the help file, and HOURS UPON HOURS (Days at a time even) of trial and error.

I'm not bashing your asking... just saying ... try to impliment what it is you want... and show what you've done... 1 or 2 lines of code is nothing really.

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

I have AutoIt 1-2-3 but i dont get how it works at all. It shows it has a game bot builder, i cannot find that anywhere, it has other stuff he sed i cannot find them... I dont see why you cannot anwer 1 question about a function, then i can look it up in autoit help file and rea dmore about it and then continue my script :D

Link to comment
Share on other sites

Ugg im sry i have no success what so ever! i searched fo 30 mins more... for any function that would help me i jsut cant find one and if i ran across it i dont get it! please smooke n or someone can you just help me get that one function :D

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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