Jump to content

Translate AHK to AU3


delray
 Share

Recommended Posts

Well your setting num and caps for more than one elseif statement so are you sure each case actually happening? You should add in some consolewrite() statements to be sure. ex:

ConsoleWrite('Read' & @LF)
TraySetIcon("Read.ico")

Also have you verified all the icons do indeed work?

TraySetIcon("Drive.ico")
Sleep(1000)
  TraySetIcon("Read.ico")
Sleep(1000)
Link to comment
Share on other sites

Well your setting num and caps for more than one elseif statement so are you sure each case actually happening? You should add in some consolewrite() statements to be sure. ex:

ConsoleWrite('Read' & @LF)
TraySetIcon("Read.ico")

Also have you verified all the icons do indeed work?

TraySetIcon("Drive.ico")
Sleep(1000)
  TraySetIcon("Read.ico")
Sleep(1000)

I switched the "Send"s around to make sure I wasn't messing up and changed "Sleep" many times. I am going to show the code for the original program from AHK that works great. The icons are embeded in the script as you will see and this is what I am trying to get rid of and use AU3 icon handling.

; HDD Indicator @ TNA by SKAN ( arian.suresh@gmail.com )
; Created: 15-May-2008  /  Last Modified: 04-Oct-2010
;
; Credit    : Adapted from "HDD Activity Monitoring LED" by Sean
; Topic  : www.autohotkey.com/forum/viewtopic.php?t=18033
; This file : www.autohotkey.net/~Skan/ShortCode/HDD-Indicator_TNA.ahk
#Persistent
Process, Priority,, High
SetBatchLines -1
; Creating NOTIFYICONDATA : http://msdn.microsoft.com/en-us/library/aa930660.aspx
; Thanks Lexikos : http://www.autohotkey.com/forum/viewtopic.php?p=162175#162175
PID := DllCall("GetCurrentProcessId"), VarSetCapacity( NID,444,0 ), NumPut( 444,NID )
DetectHiddenWindows, On
NumPut( WinExist( A_ScriptFullPath " ahk_class AutoHotkey ahk_pid " PID),NID,4 )
DetectHiddenWindows, Off
NumPut( 1028,NID,8 ), NumPut( hIcon1,NID,20), NumPut( 2,NID,12 ), IconDataHex:=""
GoSub, IconData ; Create IconData buffer
Loop 4        ; Obtain 4 Icon handles from IconData buffer
  hICon%A_Index% := DllCall( "CreateIconFromResourceEx", UInt,&IconData+( 296*(A_Index-1))
                            , UInt,296, Int,1, UInt,0x30000, Int,16, Int,16, UInt,0 )
; Run, diskperf.exe -y   ; Execute it once to enable Disk Performance monitoring.
ORC:=0, OWC:=0, VarSetCapacity( DP,88,0 ) ; DISK_PERFORMANCE
hDrv := DllCall( "CreateFile", Str,"\\.\PhysicalDrive0", UInt,0 ,UInt,3, UInt,0, UInt,3
                , UInt,0, UInt,0 )
              
OnExit, QuitScript
SetTimer, HDD_Monitor
HDD_Monitor:
  DllCall( "DeviceIoControl", UInt,hDrv, UInt,0x70020, UInt,0, UInt,0, UInt,&DP, UInt,88
          , UintP,nReturn, Uint,0 )

  NRC:=NumGet(DP,40), NWC:=NumGet(DP,44), RC:=NRC-ORC, WC:=NWC-OWC, ORC:=NRC,OWC:=NWC
  IC := RC=0&&WC=0 ? 1 : RC!=0&&WC=0 ? 2 : RC=0&&WC!=0 ? 3 : RC!=0&&WC!=0 ? 4 :
  NumPut( hIcon%IC%,NID,20 ), DllCall( "shell32\Shell_NotifyIcon",UInt,0x1,UInt,&NID )
Return                                               ; // end of auto-execute section //
; Icons are actually 512 bytes in length
IconData:
IconDataHex =
( join
280000001000000020000000010004000000000080000000000000000000000000000000000000000000000000
0080000080000000808000800000008000800080800000C0C0C001808080010000FF0000FF000100FFFF01FF00
0000FF00FF00FFFF0001FFFFFF0100000000000000000000000000000000000000000000000000000000000000
000000000000000000001910001910080000999000999008800019100019100880000000000000088087777777
777778800888888888888780008888888888887000088888888888880000000000000000000000000000000000
00000000000000FFFF0000FFFF0000FFFF00008007000000030000000100000000000000000000000000000000
000080000000C0000000E0000000FFFF0000FFFF0000FFFF0000
280000001000000020000000010004000000000080000000000000000000000000000000000000000000000000
0080000080000000808000800000008000800080800000C0C0C001808080010000FF0000FF000100FFFF01FF00
0000FF00FF00FFFF0001FFFFFF0100000000000000000000000000000000000000000000000000000000000000
000000000000000000002A20001910080000AAA00099900880002A200019100880000000000000088087777777
777778800888888888888780008888888888887000088888888888880000000000000000000000000000000000
00000000000000FFFF0000FFFF0000FFFF00008007000000030000000100000000000000000000000000000000
000080000000C0000000E0000000FFFF0000FFFF0000FFFF0000
280000001000000020000000010004000000000080000000000000000000000000000000000000000000000000
0080000080000000808000800000008000800080800000C0C0C001808080010000FF0000FF000100FFFF01FF00
0000FF00FF00FFFF0001FFFFFF0100000000000000000000000000000000000000000000000000000000000000
000000000000000000001910002A20080000999000AAA00880001910002A200880000000000000088087777777
777778800888888888888780008888888888887000088888888888880000000000000000000000000000000000
00000000000000FFFF0000FFFF0000FFFF00008007000000030000000100000000000000000000000000000000
000080000000C0000000E0000000FFFF0000FFFF0000FFFF0000
280000001000000020000000010004000000000080000000000000000000000000000000000000000000000000
0080000080000000808000800000008000800080800000C0C0C001808080010000FF0000FF000100FFFF01FF00
0000FF00FF00FFFF0001FFFFFF0100000000000000000000000000000000000000000000000000000000000000
000000000000000000002A20002A20080000AAA000AAA00880002A20002A200880000000000000088087777777
777778800888888888888780008888888888887000088888888888880000000000000000000000000000000000
00000000000000FFFF0000FFFF0000FFFF00008007000000030000000100000000000000000000000000000000
000080000000C0000000E0000000FFFF0000FFFF0000FFFF0000
)
VarSetCapacity( IconData,( nSize:=StrLen(IconDataHex)//2) )
Loop %nSize% ; MCode by Laszlo Hars: http://www.autohotkey.com/forum/viewtopic.php?t=21172
  NumPut( "0x" . SubStr(IconDataHex,2*A_Index-1,2), IconData, A_Index-1, "Char" )
Return
QuitScript:
  DllCall("CloseHandle", "Uint", hDrv)
  ExitApp
Return
Link to comment
Share on other sites

  • 1 month later...

IC := RC=0&&WC=0 ? 1 : RC!=0&&WC=0 ? 2 : RC=0&&WC!=0 ? 3 : RC!=0&&WC!=0 ? 4 : NumPut( hIcon%IC%,NID,20 )

this is a common shortsyntax in many languages.

$variable = ($is_value1=$equal_value2) ? $then_set_variable_this_value : $else_set_variable_this_value ;

? = "if condition=true, then"

: = "else"

the ahk-code above is nested and therefore a little bit hard to understand.

Edited by Raik

AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

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