Sign in to follow this  
Followers 0
Mordenkain

Help badly needed!

9 posts in this topic

#1 ·  Posted (edited)

Im sorry to post a help topic as my first post, but I badly need help on this script. I've tried everything I could come up with to make this work, but it just won't work. I had some friend look at it, and he was not able to find the error either.

Here's the deal: Im making a program that "stealth" selected programs by the WinSetState(bla bla, @SW_HIDE) function. Originally i just made it for when i was playing WoW when im not suppose to, as a panic button and just let it run in the background. Then I thought: "Hey! Why not make it more configurable?" So I made a nice GUI for it (simple but it works). Now I wanted it "stealth" multiple programs as defined by the user. So i did some stuff with FileOpen and FileWriteLine, to make it able to add titles (inputet by the user) to an .ini file. Heres the problem: When I wanted it to "stealth" the desired programs, I made it do FileReadLine to get the titles of the desired windows and @SW_HIDE them one by one. But it just won't work. It @SW_HIDE's the most recent activated window and the AUTOIT editor. Im going crazy because of this, please help me out. Here's my code (Some functions not done yet, but ignore that, look at the stealth(), unstealth() and dimwins() functions):

; Stealth program
; Made by Marc Mielsen

;Initialize
#include <GUIConstants.au3>
HotKeySet("{END}", "stealth")
HotKeySet("{HOME}", "unstealth")
HotKeySet("+{END}", "quit")
HotKeySet("+{HOME}", "showgui")
Opt("TrayIconHide", 1)
AutoItSetOption("WinTitleMatchMode", 3)

GUICreate("StealthBot",360, 170)
$bt_readme=GUICtrlCreateButton("ReadMe",10, 10, 180)
$bt_showhide=GUICtrlCreateButton("Show/Hide",10, 40, 180)
$bt_quit=GUICtrlCreateButton("Exit",10, 100, 180)
$bt_add=GUICtrlCreateButton("Add", 10, 70, 90)
$bt_clear=GUICtrlCreateButton("Clear", 100, 70, 90)
$li_windows=GUICtrlCreateList("", 200, 10, 150, 130)
$la_copyright=GUICtrlCreateLabel("© Marc Nielsen 2007", 125, 145)
GUISetState(@SW_SHOW)



$winstate=0
$loop=0
$showhideconfig=1
Dim $wins2hide[50]
;done

;sleep loop
While $loop <> $GUI_EVENT_CLOSE
    $respond=GUIGetMsg()
    Select
    Case $respond=$bt_readme
        tip()
    Case $respond=$bt_quit
        quit()
    Case $respond=$bt_showhide
        If $showhideconfig=1 Then
            hidegui()
        ElseIf $showhideconfig=0 Then
            showgui()
        Else
            Sleep(1)
        EndIf
    Case $respond=$bt_add
        add()
    Case $respond=$bt_clear
        clear()
    Case Else
        Sleep(1)
    EndSelect
WEnd
;done

;functions:
Func tip()
    MsgBox(64, "Note", "Function not available yet.")
EndFunc

Func stealth()
    dimwins()
    For $temp=1 To 50
        $winstate=WinGetState($wins2hide[$temp], "")
        If BitAND($winstate, 2) And BitAND($winstate, 1) Then
            WinSetState($wins2hide[$temp], "", @SW_MINIMIZE)
            WinSetState($wins2hide[$temp],"",@SW_HIDE)
        Else
            Sleep(1)
        EndIf
    Next
EndFunc

Func unstealth()
    dimwins()
    For $temp=1 To 50
        $winstate = WinGetState($wins2hide[$temp], "")
        If BitAND($winstate, 2) And BitAND($winstate[$temp], 1) Then
            Sleep(1)
        Else
            WinSetState($wins2hide[$temp], "", @SW_SHOW)
            WinSetState($wins2hide[$temp], "", @SW_MAXIMIZE)
        EndIf
    Next
EndFunc

Func quit()
    Exit
EndFunc

Func hidegui()
    GUISetState(@SW_MINIMIZE)
    GUISetState(@SW_HIDE)
    $showhideconfig=0
    Sleep(100)
    ToolTip("Press SHIFT + HOME to show GUI again.")
    Sleep(2000)
    ToolTip("")
EndFunc

