Jump to content

Greater Than


Recommended Posts

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

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

 

Link to comment
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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

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

 

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