Sign in to follow this  
Followers 0
lolp1

Need simple help.

13 posts in this topic

I am making a simple program to dim windows, the problem is once I dim it, the END function won't(Terminate) work, and I am guessing it is because the loop (while 1, wend) has no way to escape for the Dimm func, so could someone give me an idea on how to toggel it?

;================================================================================
;   #includes
;================================================================================

;================================================================================
;   Set hot keys
;================================================================================
HotKeySet("{ESC}", "Terminate")
HotKeySet("{INSERT}", "dimm")
;================================================================================
;   Read .ini
;================================================================================
$dimwindow= IniRead("dim.ini", "Global", "dimwindow", "")
$dimammount= IniRead("dim.ini", "Global", "dimammount", "")

;================================================================================
;   Loop program
;================================================================================

While 1
    Sleep(10)
wend



;================================================================================
;   Dim program
;================================================================================
Func dimm()
    While 1
    Sleep(10)
WinSetTrans($dimwindow, "", $dimammount)
Wend
Endfunc



;================================================================================
;   End program
;================================================================================


Func Terminate()
    Exit 0
EndFunc

Share this post


Link to post
Share on other sites



Hi,

ESC terminates the script. If you want it to end automatically then you need to change the while 1 wend loop to e.g. do until ... or for next.

You can set the value for dim in/out in a loop step by step and if it reaches the value of the ini, then end/ exitloop.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Look at HotKeySet() in the help file, in the example of _togglepause(), you'll find your answer.


[center]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.[/center]

Share this post


Link to post
Share on other sites

Hello, I took smoke Ns advice and tried this, anything look wrong? (Because it did not work;))

;================================================================================
;   #includes
;================================================================================
Global $Paused

;================================================================================
;   Set hot keys
;================================================================================
HotKeySet("{ESC}", "Terminate")
HotKeySet("{INSERT}", "dimm")
;================================================================================
;   Read .ini
;================================================================================
$dimwindow= IniRead("dim.ini", "Global", "dimwindow", "")
$dimammount= IniRead("dim.ini", "Global", "dimammount", "")

;================================================================================
;   Loop program
;================================================================================

While 1
    Sleep(10)
wend



;================================================================================
;   Dim program
;================================================================================
Func dimm()
      $Paused = NOT $Paused
    While $Paused
  sleep(10)
WinSetTrans($dimwindow, "", $dimammount)
Wend
Endfunc



;================================================================================
;   End program
;================================================================================


Func Terminate()
    Exit 0
EndFunc

Share this post


Link to post
Share on other sites

It's not going to change anything if you don't ever change the value!

P.S.

How about posting a descriptive topic next time, I only ended up in here by accident, I have sworn of stupid non-descriptive topic threads like this.


[center]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.[/center]

Share this post


Link to post
Share on other sites

Sorry! The goal is not to change the value, but when they press INSERT the dim goes back to normal. Vice versa as well. Hence the reason toggle.

(Notes to self: More descriptive titles next time = good idea!)

Share this post


Link to post
Share on other sites

Hi,

is this the goal?

;================================================================================
;    #includes
;================================================================================

;================================================================================
;    Set hot keys
;================================================================================
Opt("WinTitleMatchMode", 2)
HotKeySet("{ESC}", "Terminate")
HotKeySet("1", "dimm")
;================================================================================
;    Read .ini
;================================================================================
Global $dimwindow = "AutoIt Help" ;IniRead("dim.ini", "Global", "dimwindow", "")
Global $dimammount = 10 ;IniRead("dim.ini", "Global", "dimammount", "")
Global $Paused
Global $trans = 255

;================================================================================
;    Loop program
;================================================================================

While 1
    Sleep(100)
WEnd

;================================================================================
;    Dim program
;================================================================================
Func dimm()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
    If $dimammount < 255 And $trans > $dimammount Then
        Do
            WinSetTrans($dimwindow, "", $trans)
            Sleep(100)
            $trans -= 10
        Until $trans <= $dimammount
    EndIf
EndFunc   ;==>dimm



;================================================================================
;    End program
;================================================================================


Func Terminate()
    WinSetTrans($dimwindow, "", 255)
    Exit 0
EndFunc   ;==>Terminate

PS: Changed Insert to 1!!!

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Sorry! The goal is not to change the value, but when they press INSERT the dim goes back to normal. Vice versa as well. Hence the reason toggle.

(Notes to self: More descriptive titles next time = good idea!)

HotKeySet("{ESC}", "Terminate")
HotKeySet("{INSERT}", "dimm")
Global $dimwindow = WinGetTitle('')
Global $dimammount, $lastdimm = 255, $iPass

While 1
    Sleep(100000)
Wend

Func dimm()
    $iPass = Not $iPass
    If $iPass Then
        $dimammount = _DimAmount()
        WinSetTrans($dimwindow, '', $dimammount)
    Else
        WinSetTrans($dimwindow, '', $lastdimm)
        $lastdimm = $dimammount
    EndIf
Endfunc

Func _DimAmount()
    Return Random(1, 255)
EndFunc

Func Terminate()
    Exit 0
EndFunc

[center]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.[/center]

Share this post


Link to post
Share on other sites

Ha SmOke_N,

now I'm curious who got the right solution. :whistle:

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Ha SmOke_N,

now I'm curious who got the right solution. ;)

So long,

Mega

Makes 1 of us :whistle:

[center]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.[/center]

Share this post


Link to post
Share on other sites

Sorry, I don't belive either of those is the right solution.

I'll try to be as clear as I can be:)

When they press INSERT, I would want it to change to the $dim they have set in the .ini and only to the $dimwindow, when they press INSERT again, I would like it to set it back to It's orignal state.

I don't belive either of the above code does what I am looking for.

Share this post


Link to post
Share on other sites

Sorry, I don't belive either of those is the right solution.

I'll try to be as clear as I can be:)

When they press INSERT, I would want it to change to the $dim they have set in the .ini and only to the $dimwindow, when they press INSERT again, I would like it to set it back to It's orignal state.

I don't belive either of the above code does what I am looking for.

You're not qualified to make that ASSumption I'd wager.

Mine sets it back to the "last" state it was in and remembers what the state was when it was set invisible.

So the first state is 255 for visible.

Next state was just an example because I wasn't going to make an .ini file to solve your problem since you didn't have enough respect to provide one yourself. It goes from random 0 to 255.

On setting trans it calls the function, sets the trans, then on next insert button push, it reverts back to what it was before the trans.

That's how I perceived what you wanted.

1. Log original state

2. Set Trans

3. Set back to original state

4. New original state is last trans.

If that's not what you wanted, then the function I wrote is fairly straight forward and quite elementary, change it to suit your needs.


[center]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.[/center]

Share this post


Link to post
Share on other sites

I misslooked something SmokeN (common sense) thanks, problem has been solved!

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