Func showgui()
    GUISetState(@SW_SHOW)
    WinActivate("StealtBot")
    $showhideconfig=1
EndFunc

Func add()
    $win2stealth=InputBox("StealthBot", "Insert exact name of window to stealth.", "", "", 300, 100)
    $stealthwins=FileOpen("windows2hide.ini", 1)
    FileWriteLine($stealthwins, $win2stealth)
    GUICtrlSetData($li_windows,$win2stealth)
    FileClose($stealthwins)
EndFunc

Func clear()
    GUICtrlSetData($li_windows,"")
    $stealthwins=FileOpen("windows2hide.ini", 2)
    FileWrite($stealthwins, "")
    FileClose($stealthwins)
EndFunc

Func dimwins()
    Dim $wins2hide[51]
    $ini=FileOpen("windows2hide.ini", 0)
    While 1
        $line = FileReadLine($ini)
        If @error = -1 Then ExitLoop
    Wend
    For $temp=1 To $line
        $wins2hide[$temp]=FileReadLine($ini, $temp)
    Next
EndFunc
;done

I aware that it most likely is some STUPID mistake, but I just can't locate the error! =(

Desperately hoping for help

- Mordenkain

Edited by Mordenkain

Share this post


Link to post
Share on other sites

Shameless BUMP, sorry about that, but i really need some help! :shocked:

Share this post


Link to post
Share on other sites

Why not just throw some dbg statements in there?

Func dbg($msg, $line=@ScriptLineNumber, $err=@error, $ext=@extended)
    ConsoleWrite("(" & $line & ") := (" & $err & ")(" & $ext & ") : " & $msg & @CRLF)
EndFunc
Func stealth()
    dimwins()
    For $temp=1 To 50
        $winstate=WinGetState($wins2hide[$temp], "")
        If BitAND($winstate, 2) And BitAND($winstate, 1) Then
            dbg("HIDE: " & $wins2hide[$temp])
            WinSetState($wins2hide[$temp], "", @SW_MINIMIZE)
            WinSetState($wins2hide[$temp],"",@SW_HIDE)
        Else
            Sleep(1)
        EndIf
    Next
EndFunc

Run with scite or editor able to capture ConsoleWrite. Or search the forum for dbgview..:shocked:

Share this post


Link to post
Share on other sites

This line is bad style

Dim $wins2hide[51]oÝ÷ Ø­µêí¢­Ø§¶­¢¶¬r¸©µ©ÝºÇÚ«­¢+Ù±½°ÀÌØíÝ¥¹ÌÉ¡¥lÔÅt

Share this post


Link to post
Share on other sites

Even better return the array from the function and awoid Globals all together.

Func dimwins()
    Local $wins2hide[51]
    $ini=FileOpen("windows2hide.ini", 0)
    While 1
        $line = FileReadLine($ini)
        If @error = -1 Then ExitLoop
    Wend
    For $temp=1 To $line
        $wins2hide[$temp]=FileReadLine($ini, $temp)
    Next
    Return $wins2hide
EndFunc
Func stealth()
    Local $wins2hide = dimwins()
    For $temp=1 To 50
        $winstate=WinGetState($wins2hide[$temp], "")
        If BitAND($winstate, 2) And BitAND($winstate, 1) Then
            WinSetState($wins2hide[$temp], "", @SW_MINIMIZE)
            WinSetState($wins2hide[$temp],"",@SW_HIDE)
        Else
            Sleep(1)
        EndIf
    Next
EndFunc

Share this post


Link to post
Share on other sites

I appreciate the help, but it doesn't really solve the problem I have, and doesn't explain why the program is acting so weird. Anyone able to clarify that one?

- Mordenkain

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

What debug tool you mean? If you mean the syntax testing tool, this is the result i get:

>C:\Programmer\AutoIt3\SciTE\..\au3check.exe "C:\Documents and Settings\Marc Nielsen\Skrivebord\AUTOIT\stealthbot.au3"

AutoIt3 Syntax Checker v1.54 Copyright © Tylo 2006

C:\Documents and Settings\Marc Nielsen\Skrivebord\AUTOIT\stealthbot.au3 - 0 error(s), 0 warning(s)

>Exit code: 0 Time: 0.335

Edited by Mordenkain

Share this post


Link to post
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
Sign in to follow this  
Followers 0