Sign in to follow this  
Followers 0
SkellySoul

Greater Than

6 posts in this topic

#1 ·  Posted (edited)

Hi

I have these two functions the one works and the other doesn't and do not understand why.

Basically if $Trans = 255 or higher then don't increase by 5.

Thanks for the help!

If Not $Trans <= 0 Then ; Works
$Trans -= 5
ToolTip($Trans)
WinSetTrans($GUI, "", $Trans)
EndIf
If Not $Trans >= 255 Then ; Does not work.
$Trans += 5
ToolTip($Trans)
WinSetTrans($GUI, "", $Trans)
EndIf
Edited by SkellySoul

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Is the ceiling 255 though? Because technically what you're saying you want to do is if it's 254, still increase by 5... which makes it 259.

EDIT:

Also, are these 2 running synonymous? Because both directives will be true if it's in the range of -4 thru 254 and it will subtract 5 then add 5 back.

Edited by Mechaflash

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

Why do not write it the other way round?

If $Trans > 0 Then
    $Trans -= 5
    ToolTip($Trans)
    WinSetTrans($GUI, "", $Trans)
EndIf

If $Trans < 255 Then
    $Trans += 5
    ToolTip($Trans)
    WinSetTrans($GUI, "", $Trans)
EndIf
1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

This is more of the code.

Func _Trans()
If IsHWnd($GUI) Then
Local $Key = ""
MsgBox(0 , "", $Trans)
ConsoleWrite(@HotKeyPressed)
    Switch @HotKeyPressed
Case "{PGUP}"
If Not $Trans >= 255 Then
$Trans += 5
ToolTip($Trans)
WinSetTrans($GUI, "", $Trans)
EndIf
        Case "{PGDN}"
If Not $Trans <= 0 Then
$Trans -= 5
ToolTip($Trans)
WinSetTrans($GUI, "", $Trans)
EndIf
EndSwitch
EndIf
EndFunc
 
 
 
Full Source
 
#cs ----------------------------------------------------------------------------
 
 AutoIt Version: 3.3.11.2 (Beta)
 Author:         myName
 
 Script Function:
Template AutoIt script.
 
#ce ----------------------------------------------------------------------------
 
; Script Start - Add your code below here
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
 
Global $GUI, $Trans
 
HotKeySet("{Home}", "_Window")
HotKeySet("{End}" , "_Exit")
HotKeySet("{PGUP}" , "_Trans")
HotKeySet("{PGDN}" , "_Trans")
 
$Trans = 100
 
While 1
Sleep(1000)
WEnd
 
Func _Window()
GUIDelete($GUI)
;Fix up Errors
$Pos = WinGetPos("[ACTIVE]")
$Handle = WinGetHandle("[ACTIVE]")
If @Error = 1 Then
MsgBox(16, "Error", "No Window Found!")
Exit
Else
$GUI = GUICreate("", $Pos[2], $Pos[3], $Pos[0], $Pos[1], $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)
GUISetBkColor(0x000000)
GUISetState(@SW_HIDE)
WinSetTrans($GUI, "", $Trans)
GUISetState(@SW_SHOW)
 
;WinGetState
 
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
EndIf
EndFunc
 
Func _Trans()
If IsHWnd($GUI) Then
Local $Key = ""
ConsoleWrite(@HotKeyPressed)
    Switch @HotKeyPressed
Case "{PGUP}"
If Not $Trans >= 255 Then
$Trans += 5
ToolTip($Trans)
WinSetTrans($GUI, "", $Trans)
EndIf
        Case "{PGDN}"
If Not $Trans <= 0 Then
$Trans -= 5
ToolTip($Trans)
WinSetTrans($GUI, "", $Trans)
EndIf
EndSwitch
EndIf
EndFunc
 
Func _Exit()
GUIDelete($GUI)
Exit
EndFunc
Edited by SkellySoul

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

EDIT: Checked the WinSetTrans() and it only accepts a range of 0 - 255. Changed the two if statements to reflect this properly.

Func _Trans()
If IsHWnd($GUI) Then
  Local $Key = ""
  MsgBox(0 , "", $Trans)
  ConsoleWrite(@HotKeyPressed)
    Switch @HotKeyPressed
      Case "{PGUP}"
        If ($Trans + 5) <= 255 Then
          $Trans += 5
          ToolTip($Trans)
          WinSetTrans($GUI, "", $Trans)
        EndIf
      Case "{PGDN}"
        If ($Trans - 5) >= 0 Then
          $Trans -= 5
          ToolTip($Trans)
          WinSetTrans($GUI, "", $Trans)
        EndIf
      EndSwitch
EndIf
EndFunc
Edited by Mechaflash
1 person likes this

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

opps..I had them backwards  :mellow:

Thanks very much for the help :)

[Edited]

I guess also using "Not" wasn't very wise either heh  :sweating:

Edited by SkellySoul

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