playlet Posted November 20, 2009 Share Posted November 20, 2009 (edited) --- Edited August 18, 2016 by playlet mesale0077, n1maS, mdwerne and 1 other 4 Link to comment Share on other sites More sharing options...
picea892 Posted November 20, 2009 Share Posted November 20, 2009 (edited) Hi. I ran the script and nothing appeared to happen...maybe more instructions are needed. Is there a key to press or place to move the mouse. As well, I have to believe there is a more efficient way to examine the case selections. There is a lot of duplicated code in the script and I think it would be easier to understand and work with if you streamlined it. Perhaps you can use an array and query multiple cases at once or move some things to a function and call the function instead of repeating code. Another example would be to use an array for your flags instead of $over1 = 0, $over1a = 0, $press1 = 0, $over2 = 0, $over2a = 0, $press2 = 0 This code seems like a lot of work, I think you must have worked quite hard on it. I would like to check it out, if you give me more direction I'd appreciate it. Edited November 20, 2009 by picea892 Link to comment Share on other sites More sharing options...
playlet Posted November 20, 2009 Author Share Posted November 20, 2009 (edited) --- Edited August 18, 2016 by playlet Link to comment Share on other sites More sharing options...
playlet Posted November 21, 2009 Author Share Posted November 21, 2009 (edited) --- Edited August 18, 2016 by playlet Link to comment Share on other sites More sharing options...
picea892 Posted November 22, 2009 Share Posted November 22, 2009 (edited) Hi, got it working and made some revisions. 1) Using the winapi function so no longer require grey.gif 2) tweaked so more universally usable. Can accommodate different sized monitors and fileinstall to script directory so not tweaking needed. I had other ideas for tweaks but didn't implement because as you say, you have a pretty easy to understand script. Anything I'd add would just add complexity and part of the point of these examples is for learning. Some stuff for you to consider if you feel like it. Instead of having multiple pictures and switching them, you can draw right on the png. I have plenty of examples of doing this if you like one. Your method is akin to what a website would do, we can do better in autoit. Another thought was the array thing. it would be 12 down, 3 over. First one would be the png, 2nd and 3rd would be the flags. One other. I have dual monitors and I can see the text on my second monitor when they are supposed be hidden. You might want to move the gui down instead of left or hide and show the gui. Otherwise good job. I think the forum is better for you having shared this. Picea Edit: Here is an example I made for drawing on a png http://www.autoitscript.com/forum/index.php?showtopic=103224&st=0&p=731512&hl=outlook%20widget&fromsearch=1&#entry731512 expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=..\essential\devilish.ico #AutoIt3Wrapper_outfile=Special Starter 5c.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Description=Launcher by Playlet #AutoIt3Wrapper_Res_Fileversion=5.0.0.0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <StructureConstants.au3> #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <Misc.au3> ;OnAutoItExitRegister ("Close_process") If WinExists ("Launcher-Playlet") Then MsgBox (0, "Warning", "You can only start this application once !") Exit EndIf If Not FileExists (@TempDir & "\essential\") Then DirCreate (@TempDir & "\essential\") FileInstall (@ScriptDir&"\essential\devilish.ico", @TempDir & "\essential\devilish.ico", 1) FileInstall (@ScriptDir&"\essential\images-png\normal4.png", @TempDir & "\essential\normal.png", 1) FileInstall (@ScriptDir&"\essential\images-png\grey.gif", @TempDir & "\essential\grey.gif", 1) FileInstall (@ScriptDir&"\essential\images-png\over14.png", @TempDir & "\essential\over1.png", 1) FileInstall (@ScriptDir&"\essential\images-png\over24.png", @TempDir & "\essential\over2.png", 1) FileInstall (@ScriptDir&"\essential\images-png\over34.png", @TempDir & "\essential\over3.png", 1) FileInstall (@ScriptDir&"\essential\images-png\over44.png", @TempDir & "\essential\over4.png", 1) FileInstall (@ScriptDir&"\essential\images-png\over54.png", @TempDir & "\essential\over5.png", 1) FileInstall (@ScriptDir&"\essential\images-png\over64.png", @TempDir & "\essential\over6.png", 1) FileInstall (@ScriptDir&"\essential\images-png\over74.png", @TempDir & "\essential\over7.png", 1) FileInstall (@ScriptDir&"\essential\images-png\over84.png", @TempDir & "\essential\over8.png", 1) FileInstall (@ScriptDir&"\essential\images-png\over94.png", @TempDir & "\essential\over9.png", 1) FileInstall (@ScriptDir&"\essential\images-png\over104.png", @TempDir & "\essential\over10.png", 1) ;FileInstall (@ScriptDir&"\essential\images-png\over114.png", @TempDir & "\essential\over11.png", 1) FileInstall (@ScriptDir&"\essential\images-png\over124.png", @TempDir & "\essential\over12.png", 1) FileInstall (@ScriptDir&"\essential\images-png\press14.png", @TempDir & "\essential\press1.png", 1) FileInstall (@ScriptDir&"\essential\images-png\press24.png", @TempDir & "\essential\press2.png", 1) FileInstall (@ScriptDir&"\essential\images-png\press34.png", @TempDir & "\essential\press3.png", 1) FileInstall (@ScriptDir&"\essential\images-png\press44.png", @TempDir & "\essential\press4.png", 1) FileInstall (@ScriptDir&"\essential\images-png\press54.png", @TempDir & "\essential\press5.png", 1) FileInstall (@ScriptDir&"\essential\images-png\press64.png", @TempDir & "\essential\press6.png", 1) FileInstall (@ScriptDir&"\essential\images-png\press74.png", @TempDir & "\essential\press7.png", 1) FileInstall (@ScriptDir&"\essential\images-png\press84.png", @TempDir & "\essential\press8.png", 1) FileInstall (@ScriptDir&"\essential\images-png\press94.png", @TempDir & "\essential\press9.png", 1) FileInstall (@ScriptDir&"\essential\images-png\press104.png", @TempDir & "\essential\press10.png", 1) ;FileInstall (@ScriptDir&"\essential\images-png\press114.png", @TempDir & "\essential\press11.png", 1) FileInstall (@ScriptDir&"\essential\images-png\press124.png", @TempDir & "\essential\press12.png", 1) TraySetIcon (@TempDir & "\essential\devilish.ico") Opt ("TrayAutoPause", 0) Global Const $AC_SRC_ALPHA = 1 Global $posx= @DesktopWidth-163 Global $posy= @DesktopHeight-520 Global Const $MAX_PATH = 260 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxEntryName = 256 Global Const $RAS_MaxDeviceName = 128 $tRASCONN = DllStructCreate("dword dwSize;hwnd hRasConn;char szEntryName[" & $RAS_MaxEntryName + 1 & "];" & "char szDeviceType[" & $RAS_MaxDeviceType + 1 & "];" _ & "char szDeviceName[" & $RAS_MaxDeviceName + 1 & "];" & "char szPhonebook[" & $MAX_PATH & "];" & "dword dwSubEntry;byte guidEntry[16];dword dwFlags;byte luid[8]") $tRAS_STATS = DllStructCreate("dword dwSize;dword dwBytesXmited;dword dwBytesRcved;dword dwFramesXmited;" & _ "dword dwFramesRcved;dword dwCrcErr;dword dwTimeoutErr;dword dwAlignmentErr;" & "dword dwHardwareOverrunErr;dword dwFramingErr;dword dwBufferOverrunErr;" & _ "dword dwCompressionRatioIn;dword dwCompressionRatioOut;dword dwBps;dword dwConnectDuration") $iCntByte = DllStructCreate("dword") $iCntConn = DllStructCreate("dword") DllStructSetData($iCntByte, 1, DllStructGetSize($tRASCONN)) DllStructSetData($tRASCONN, "dwSize", DllStructGetSize($tRASCONN)) DllStructSetData($tRAS_STATS, "dwSize", DllStructGetSize($tRAS_STATS)) _GDIPlus_Startup() $gui = GUICreate ("Launcher-Playlet", 167, 490, $posx, $posy, $WS_POPUP, $WS_EX_LAYERED, WinGetHandle("[CLASS:Progman]")) GUISetIcon (@TempDir & "\essential\devilish.ico") $image_skin = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\normal.png") SetBitmap($gui, $image_skin, 255) $im1 = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\over1.png") $im2 = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\over2.png") $im3 = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\over3.png") $im4 = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\over4.png") $im5 = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\over5.png") $im6 = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\over6.png") $im7 = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\over7.png") $im8 = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\over8.png") $im9 = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\over9.png") $im10 = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\over10.png") ;$im11 = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\over11.png") $im12 = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\over12.png") $im1a = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\press1.png") $im2a = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\press2.png") $im3a = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\press3.png") $im4a = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\press4.png") $im5a = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\press5.png") $im6a = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\press6.png") $im7a = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\press7.png") $im8a = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\press8.png") $im9a = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\press9.png") $im10a = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\press10.png") ;$im11a = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\press11.png") $im12a = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential\press12.png") GUISetState() $controlgui = GUICreate("ControlGUI", 167, 490, $posx, $posy, $WS_POPUP, $WS_EX_LAYERED, $gui) GUISetFont (14, 400, -1, "Comic Sans MS") GUISetBkColor(0x123456,$controlgui) ;GUICtrlCreatePic(@TempDir & "\essential\grey.gif", 0, 0, 167, 490) ;GUICtrlSetState(-1, $GUI_DISABLE) $1 = GUICtrlCreateLabel("Button1", 12, 7, 144, 36, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $2 = GUICtrlCreateLabel("Button2", 12, 48, 144, 36, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $3 = GUICtrlCreateLabel("Button3", 12, 89, 144, 36, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $4 = GUICtrlCreateLabel("Button4", 12, 130, 144, 36, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $5 = GUICtrlCreateLabel("Button5", 12, 171, 144, 36, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $6 = GUICtrlCreateLabel("Button6", 12, 212, 144, 36, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $7 = GUICtrlCreateLabel("Button7", 12, 253, 144, 36, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $8 = GUICtrlCreateLabel("Button8", 12, 294, 144, 36, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $9 = GUICtrlCreateLabel("Button9", 12, 335, 144, 36, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $10 = GUICtrlCreateLabel("Button10", 12, 376, 144, 36, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) #cs $11 = GUICtrlCreateLabel("", 12, 417, 100, 36, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 7) #ce ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;internet status labels $11a = GUICtrlCreateLabel("", 19, 422, 87, 13, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 8) $11b = GUICtrlCreateLabel("", 19, 434, 87, 13, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 8) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;exit button $12 = GUICtrlCreateLabel("", 116, 417, 40, 36, 0x01) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) _API_SetLayeredWindowAttributes($controlgui, 0x123456, 230) GUISetState() $pause = 0 $rest = 0 $over1 = 0 $over1a = 0 $press1 = 0 $over2 = 0 $over2a = 0 $press2 = 0 $over3 = 0 $over3a = 0 $press3 = 0 $over4 = 0 $over4a = 0 $press4 = 0 $over5 = 0 $over5a = 0 $press5 = 0 $over6 = 0 $over6a = 0 $press6 = 0 $over7 = 0 $over7a = 0 $press7 = 0 $over8 = 0 $over8a = 0 $press8 = 0 $over9 = 0 $over9a = 0 $press9 = 0 $over10 = 0 $over10a = 0 $press10 = 0 ;$over11 = 0 ;$over11a = 0 ;$press11 = 0 $over12 = 0 $over12a = 0 $press12 = 0 $lastactive = "" $offline = 1 While 1 If _IsPressed ("24") Then _Pause() $mpos = MouseGetPos() Select Case $mpos[0] > @DesktopWidth-50 $check = WinGetPos ($gui) Select Case $check[0] <> $posx $lastactive = WinGetTitle ("[active]") GUISetState (@SW_SHOW, $gui) For $j = $posx+165 To $posx Step -5 WinMove ($gui, "", $j, $posy) WinMove ($controlgui, "", $j, $posy) Next Case $check[0] = $posx $pause = 0 $pos = GUIGetCursorInfo($controlgui) While $mpos[0] > 1230 If @IPAddress1 <> "127.0.0.1" Then If $offline = 1 Then $aRet = DllCall("rasapi32.dll", "int", "RasEnumConnections", "ptr", DllStructGetPtr($tRASCONN), "ptr", DllStructGetPtr($iCntByte), "ptr", DllStructGetPtr($iCntConn)) If $aRet[0] Then SetError(2, $aRet[0], -1) EndIf If DllStructGetData($iCntConn,1) < 1 Then SetError(1, 0, 0) ;Error: not opened connections EndIf $offline = 0 GUICtrlSetData ($11a, "Online (0')") GUICtrlSetData ($11b, "Usage: 0.00 mb") ElseIf $offline = 0 Then EndIf $aRet = DllCall("rasapi32.dll", "int", "RasGetConnectionStatistics", "hwnd", DllStructGetData($tRASCONN, "hRasConn"), "ptr", DllStructGetPtr($tRAS_STATS)) If $aRet[0] Then SetError(3, $aRet[0], -1) EndIf $stat = DllStructGetData($tRAS_STATS, "dwBytesXmited") $stat2 = DllStructGetData($tRAS_STATS, "dwBytesRcved") $stat3 = DllStructGetData($tRAS_STATS, "dwConnectDuration") $sentmb = Round (($stat / 1048576), 2) $receivedmb = Round (($stat2 / 1048576), 2) $totalsummb = Round ((($stat+$stat2) / 1048576), 2) $time = Round ((($stat3 / 1000) / 60), 2) $split = StringSplit ($time, ".") $min = $split[1] $read = GUICtrlRead ($11a) $read2 = GUICtrlRead ($11b) $splitter = StringSplit ($read, "Online (", 1) $splitter2 = StringSplit ($splitter[2], "')", 1) $accmin = $splitter2[1] $splitter3 = StringSplit ($read2, "Usage: ", 1) $splitter4 = StringSplit ($splitter3[2], " mb", 1) $accmb = $splitter4[1] If $min <> $accmin Or $totalsummb <> $accmb Then Select Case ($totalsummb - $accmb) >= 0.1 GUICtrlSetData ($11a, "Online (" & $min & "')") GUICtrlSetData ($11b, "Usage: " & $totalsummb & " mb") Case $min <> $accmin GUICtrlSetData ($11a, "Online (" & $min & "')") EndSelect Else EndIf ElseIf @IPAddress1 = "127.0.0.1" Then $readoff = GUICtrlRead ($11a) $readoff2 = GUICtrlRead ($11b) If $readoff <> "Offline" Or $readoff = "" Then GUICtrlSetData ($11a, "Offline") GUICtrlSetData ($11b, "Usage: -") $offline = 1 ElseIf $readoff = "Offline" Then EndIf EndIf If _IsPressed ("24") Then _Pause() $mpos = MouseGetPos() $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $1 ;1st $rest = 0 Select Case $pos[2] = 0 If $over1 = 0 Then SetBitmap($gui, $im1, 255) $over1 = 1 ElseIf $over1 = 1 Then EndIf Case $pos[2] = 1 If $press1 = 0 Then SetBitmap($gui, $im1a, 255) $press1 = 1 ElseIf $press1 = 1 Then EndIf While $pos[2] = 1 $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $1 If $press1 = 0 Then SetBitmap($gui, $im1a, 255) $press1 = 1 $over1a = 0 ElseIf $press1 = 1 Then EndIf Case $pos[4] <> $1 If $over1a = 0 Then SetBitmap($gui, $im1, 255) $over1a = 1 $press1 = 0 ElseIf $over1a = 1 Then EndIf EndSelect Sleep(5) WEnd $over1 = 0 $press1 = 0 If $pos[4] = $1 Then MsgBox (0, "", "Button 1") Beep(1000, 50) Beep(2000, 50) EndIf EndSelect Case $pos[4] = $2 ;2nd $rest = 0 Select Case $pos[2] = 0 If $over2 = 0 Then SetBitmap($gui, $im2, 255) $over2 = 1 ElseIf $over2 = 1 Then EndIf Case $pos[2] = 1 If $press2 = 0 Then SetBitmap($gui, $im2a, 255) $press2 = 1 ElseIf $press2 = 1 Then EndIf While $pos[2] = 1 $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $2 If $press2 = 0 Then SetBitmap($gui, $im2a, 255) $press2 = 1 $over2a = 0 ElseIf $press2 = 1 Then EndIf Case $pos[4] <> $2 If $over2a = 0 Then SetBitmap($gui, $im2, 255) $over2a = 1 $press2 = 0 ElseIf $over2a = 1 Then EndIf EndSelect Sleep(5) WEnd $over2 = 0 $press2 = 0 If $pos[4] = $2 Then MsgBox (0, "", "Button 2") Beep(1000, 50) Beep(2000, 50) EndIf EndSelect Case $pos[4] = $3 ;3rd $rest = 0 Select Case $pos[2] = 0 If $over3 = 0 Then SetBitmap($gui, $im3, 255) $over3 = 1 ElseIf $over3 = 1 Then EndIf Case $pos[2] = 1 If $press3 = 0 Then SetBitmap($gui, $im3a, 255) $press3 = 1 ElseIf $press3 = 1 Then EndIf While $pos[2] = 1 $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $3 If $press3 = 0 Then SetBitmap($gui, $im3a, 255) $press3 = 1 $over3a = 0 ElseIf $press3 = 1 Then EndIf Case $pos[4] <> $3 If $over3a = 0 Then SetBitmap($gui, $im3, 255) $over3a = 1 $press3 = 0 ElseIf $over3a = 1 Then EndIf EndSelect Sleep(5) WEnd $over3 = 0 $press3 = 0 If $pos[4] = $3 Then MsgBox (0, "", "Button 3") Beep(1000, 50) Beep(2000, 50) EndIf EndSelect Case $pos[4] = $4 ;4th $rest = 0 Select Case $pos[2] = 0 If $over4 = 0 Then SetBitmap($gui, $im4, 255) $over4 = 1 ElseIf $over4 = 1 Then EndIf Case $pos[2] = 1 If $press4 = 0 Then SetBitmap($gui, $im4a, 255) $press4 = 1 ElseIf $press4 = 1 Then EndIf While $pos[2] = 1 $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $4 If $press4 = 0 Then SetBitmap($gui, $im4a, 255) $press4 = 1 $over4a = 0 ElseIf $press4 = 1 Then EndIf Case $pos[4] <> $4 If $over4a = 0 Then SetBitmap($gui, $im4, 255) $over4a = 1 $press4 = 0 ElseIf $over4a = 1 Then EndIf EndSelect Sleep(5) WEnd $over4 = 0 $press4 = 0 If $pos[4] = $4 Then MsgBox (0, "", "Button 4") Beep(1000, 50) Beep(2000, 50) EndIf EndSelect Case $pos[4] = $5 ;5th $rest = 0 Select Case $pos[2] = 0 If $over5 = 0 Then SetBitmap($gui, $im5, 255) $over5 = 1 ElseIf $over5 = 1 Then EndIf Case $pos[2] = 1 If $press5 = 0 Then SetBitmap($gui, $im5a, 255) $press5 = 1 ElseIf $press5 = 1 Then EndIf While $pos[2] = 1 $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $5 If $press5 = 0 Then SetBitmap($gui, $im5a, 255) $press5 = 1 $over5a = 0 ElseIf $press5 = 1 Then EndIf Case $pos[4] <> $5 If $over5a = 0 Then SetBitmap($gui, $im5, 255) $over5a = 1 $press5 = 0 ElseIf $over5a = 1 Then EndIf EndSelect Sleep(5) WEnd $over5 = 0 $press5 = 0 If $pos[4] = $5 Then MsgBox (0, "", "Button 5") Beep(1000, 50) Beep(2000, 50) EndIf EndSelect Case $pos[4] = $6 ;6th $rest = 0 Select Case $pos[2] = 0 If $over6 = 0 Then SetBitmap($gui, $im6, 255) $over6 = 1 ElseIf $over6 = 1 Then EndIf Case $pos[2] = 1 If $press6 = 0 Then SetBitmap($gui, $im6a, 255) $press6 = 1 ElseIf $press6 = 1 Then EndIf While $pos[2] = 1 $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $6 If $press6 = 0 Then SetBitmap($gui, $im6a, 255) $press6 = 1 $over6a = 0 ElseIf $press6 = 1 Then EndIf Case $pos[4] <> $6 If $over6a = 0 Then SetBitmap($gui, $im6, 255) $over6a = 1 $press6 = 0 ElseIf $over6a = 1 Then EndIf EndSelect Sleep(5) WEnd $over6 = 0 $press6 = 0 If $pos[4] = $6 Then MsgBox (0, "", "Button 6") Beep(1000, 50) Beep(2000, 50) EndIf EndSelect Case $pos[4] = $7 ;7th $rest = 0 Select Case $pos[2] = 0 If $over7 = 0 Then SetBitmap($gui, $im7, 255) $over7 = 1 ElseIf $over7 = 1 Then EndIf Case $pos[2] = 1 If $press7 = 0 Then SetBitmap($gui, $im7a, 255) $press7 = 1 ElseIf $press7 = 1 Then EndIf While $pos[2] = 1 $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $7 If $press7 = 0 Then SetBitmap($gui, $im7a, 255) $press7 = 1 $over7a = 0 ElseIf $press7 = 1 Then EndIf Case $pos[4] <> $7 If $over7a = 0 Then SetBitmap($gui, $im7, 255) $over7a = 1 $press7 = 0 ElseIf $over7a = 1 Then EndIf EndSelect Sleep(5) WEnd $over7 = 0 $press7 = 0 If $pos[4] = $7 Then MsgBox (0, "", "Button 7") Beep(1000, 50) Beep(2000, 50) EndIf EndSelect Case $pos[4] = $8 ;8th $rest = 0 Select Case $pos[2] = 0 If $over8 = 0 Then SetBitmap($gui, $im8, 255) $over8 = 1 ElseIf $over8 = 1 Then EndIf Case $pos[2] = 1 If $press8 = 0 Then SetBitmap($gui, $im8a, 255) $press8 = 1 ElseIf $press8 = 1 Then EndIf While $pos[2] = 1 $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $8 If $press8 = 0 Then SetBitmap($gui, $im8a, 255) $press8 = 1 $over8a = 0 ElseIf $press8 = 1 Then EndIf Case $pos[4] <> $8 If $over8a = 0 Then SetBitmap($gui, $im8, 255) $over8a = 1 $press8 = 0 ElseIf $over8a = 1 Then EndIf EndSelect Sleep(5) WEnd $over8 = 0 $press8 = 0 If $pos[4] = $8 Then MsgBox (0, "", "Button 8") Beep(1000, 50) Beep(2000, 50) EndIf EndSelect Case $pos[4] = $9 ;9th $rest = 0 Select Case $pos[2] = 0 If $over9 = 0 Then SetBitmap($gui, $im9, 255) $over9 = 1 ElseIf $over9 = 1 Then EndIf Case $pos[2] = 1 If $press9 = 0 Then SetBitmap($gui, $im9a, 255) $press9 = 1 ElseIf $press9 = 1 Then EndIf While $pos[2] = 1 $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $9 If $press9 = 0 Then SetBitmap($gui, $im9a, 255) $press9 = 1 $over9a = 0 ElseIf $press9 = 1 Then EndIf Case $pos[4] <> $9 If $over9a = 0 Then SetBitmap($gui, $im9, 255) $over9a = 1 $press9 = 0 ElseIf $over9a = 1 Then EndIf EndSelect Sleep(5) WEnd $over9 = 0 $press9 = 0 If $pos[4] = $9 Then MsgBox (0, "", "Button 9") Beep(1000, 50) Beep(2000, 50) $lastactive = "Program Files" EndIf EndSelect Case $pos[4] = $10 ;10th $rest = 0 Select Case $pos[2] = 0 If $over10 = 0 Then SetBitmap($gui, $im10, 255) $over10 = 1 ElseIf $over10 = 1 Then EndIf Case $pos[2] = 1 If $press10 = 0 Then SetBitmap($gui, $im10a, 255) $press10 = 1 ElseIf $press10 = 1 Then EndIf While $pos[2] = 1 $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $10 If $press10 = 0 Then SetBitmap($gui, $im10a, 255) $press10 = 1 $over10a = 0 ElseIf $press10 = 1 Then EndIf Case $pos[4] <> $10 If $over10a = 0 Then SetBitmap($gui, $im10, 255) $over10a = 1 $press10 = 0 ElseIf $over10a = 1 Then EndIf EndSelect Sleep(5) WEnd $over10 = 0 $press10 = 0 If $pos[4] = $10 Then MsgBox (0, "", "Button 10") Beep(1000, 50) Beep(2000, 50) EndIf EndSelect #cs Case $pos[4] = $11 ;11th - net status button, doesn't need hover control $rest = 0 Select Case $pos[2] = 0 If $over11 = 0 Then SetBitmap($gui, $im11, 255) $over11 = 1 ElseIf $over11 = 1 Then EndIf Case $pos[2] = 1 If $press11 = 0 Then SetBitmap($gui, $im11a, 255) $press11 = 1 ElseIf $press11 = 1 Then EndIf While $pos[2] = 1 $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $11 If $press11 = 0 Then SetBitmap($gui, $im11a, 255) $press11 = 1 $over11a = 0 ElseIf $press11 = 1 Then EndIf Case $pos[4] <> $11 If $over11a = 0 Then SetBitmap($gui, $im11, 255) $over11a = 1 $press11 = 0 ElseIf $over11a = 1 Then EndIf EndSelect Sleep(5) WEnd $over11 = 0 $press11 = 0 If $pos[4] = $11 Then Close_process() Beep(1000, 50) Beep(2000, 50) EndIf EndSelect #ce Case $pos[4] = $12 ;12th - exit button $rest = 0 Select Case $pos[2] = 0 If $over12 = 0 Then SetBitmap($gui, $im12, 255) $over12 = 1 ElseIf $over12 = 1 Then EndIf Case $pos[2] = 1 If $press12 = 0 Then SetBitmap($gui, $im12a, 255) $press12 = 1 ElseIf $press12 = 1 Then EndIf While $pos[2] = 1 $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $12 If $press12 = 0 Then SetBitmap($gui, $im12a, 255) $press12 = 1 $over12a = 0 ElseIf $press12 = 1 Then EndIf Case $pos[4] <> $12 If $over12a = 0 Then SetBitmap($gui, $im12, 255) $over12a = 1 $press12 = 0 ElseIf $over12a = 1 Then EndIf EndSelect Sleep(5) WEnd $over12 = 0 $press12 = 0 If $pos[4] = $12 Then Beep(1000, 50) Beep(2000, 50) Beep(500, 50) Close_process() EndIf EndSelect Case Else ;else - not hovering on any button If $rest = 0 Then SetBitmap($gui, $image_skin, 255) $rest = 1 $over1 = 0 $over1a = 0 $press1 = 0 $over2 = 0 $over2a = 0 $press2 = 0 $over3 = 0 $over3a = 0 $press3 = 0 $over4 = 0 $over4a = 0 $press4 = 0 $over5 = 0 $over5a = 0 $press5 = 0 $over6 = 0 $over6a = 0 $press6 = 0 $over7 = 0 $over7a = 0 $press7 = 0 $over8 = 0 $over8a = 0 $press8 = 0 $over9 = 0 $over9a = 0 $press9 = 0 $over10 = 0 $over10a = 0 $press10 = 0 ;$over11 = 0 ;$over11a = 0 ;$press11 = 0 $over12 = 0 $over12a = 0 $press12 = 0 ElseIf $rest = 1 Then $over1 = 0 $over1a = 0 $press1 = 0 $over2 = 0 $over2a = 0 $press2 = 0 $over3 = 0 $over3a = 0 $press3 = 0 $over4 = 0 $over4a = 0 $press4 = 0 $over5 = 0 $over5a = 0 $press5 = 0 $over6 = 0 $over6a = 0 $press6 = 0 $over7 = 0 $over7a = 0 $press7 = 0 $over8 = 0 $over8a = 0 $press8 = 0 $over9 = 0 $over9a = 0 $press9 = 0 $over10 = 0 $over10a = 0 $press10 = 0 ;$over11 = 0 ;$over11a = 0 ;$press11 = 0 $over12 = 0 $over12a = 0 $press12 = 0 EndIf EndSelect Sleep(5) WEnd EndSelect Case $mpos[0] < 1390 If $pause = 0 Then SetBitmap($gui, $image_skin, 255) $pause = 1 ElseIf $pause = 1 Then $check = WinGetPos ($gui) Select Case $check[0] <> $posx+165 For $i = $posx To $posx+165 Step 5 WinMove ($gui, "", $i, $posy) WinMove ($controlgui, "", $i, $posy) Next GUISetState (@SW_HIDE, $gui) If $lastactive <> "" Then WinActivate ($lastactive) EndIf Case $check[0] = $posx+165 ; EndSelect EndIf EndSelect Sleep(20) WEnd Func Close_process() _GDIPlus_ImageDispose ($image_skin) _GDIPlus_ImageDispose ($im1) _GDIPlus_ImageDispose ($im2) _GDIPlus_ImageDispose ($im3) _GDIPlus_ImageDispose ($im4) _GDIPlus_ImageDispose ($im5) _GDIPlus_ImageDispose ($im6) _GDIPlus_ImageDispose ($im7) _GDIPlus_ImageDispose ($im8) _GDIPlus_ImageDispose ($im9) _GDIPlus_ImageDispose ($im10) ;_GDIPlus_ImageDispose ($im11) _GDIPlus_ImageDispose ($im12) _GDIPlus_ImageDispose ($im1a) _GDIPlus_ImageDispose ($im2a) _GDIPlus_ImageDispose ($im3a) _GDIPlus_ImageDispose ($im4a) _GDIPlus_ImageDispose ($im5a) _GDIPlus_ImageDispose ($im6a) _GDIPlus_ImageDispose ($im7a) _GDIPlus_ImageDispose ($im8a) _GDIPlus_ImageDispose ($im9a) _GDIPlus_ImageDispose ($im10a) ;_GDIPlus_ImageDispose ($im11a) _GDIPlus_ImageDispose ($im12a) _WinAPI_DeleteObject($image_skin) _WinAPI_DeleteObject($im1) _WinAPI_DeleteObject($im2) _WinAPI_DeleteObject($im3) _WinAPI_DeleteObject($im4) _WinAPI_DeleteObject($im5) _WinAPI_DeleteObject($im6) _WinAPI_DeleteObject($im7) _WinAPI_DeleteObject($im8) _WinAPI_DeleteObject($im9) _WinAPI_DeleteObject($im10) ;_WinAPI_DeleteObject($im11) _WinAPI_DeleteObject($im12) _WinAPI_DeleteObject($im1a) _WinAPI_DeleteObject($im2a) _WinAPI_DeleteObject($im3a) _WinAPI_DeleteObject($im4a) _WinAPI_DeleteObject($im5a) _WinAPI_DeleteObject($im6a) _WinAPI_DeleteObject($im7a) _WinAPI_DeleteObject($im8a) _WinAPI_DeleteObject($im9a) _WinAPI_DeleteObject($im10a) ;_WinAPI_DeleteObject($im11a) _WinAPI_DeleteObject($im12a) _GDIPlus_Shutdown() DllClose ("rasapi32.dll") ;Sleep(500) WinActivate ($lastactive) DirRemove (@TempDir & "\essential", 1) Exit EndFunc Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc Func _Pause() $dll = DllOpen("user32.dll") Sleep (1000) Do Sleep (60) Until _IsPressed ("24", $dll) DllClose ($dll) Sleep (1000) EndFunc ;=============================================================================== ; ; Function Name: _API_SetLayeredWindowAttributes ; Description:: Sets Layered Window Attributes:) See MSDN for more informaion ; Parameter(s): ; $hwnd - Handle of GUI to work on ; $i_transcolor - Transparent color ; $Transparency - Set Transparancy of GUI ; $isColorRef - If True, $i_transcolor is a COLORREF-Strucure, else an RGB-Color ; Requirement(s): Layered Windows ; Return Value(s): Success: 1 ; Error: 0 ; @error: 1 to 3 - Error from DllCall ; @error: 4 - Function did not succeed - use ; _WinAPI_GetLastErrorMessage or _WinAPI_GetLastError to get more information ; Author(s): Prog@ndy ; ;=============================================================================== ; Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False) Local Const $AC_SRC_ALPHA = 1 Local Const $ULW_ALPHA = 2 Local Const $LWA_ALPHA = 0x2 Local Const $LWA_COLORKEY = 0x1 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA) Select Case @error Return SetError(@error,0,0) Case $ret[0] = 0 Return SetError(4,0,0) Case Else Return 1 EndSelect EndFunc;==>_API_SetLayeredWindowAttributes Edited November 22, 2009 by picea892 Link to comment Share on other sites More sharing options...
playlet Posted November 24, 2009 Author Share Posted November 24, 2009 (edited) --- Edited August 18, 2016 by playlet Link to comment Share on other sites More sharing options...
dantay9 Posted November 24, 2009 Share Posted November 24, 2009 Slick looking GUI! Great work Playlet. Link to comment Share on other sites More sharing options...
playlet Posted November 24, 2009 Author Share Posted November 24, 2009 (edited) --- Edited August 18, 2016 by playlet Link to comment Share on other sites More sharing options...
picea892 Posted November 25, 2009 Share Posted November 25, 2009 Hi Playlet Congrats on your 100. I like your script, so I thought I would demonstrate with it (I hope you don't mind). I have changed your 1000+ line script to a 350+ line script by using 1 array and multiple for next loops. All seems to work except your IP button looks wonky. I spent more time on this than I wanted, so I'll let you fix that little glitch. I am over my global upload quota so can't upload the pictures (or even the 13 kb script). So below is the revised script. You will have to renumber your pictures and put in a folder called "essential" in your script directory. Renamed pngs would be over1.png; over2.png; over3.png....... press1.png; press2.png; press3.png..... expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\essential\devilish.ico #AutoIt3Wrapper_Outfile=Special Starter 5c.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Description=Launcher by Playlet #AutoIt3Wrapper_Res_Fileversion=5.0.0.0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <StructureConstants.au3> #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <Misc.au3> Global $labelarray[13][8] If WinExists("Launcher-Playlet") Then MsgBox(0, "Warning", "You can only start this application once !") Exit EndIf TraySetIcon(@ScriptDir & "\essential\devilish.ico") Opt("TrayAutoPause", 0) Global Const $AC_SRC_ALPHA = 1 Global $posx = @DesktopWidth - 163 Global $posy = @DesktopHeight - 520 Global Const $MAX_PATH = 260 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxEntryName = 256 Global Const $RAS_MaxDeviceName = 128 $tRASCONN = DllStructCreate("dword dwSize;hwnd hRasConn;char szEntryName[" & $RAS_MaxEntryName + 1 & "];" & "char szDeviceType[" & $RAS_MaxDeviceType + 1 & "];" _ & "char szDeviceName[" & $RAS_MaxDeviceName + 1 & "];" & "char szPhonebook[" & $MAX_PATH & "];" & "dword dwSubEntry;byte guidEntry[16];dword dwFlags;byte luid[8]") $tRAS_STATS = DllStructCreate("dword dwSize;dword dwBytesXmited;dword dwBytesRcved;dword dwFramesXmited;" & _ "dword dwFramesRcved;dword dwCrcErr;dword dwTimeoutErr;dword dwAlignmentErr;" & "dword dwHardwareOverrunErr;dword dwFramingErr;dword dwBufferOverrunErr;" & _ "dword dwCompressionRatioIn;dword dwCompressionRatioOut;dword dwBps;dword dwConnectDuration") $iCntByte = DllStructCreate("dword") $iCntConn = DllStructCreate("dword") DllStructSetData($iCntByte, 1, DllStructGetSize($tRASCONN)) DllStructSetData($tRASCONN, "dwSize", DllStructGetSize($tRASCONN)) DllStructSetData($tRAS_STATS, "dwSize", DllStructGetSize($tRAS_STATS)) _GDIPlus_Startup() $gui = GUICreate("Launcher-Playlet", 167, 490, $posx, $posy, $WS_POPUP, $WS_EX_LAYERED, WinGetHandle("[CLASS:Progman]")) GUISetIcon(@ScriptDir & "\essential\devilish.ico") $image_skin = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\essential\normal.png") SetBitmap($gui, $image_skin, 255) For $i = 1 To 12 $labelarray[$i][0] = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\essential\over" & $i & ".png") $labelarray[$i][1] = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\essential\press" & $i & ".png") Next GUISetState() $controlgui = GUICreate("ControlGUI", 167, 490, $posx, $posy, $WS_POPUP, $WS_EX_LAYERED, $gui) GUISetFont(14, 400, -1, "Comic Sans MS") GUISetBkColor(0x123456, $controlgui) ;GUICtrlCreatePic(@scriptdir & "\essential\grey.gif", 0, 0, 167, 490) ;GUICtrlSetState(-1, $GUI_DISABLE) $goingdown = 7 For $i = 1 To 11 $labelarray[$i][5] = GUICtrlCreateLabel("Button" & $i, 12, $goingdown, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $goingdown = $goingdown + 41 Next $labelarray[11][5] = GUICtrlCreateLabel("", 19, 434, 87, 13, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 8) $labelarray[12][5] = GUICtrlCreateLabel("", 116, 417, 40, 36, 0x01+0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 8) _API_SetLayeredWindowAttributes($controlgui, 0x123456, 230) GUISetState() For $i = 1 To 12 $labelarray[$i][2] = 0 ;used to be $over1 $labelarray[$i][3] = 0 ;used to be $over1a $labelarray[$i][4] = 0 ;used to be $press1 Next Global $pause = 0 Global $rest = 0 Global $lastactive = "" Global $offline = 1 While 1 If _IsPressed("24") Then _Pause() $mpos = MouseGetPos() Select Case $mpos[0] > @DesktopWidth - 300 $check = WinGetPos($gui) Select Case $check[0] <> $posx $lastactive = WinGetTitle("[active]") GUISetState(@SW_SHOW, $gui) For $j = $posx + 165 To $posx Step -5 WinMove($gui, "", $j, $posy) WinMove($controlgui, "", $j, $posy) Next Case $check[0] = $posx $pause = 0 $pos = GUIGetCursorInfo($controlgui) While $mpos[0] > @DesktopWidth-300 If @IPAddress1 <> "127.0.0.1" Then If $offline = 1 Then $aRet = DllCall("rasapi32.dll", "int", "RasEnumConnections", "ptr", DllStructGetPtr($tRASCONN), "ptr", DllStructGetPtr($iCntByte), "ptr", DllStructGetPtr($iCntConn)) If $aRet[0] Then SetError(2, $aRet[0], -1) EndIf If DllStructGetData($iCntConn, 1) < 1 Then SetError(1, 0, 0) ;Error: not opened connections EndIf $offline = 0 GUICtrlSetData($labelarray[11][5], "Online (0')") GUICtrlSetData($labelarray[12][5], "Usage: 0.00 mb") ElseIf $offline = 0 Then EndIf $aRet = DllCall("rasapi32.dll", "int", "RasGetConnectionStatistics", "hwnd", DllStructGetData($tRASCONN, "hRasConn"), "ptr", DllStructGetPtr($tRAS_STATS)) If $aRet[0] Then SetError(3, $aRet[0], -1) EndIf $stat = DllStructGetData($tRAS_STATS, "dwBytesXmited") $stat2 = DllStructGetData($tRAS_STATS, "dwBytesRcved") $stat3 = DllStructGetData($tRAS_STATS, "dwConnectDuration") $sentmb = Round(($stat / 1048576), 2) $receivedmb = Round(($stat2 / 1048576), 2) $totalsummb = Round((($stat + $stat2) / 1048576), 2) $time = Round((($stat3 / 1000) / 60), 2) $split = StringSplit($time, ".") $min = $split[1] $read = GUICtrlRead($labelarray[11][5]) $read2 = GUICtrlRead($labelarray[12][5]) $splitter = StringSplit($read, "Online (", 1) $splitter2 = StringSplit($splitter[2], "')", 1) $accmin = $splitter2[1] $splitter3 = StringSplit($read2, "Usage: ", 1) $splitter4 = StringSplit($splitter3[2], " mb", 1) $accmb = $splitter4[1] If $min <> $accmin Or $totalsummb <> $accmb Then Select Case ($totalsummb - $accmb) >= 0.1 GUICtrlSetData($labelarray[11][5], "Online (" & $min & "')") GUICtrlSetData($labelarray[12][5], "Usage: " & $totalsummb & " mb") Case $min <> $accmin GUICtrlSetData($labelarray[11][5], "Online (" & $min & "')") EndSelect Else EndIf ElseIf @IPAddress1 = "127.0.0.1" Then $readoff = GUICtrlRead($labelarray[11][5]) $readoff2 = GUICtrlRead($labelarray[12][5]) If $readoff <> "Offline" Or $readoff = "" Then GUICtrlSetData($labelarray[11][5], "Offline") GUICtrlSetData($labelarray[12][5], "Usage: -") $offline = 1 ElseIf $readoff = "Offline" Then EndIf EndIf If _IsPressed("24") Then _Pause() $mpos = MouseGetPos() whichbutt() Sleep(5) $i=0 WEnd EndSelect Case $mpos[0] < @DesktopWidth-300 If $pause = 0 Then SetBitmap($gui, $image_skin, 255) $pause = 1 ElseIf $pause = 1 Then $check = WinGetPos($gui) Select Case $check[0] <> $posx + 165 For $b = $posx To $posx + 165 Step 5 WinMove($gui, "", $b, $posy) WinMove($controlgui, "", $b, $posy) Next GUISetState(@SW_HIDE, $gui) If $lastactive <> "" Then WinActivate($lastactive) EndIf Case $check[0] = $posx + 165 ; EndSelect EndIf EndSelect Sleep(20) WEnd Func OnAutoItExit() For $i = 1 To 12 _GDIPlus_ImageDispose($labelarray[$i][0]) _GDIPlus_ImageDispose($labelarray[$i][1]) Next _GDIPlus_ImageDispose($image_skin) _WinAPI_DeleteObject($image_skin) _GDIPlus_Shutdown() DllClose("rasapi32.dll") ;Sleep(500) WinActivate($lastactive) Exit EndFunc ;==>Close_process Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap Func _Pause() $dll = DllOpen("user32.dll") Sleep(1000) Do Sleep(60) Until _IsPressed("24", $dll) DllClose($dll) Sleep(1000) EndFunc ;==>_Pause ;=============================================================================== ; ; Function Name: _API_SetLayeredWindowAttributes ; Description:: Sets Layered Window Attributes:) See MSDN for more informaion ; Parameter(s): ; $hwnd - Handle of GUI to work on ; $i_transcolor - Transparent color ; $Transparency - Set Transparancy of GUI ; $isColorRef - If True, $i_transcolor is a COLORREF-Strucure, else an RGB-Color ; Requirement(s): Layered Windows ; Return Value(s): Success: 1 ; Error: 0 ; @error: 1 to 3 - Error from DllCall ; @error: 4 - Function did not succeed - use ; _WinAPI_GetLastErrorMessage or _WinAPI_GetLastError to get more information ; Author(s): Prog@ndy ; ;=============================================================================== ; Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False) Local Const $AC_SRC_ALPHA = 1 Local Const $ULW_ALPHA = 2 Local Const $LWA_ALPHA = 0x2 Local Const $LWA_COLORKEY = 0x1 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, 0, 0) Case Else Return 1 EndSelect EndFunc ;==>_API_SetLayeredWindowAttributes func whichbutt() $pos = GUIGetCursorInfo($controlgui) For $i = 1 To 12 If $pos[4] = $labelarray[$i][5] Then $rest = 0 Select Case $pos[2] = 0 If $labelarray[$i][2] = 0 Then SetBitmap($gui, $labelarray[$i][0], 255) $labelarray[$i][2] = 1 Return EndIf Case $pos[2] = 1 If $labelarray[$i][4] = 0 Then SetBitmap($gui, $labelarray[$i][1], 255) $labelarray[$i][4] = 1 While $pos[2] = 1 $pos = GUIGetCursorInfo($controlgui) Select Case $pos[4] = $labelarray[$i][5] If $labelarray[$i][4] = 0 Then SetBitmap($gui, $labelarray[$i][1], 255) $labelarray[$i][4] = 1 $labelarray[$i][3] = 0 Return EndIf Case $pos[4] <> $labelarray[$i][5] If $labelarray[$i][3] = 0 Then SetBitmap($gui, $labelarray[$i][0], 255) $labelarray[$i][3] = 1 $labelarray[$i][4] = 0 Return EndIf EndSelect Sleep(5) WEnd $labelarray[$i][2] = 0 $labelarray[$i][4] = 0 if $pos[4] = $labelarray[12][5] Then Beep(1000, 50) Beep(2000, 50) Beep(500, 50) OnAutoItExit() Return EndIf If $pos[4] = $labelarray[$i][5] Then MsgBox(0, "", "Button" & $i) Beep(1000, 50) Beep(2000, 50) Return EndIf EndIf EndSelect EndIf Next reset() EndFunc Func reset() For $i = 1 To 12 $labelarray[$i][2] = 0 ;used to be $over1 $labelarray[$i][3] = 0 ;used to be $over1a $labelarray[$i][4] = 0 ;used to be $press1 Next ; SetBitmap($gui, $image_skin, 255) EndFunc Link to comment Share on other sites More sharing options...
playlet Posted November 27, 2009 Author Share Posted November 27, 2009 (edited) --- Edited August 18, 2016 by playlet Link to comment Share on other sites More sharing options...
playlet Posted November 27, 2009 Author Share Posted November 27, 2009 (edited) --- Edited August 18, 2016 by playlet Link to comment Share on other sites More sharing options...
picea892 Posted November 27, 2009 Share Posted November 27, 2009 (edited) Hi again, glad you cleaned up the script I gave. Seems to be working like you originally intended. Have you seen dantay9's launcher. He seems to have some good ideas that perhaps you can build on. That explosion thing is pretty neat. http://www.autoitscript.com/forum/index.php?showtopic=102956 Edit: Oops, just noticed there was a post I didn't read. Yes I can help. Yes you have one image - load it to memory and you use it multiple times. This is something I'm interested in and would be trying to do anyways. Your script gives a great base to build on. No promises, but maybe over the weekend I can get something going for an example. Maybe Danty9 can contribute his poof stuff too Edited November 27, 2009 by picea892 Link to comment Share on other sites More sharing options...
dantay9 Posted November 28, 2009 Share Posted November 28, 2009 (edited) My toolbar is pretty cool. It is yet another one of my scripts that look great, but seem to not do very well as far as functionality. I got some of the ideas from Rocketdock. You are free to use my code as an example and even copy some of the functions as long as you give me credit for it. I really like the colors and the hover over effects you use. Keep up the good work! Edited November 28, 2009 by dantay9 Link to comment Share on other sites More sharing options...
picea892 Posted November 28, 2009 Share Posted November 28, 2009 Excellent work Playlet, That's exactly what I was thinking of. You beat me to it....I actually hit a bit of a brick wall and was going to go at it tomorrow so I'm glad you got it. I'm sure there are other ways, but your method seems streamlined enough for most purposes. Perhaps other members have other ideas..... Link to comment Share on other sites More sharing options...
playlet Posted November 29, 2009 Author Share Posted November 29, 2009 (edited) --- Edited August 18, 2016 by playlet Link to comment Share on other sites More sharing options...
dantay9 Posted November 29, 2009 Share Posted November 29, 2009 (edited) I made a few small changes to your script. First, I used _Singleton to check if the application was already running. I added an if statement to the OnAutoItExit function to simply exit when caused by _Singleton. I also added a $Sensitivity constant variable to determine the distance from the edge when the gui will pop out. Just thought it would be easier to change that way. Then I changed the select case statements to if statements because I think it is easier to read when the tabs don't go as far across the page. Changed a few select statements to switch statements too for speed. FileInstall also wasn't working when compiled. Here is what I have: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=devilish.ico #AutoIt3Wrapper_outfile=Special Starter 2.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Description=Launcher by Playlet #AutoIt3Wrapper_Res_Fileversion=2.0.0.0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <Misc.au3> If _Singleton(@ScriptName, 1) = 0 Then MsgBox(0, "Warning", "You can only start this application once!") Exit EndIf If Not FileExists(@TempDir & "\essential2\") Then DirCreate(@TempDir & "\essential2\") FileInstall("devilish.ico", @TempDir & "\essential2\devilish.ico", 1) FileInstall("normal.png", @TempDir & "\essential2\normal.png", 1) FileInstall("over.png", @TempDir & "\essential2\over.png", 1) FileInstall("pressed.png", @TempDir & "\essential2\pressed.png", 1) FileInstall("normal-small.png", @TempDir & "\essential2\normal-small.png", 1) FileInstall("over-small.png", @TempDir & "\essential2\over-small.png", 1) FileInstall("pressed-small.png", @TempDir & "\essential2\pressed-small.png", 1) FileInstall("normal-exit.png", @TempDir & "\essential2\normal-exit.png", 1) FileInstall("over-exit.png", @TempDir & "\essential2\over-exit.png", 1) FileInstall("pressed-exit.png", @TempDir & "\essential2\pressed-exit.png", 1) TraySetIcon(@TempDir & "\essential2\devilish.ico") Opt("TrayAutoPause", 0) Global Const $AC_SRC_ALPHA = 1 Global $labelarray[14][6] Global Const $WS_EX_COMPOSITED = 0x2000000 Global Const $Sensitivity = 300 ;adjust this if you need - can be just at the end of the screen or near gui's left side ; gui position Global $posx = @DesktopWidth - 163 Global $posy = @DesktopHeight - 520 ; internet status area LoadNetChecking() ;image loading area _GDIPlus_Startup() $normal = @TempDir & "\essential2\normal.png" $over = @TempDir & "\essential2\over.png" $pressed = @TempDir & "\essential2\pressed.png" $normalimage = _GDIPlus_ImageLoadFromFile($normal) $overimage = _GDIPlus_ImageLoadFromFile($over) $pressedimage = _GDIPlus_ImageLoadFromFile($pressed) $normal_small = @TempDir & "\essential2\normal-small.png" $over_small = @TempDir & "\essential2\over-small.png" $pressed_small = @TempDir & "\essential2\pressed-small.png" $normalimage_small = _GDIPlus_ImageLoadFromFile($normal_small) $overimage_small = _GDIPlus_ImageLoadFromFile($over_small) $pressedimage_small = _GDIPlus_ImageLoadFromFile($pressed_small) $normal_exit = @TempDir & "\essential2\normal-exit.png" $over_exit = @TempDir & "\essential2\over-exit.png" $pressed_exit = @TempDir & "\essential2\pressed-exit.png" $normalimage_exit = _GDIPlus_ImageLoadFromFile($normal_exit) $overimage_exit = _GDIPlus_ImageLoadFromFile($over_exit) $pressedimage_exit = _GDIPlus_ImageLoadFromFile($pressed_exit) ; gui creation area $iW = 167 $iH = 490 $gui = GUICreate("Launcher-Playlet", $iW, $iH, $posx, $posy, $WS_POPUP, $WS_EX_LAYERED, WinGetHandle("[CLASS:Progman]")) GUISetIcon(@TempDir & "\essential2\devilish.ico") GUISetState() ; skin creation area $object_skin = _ImageDraw() $over1 = _ImageDraw("over", 1) $over2 = _ImageDraw("over", 2) $over3 = _ImageDraw("over", 3) $over4 = _ImageDraw("over", 4) $over5 = _ImageDraw("over", 5) $over6 = _ImageDraw("over", 6) $over7 = _ImageDraw("over", 7) $over8 = _ImageDraw("over", 8) $over9 = _ImageDraw("over", 9) $over10 = _ImageDraw("over", 10) $over11 = _ImageDraw("over", 11) $pressed1 = _ImageDraw("pressed", 1) $pressed2 = _ImageDraw("pressed", 2) $pressed3 = _ImageDraw("pressed", 3) $pressed4 = _ImageDraw("pressed", 4) $pressed5 = _ImageDraw("pressed", 5) $pressed6 = _ImageDraw("pressed", 6) $pressed7 = _ImageDraw("pressed", 7) $pressed8 = _ImageDraw("pressed", 8) $pressed9 = _ImageDraw("pressed", 9) $pressed10 = _ImageDraw("pressed", 10) $pressed11 = _ImageDraw("pressed", 11) ; gui holding labels (button text, also for getting hover position) $controlgui = GUICreate("ControlGUI", $iW, $iH, $posx, $posy, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_COMPOSITED, $gui) GUISetFont(14, 400, -1, "Comic Sans MS") GUISetBkColor(0x123456, $controlgui) ; control creation area $labelarray[1][5] = GUICtrlCreateLabel("Button 1", 12, 9, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[2][5] = GUICtrlCreateLabel("Button 2", 12, 50, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[3][5] = GUICtrlCreateLabel("Button 3", 12, 91, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[4][5] = GUICtrlCreateLabel("Button 4", 12, 132, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[5][5] = GUICtrlCreateLabel("Button 5", 12, 173, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[6][5] = GUICtrlCreateLabel("Button 6", 12, 214, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[7][5] = GUICtrlCreateLabel("Button 7", 12, 255, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[8][5] = GUICtrlCreateLabel("Button 8", 12, 296, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[9][5] = GUICtrlCreateLabel("Button 9", 12, 337, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[10][5] = GUICtrlCreateLabel("Button 10", 12, 378, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[11][5] = GUICtrlCreateLabel("", 116, 419, 40, 36); exit button GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $labelarray[12][5] = GUICtrlCreateLabel("", 19, 424, 87, 13, 0x01 + 0x0200); status label GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 8) $labelarray[13][5] = GUICtrlCreateLabel("", 19, 436, 87, 13, 0x01 + 0x0200); usage label GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 8) _API_SetLayeredWindowAttributes($controlgui, 0x123456, 230) GUISetState() ; some state variables For $i = 1 To 11 $labelarray[$i][2] = 0 ;used to be $over1 $labelarray[$i][3] = 0 ;used to be $over1a $labelarray[$i][4] = 0 ;used to be $press1 Next Global $pause = 0 Global $lastactive = "" Global $offline = 1 ;setup main skin SetBitmap($gui, $object_skin, 255) While 1 If _IsPressed("24") Then _Pause() $mpos = MouseGetPos() If $mpos[0] > @DesktopWidth - $Sensitivity Then $check = WinGetPos($gui) If $check[0] <> $posx Then $lastactive = WinGetTitle("[active]") GUISetState(@SW_SHOW, $gui) For $j = $posx + 165 To $posx Step -5 WinMove($gui, "", $j, $posy) WinMove($controlgui, "", $j, $posy) Next ;~ ElseIf $check[0] = $posx Then Else $pause = 0 $pos = GUIGetCursorInfo($controlgui) While $mpos[0] > @DesktopWidth - $Sensitivity $mpos = MouseGetPos() If _IsPressed("24") Then _Pause() ; button checking part $pos = GUIGetCursorInfo($controlgui) For $i = 1 To 11 If $pos[4] = $labelarray[$i][5] Then If $i > 11 Or $pos[2] = 1 Then ExitLoop While $pos[4] = $labelarray[$i][5] $pos = GUIGetCursorInfo($controlgui) Switch $pos[2] Case 0; not pressed If $labelarray[$i][2] = 0 Then $labelarray[$i][2] = 1 SelectOver() EndIf Case 1; pressed If $labelarray[$i][4] = 0 Then $labelarray[$i][4] = 1 SelectPressed() EndIf While $pos[2] = 1; holding pressed $pos = GUIGetCursorInfo($controlgui) If $pos[4] = $labelarray[$i][5] Then ; on the control If $labelarray[$i][4] = 0 Then $labelarray[$i][4] = 1 $labelarray[$i][3] = 0 SelectPressed() EndIf ;~ ElseIf $pos[4] <> $labelarray[$i][5] Then ; not on the control Else If $labelarray[$i][3] = 0 Then $labelarray[$i][3] = 1 $labelarray[$i][4] = 0 SelectOver() EndIf EndIf Sleep(5) WEnd $labelarray[$i][2] = 0 $labelarray[$i][4] = 0 Switch $pos[4] ;still on the control after release Case $pos[4] = $labelarray[11][5] Beep(1000, 50) Beep(2000, 50) Beep(500, 50) OnAutoItExit() Case $pos[4] = $labelarray[$i][5] RunIt($i) EndSwitch EndSwitch Sleep(5) WEnd SetBitmap($gui, $object_skin, 255) ;~ ElseIf $pos[4] <> $labelarray[$i][5] Then Else GetNetStatus(); update status fields only when not over the control - reduces usage EndIf Next Sleep(1) For $i = 1 To 11 $labelarray[$i][2] = 0 ;used to be $over1 $labelarray[$i][3] = 0 ;used to be $over1a $labelarray[$i][4] = 0 ;used to be $press1 Next WEnd EndIf ;~ ElseIf $mpos[0] < @DesktopWidth - 100 Then Else Switch $pause Case 0 SetBitmap($gui, $object_skin, 255) $pause = 1 Case 1 $check = WinGetPos($gui) If $check[0] <> $posx + 165 Then For $b = $posx To $posx + 165 Step 5 WinMove($gui, "", $b, $posy) WinMove($controlgui, "", $b, $posy) Next GUISetState(@SW_HIDE, $gui) If $lastactive <> "" Then WinActivate($lastactive) ;~ ElseIf $check[0] = $posx + 165 Then Else ; EndIf EndSwitch EndIf Sleep(20) WEnd Func RunIt($whichone) ; replace msgboxes with your code Switch $whichone Case 1 MsgBox(0, "", "Button 1") Case 2 MsgBox(0, "", "Button 2") Case 3 MsgBox(0, "", "Button 3") Case 4 MsgBox(0, "", "Button 4") Case 5 MsgBox(0, "", "Button 5") Case 6 MsgBox(0, "", "Button 6") Case 7 MsgBox(0, "", "Button 7") Case 8 MsgBox(0, "", "Button 8") Case 9 MsgBox(0, "", "Button 9") Case 10 MsgBox(0, "", "Button 10") EndSwitch Beep(1000, 50) Beep(2000, 50) EndFunc ;==>RunIt Func LoadNetChecking() Global Const $MAX_PATH = 260 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxEntryName = 256 Global Const $RAS_MaxDeviceName = 128 Global $tRASCONN = DllStructCreate("dword dwSize;hwnd hRasConn;char szEntryName[" & $RAS_MaxEntryName + 1 & "];" & "char szDeviceType[" & $RAS_MaxDeviceType + 1 & "];" _ & "char szDeviceName[" & $RAS_MaxDeviceName + 1 & "];" & "char szPhonebook[" & $MAX_PATH & "];" & "dword dwSubEntry;byte guidEntry[16];dword dwFlags;byte luid[8]") Global $tRAS_STATS = DllStructCreate("dword dwSize;dword dwBytesXmited;dword dwBytesRcved;dword dwFramesXmited;" & _ "dword dwFramesRcved;dword dwCrcErr;dword dwTimeoutErr;dword dwAlignmentErr;" & "dword dwHardwareOverrunErr;dword dwFramingErr;dword dwBufferOverrunErr;" & _ "dword dwCompressionRatioIn;dword dwCompressionRatioOut;dword dwBps;dword dwConnectDuration") Global $iCntByte = DllStructCreate("dword") Global $iCntConn = DllStructCreate("dword") DllStructSetData($iCntByte, 1, DllStructGetSize($tRASCONN)) DllStructSetData($tRASCONN, "dwSize", DllStructGetSize($tRASCONN)) DllStructSetData($tRAS_STATS, "dwSize", DllStructGetSize($tRAS_STATS)) EndFunc ;==>LoadNetChecking Func GetNetStatus() Global $tRASCONN, $iCntByte, $iCntConn, $tRAS_STATS If @IPAddress1 <> "127.0.0.1" Then If $offline = 1 Then $aRet = DllCall("rasapi32.dll", "int", "RasEnumConnections", "ptr", DllStructGetPtr($tRASCONN), "ptr", DllStructGetPtr($iCntByte), "ptr", DllStructGetPtr($iCntConn)) If $aRet[0] Then SetError(2, $aRet[0], -1) If DllStructGetData($iCntConn, 1) < 1 Then SetError(1, 0, 0) ;Error: not opened connections $offline = 0 GUICtrlSetData($labelarray[12][5], "Online (0')") GUICtrlSetData($labelarray[13][5], "Usage: 0.00 mb") EndIf $aRet = DllCall("rasapi32.dll", "int", "RasGetConnectionStatistics", "hwnd", DllStructGetData($tRASCONN, "hRasConn"), "ptr", DllStructGetPtr($tRAS_STATS)) If $aRet[0] Then SetError(3, $aRet[0], -1) $stat = DllStructGetData($tRAS_STATS, "dwBytesXmited") $stat2 = DllStructGetData($tRAS_STATS, "dwBytesRcved") $stat3 = DllStructGetData($tRAS_STATS, "dwConnectDuration") $sentmb = Round(($stat / 1048576), 2) $receivedmb = Round(($stat2 / 1048576), 2) $totalsummb = Round((($stat + $stat2) / 1048576), 2) $time = Round((($stat3 / 1000) / 60), 2) $split = StringSplit($time, ".") $min = $split[1] $read = GUICtrlRead($labelarray[12][5]) $read2 = GUICtrlRead($labelarray[13][5]) $splitter = StringSplit($read, "Online (", 1) $splitter2 = StringSplit($splitter[2], "')", 1) $accmin = $splitter2[1] $splitter3 = StringSplit($read2, "Usage: ", 1) $splitter4 = StringSplit($splitter3[2], " mb", 1) $accmb = $splitter4[1] If $min <> $accmin Or $totalsummb <> $accmb Then If ($totalsummb - $accmb) >= 0.125 Then ;update every ~125 kb GUICtrlSetData($labelarray[12][5], "Online (" & $min & "')") GUICtrlSetData($labelarray[13][5], "Usage: " & $totalsummb & " mb") ElseIf $min <> $accmin Then GUICtrlSetData($labelarray[12][5], "Online (" & $min & "')") EndIf EndIf ;~ ElseIf @IPAddress1 = "127.0.0.1" Then Else $readoff = GUICtrlRead($labelarray[12][5]) $readoff2 = GUICtrlRead($labelarray[13][5]) If $readoff <> "Offline" Or $readoff = "" Then GUICtrlSetData($labelarray[12][5], "Offline") GUICtrlSetData($labelarray[13][5], "Usage: -") $offline = 1 EndIf EndIf EndFunc ;==>GetNetStatus Func SelectPressed() Switch $i Case 1 SetBitmap($gui, $pressed1, 255) Case 2 SetBitmap($gui, $pressed2, 255) Case 3 SetBitmap($gui, $pressed3, 255) Case 4 SetBitmap($gui, $pressed4, 255) Case 5 SetBitmap($gui, $pressed5, 255) Case 6 SetBitmap($gui, $pressed6, 255) Case 7 SetBitmap($gui, $pressed7, 255) Case 8 SetBitmap($gui, $pressed8, 255) Case 9 SetBitmap($gui, $pressed9, 255) Case 10 SetBitmap($gui, $pressed10, 255) Case 11 SetBitmap($gui, $pressed11, 255) EndSwitch EndFunc ;==>SelectPressed Func SelectOver() Switch $i Case 1 SetBitmap($gui, $over1, 255) Case 2 SetBitmap($gui, $over2, 255) Case 3 SetBitmap($gui, $over3, 255) Case 4 SetBitmap($gui, $over4, 255) Case 5 SetBitmap($gui, $over5, 255) Case 6 SetBitmap($gui, $over6, 255) Case 7 SetBitmap($gui, $over7, 255) Case 8 SetBitmap($gui, $over8, 255) Case 9 SetBitmap($gui, $over9, 255) Case 10 SetBitmap($gui, $over10, 255) Case 11 SetBitmap($gui, $over11, 255) EndSwitch EndFunc ;==>SelectOver Func OnAutoItExit() If IsDeclared("WS_EX_COMPOSITED") Then ;if script wasn't closed by _Singleton _GDIPlus_ImageDispose($normalimage) _GDIPlus_ImageDispose($normalimage_small) _GDIPlus_ImageDispose($normalimage_exit) _GDIPlus_ImageDispose($overimage) _GDIPlus_ImageDispose($overimage_small) _GDIPlus_ImageDispose($overimage_exit) _GDIPlus_ImageDispose($pressedimage) _GDIPlus_ImageDispose($pressedimage_small) _GDIPlus_ImageDispose($pressedimage_exit) _GDIPlus_Shutdown() DllClose("rasapi32.dll") WinActivate($lastactive) DirRemove(@TempDir & "\essential2", 1) EndIf Exit EndFunc ;==>OnAutoItExit Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap Func _Pause() $dll = DllOpen("user32.dll") Sleep(1000) Do Sleep(60) Until _IsPressed("24", $dll) DllClose($dll) Sleep(1000) EndFunc ;==>_Pause Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False) Local Const $AC_SRC_ALPHA = 1 Local Const $ULW_ALPHA = 2 Local Const $LWA_ALPHA = 0x2 Local Const $LWA_COLORKEY = 0x1 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA) If @error Then Return SetError(@error, 0, 0) ElseIf $Ret[0] = 0 Then Return SetError(4, 0, 0) Else Return 1 EndIf EndFunc ;==>_API_SetLayeredWindowAttributes Func _ImageDraw($state = "normal", $case = ""); draw a picture on to png Local $hGraphic1, $hBitmap, $hGraphic2 $image1 = $normalimage $image2 = $normalimage $image3 = $normalimage $image4 = $normalimage $image5 = $normalimage $image6 = $normalimage $image7 = $normalimage $image8 = $normalimage $image9 = $normalimage $image10 = $normalimage $image11 = $normalimage_small $image12 = $normalimage_exit ;Create a new bitmap, this way the original opened png is left unchanged $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow()) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic1) $hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap) ; Draw the original opened png into my newly created bitmap Switch $state Case "normal" Case "pressed" Switch $case Case 1 $image1 = $pressedimage Case 2 $image2 = $pressedimage Case 3 $image3 = $pressedimage Case 4 $image4 = $pressedimage Case 5 $image5 = $pressedimage Case 6 $image6 = $pressedimage Case 7 $image7 = $pressedimage Case 8 $image8 = $pressedimage Case 9 $image9 = $pressedimage Case 10 $image10 = $pressedimage Case 11 $image12 = $pressedimage_exit EndSwitch Case "over" Switch $case Case 1 $image1 = $overimage Case 2 $image2 = $overimage Case 3 $image3 = $overimage Case 4 $image4 = $overimage Case 5 $image5 = $overimage Case 6 $image6 = $overimage Case 7 $image7 = $overimage Case 8 $image8 = $overimage Case 9 $image9 = $overimage Case 10 $image10 = $overimage Case 11 $image12 = $overimage_exit EndSwitch EndSwitch _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image1, 0, 0, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image2, 0, 41, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image3, 0, 82, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image4, 0, 123, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image5, 0, 164, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image6, 0, 205, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image7, 0, 246, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image8, 0, 287, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image9, 0, 328, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image10, 0, 369, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image11, 3, 411, 118, 53) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image12, 107, 412, 57, 52) ;Cleanup the no longer needed resources _GDIPlus_GraphicsDispose($hGraphic2) _GDIPlus_GraphicsDispose($hGraphic1) ;Return the new bitmap Return $hBitmap EndFunc ;==>_ImageDraw Your code is getting smaller and smaller. I really love the effects. I think the visual specs are just about done. Great job so far. Edited November 29, 2009 by dantay9 Link to comment Share on other sites More sharing options...
playlet Posted November 29, 2009 Author Share Posted November 29, 2009 (edited) --- Edited August 18, 2016 by playlet Link to comment Share on other sites More sharing options...
picea892 Posted November 29, 2009 Share Posted November 29, 2009 3 other ideas 1) You may not like this idea because it can make the text difficult to read depending on what is under it. Below, I changed the button 1 hover so the text uses transparent font (hole in gui in shape of text). I started down the path of doing it for all buttons but realized that it was going to be a bit of work and I would probably end up changing all the $over1 $pressed1 to array to make it easier to implement. That seemed to be more effort than I wanted to do on a Sunday morning, especially not knowing if it would help. 2) Icons, I'm debating whether icons extracted from the exe to be launched would make it look nicer or not? 3)Reference an ini file for label name and programs to launch. Makes it easier to tweak a compiled script. Also could make a gui interface to add files but that seems like a lot of work when you can do the same with an ini. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=devilish.ico #AutoIt3Wrapper_outfile=Special Starter 2.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Description=Launcher by Playlet #AutoIt3Wrapper_Res_Fileversion=2.0.0.0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <Misc.au3> If _Singleton(@ScriptName, 1) = 0 Then MsgBox(0, "Warning", "You can only start this application once!") Exit EndIf If Not FileExists(@TempDir & "\essential2\") Then DirCreate(@TempDir & "\essential2\") FileInstall("devilish.ico", @TempDir & "\essential2\devilish.ico", 1) FileInstall("normal.png", @TempDir & "\essential2\normal.png", 1) FileInstall("over.png", @TempDir & "\essential2\over.png", 1) FileInstall("pressed.png", @TempDir & "\essential2\pressed.png", 1) FileInstall("normal-small.png", @TempDir & "\essential2\normal-small.png", 1) FileInstall("over-small.png", @TempDir & "\essential2\over-small.png", 1) FileInstall("pressed-small.png", @TempDir & "\essential2\pressed-small.png", 1) FileInstall("normal-exit.png", @TempDir & "\essential2\normal-exit.png", 1) FileInstall("over-exit.png", @TempDir & "\essential2\over-exit.png", 1) FileInstall("pressed-exit.png", @TempDir & "\essential2\pressed-exit.png", 1) TraySetIcon(@TempDir & "\essential2\devilish.ico") Opt("TrayAutoPause", 0) Global Const $AC_SRC_ALPHA = 1 Global $labelarray[14][6] Global Const $WS_EX_COMPOSITED = 0x2000000 Global Const $Sensitivity = 300 ;adjust this if you need - can be just at the end of the screen or near gui's left side - show it Global Const $Sensitivity2 = 300 ;adjust this if you need - can be near gui's left side or more to the left - hide it ; gui position Global $posx = @DesktopWidth - 163 Global $posy = @DesktopHeight - 520 ; internet status area LoadNetChecking() ;image loading area _GDIPlus_Startup() $normal = @TempDir & "\essential2\normal.png" $over = @TempDir & "\essential2\over.png" $pressed = @TempDir & "\essential2\pressed.png" $normalimage = _GDIPlus_ImageLoadFromFile($normal) $overimage = _GDIPlus_ImageLoadFromFile($over) $pressedimage = _GDIPlus_ImageLoadFromFile($pressed) $normal_small = @TempDir & "\essential2\normal-small.png" $over_small = @TempDir & "\essential2\over-small.png" $pressed_small = @TempDir & "\essential2\pressed-small.png" $normalimage_small = _GDIPlus_ImageLoadFromFile($normal_small) $overimage_small = _GDIPlus_ImageLoadFromFile($over_small) $pressedimage_small = _GDIPlus_ImageLoadFromFile($pressed_small) $normal_exit = @TempDir & "\essential2\normal-exit.png" $over_exit = @TempDir & "\essential2\over-exit.png" $pressed_exit = @TempDir & "\essential2\pressed-exit.png" $normalimage_exit = _GDIPlus_ImageLoadFromFile($normal_exit) $overimage_exit = _GDIPlus_ImageLoadFromFile($over_exit) $pressedimage_exit = _GDIPlus_ImageLoadFromFile($pressed_exit) ; gui creation area $iW = 167 $iH = 490 $gui = GUICreate("Launcher-Playlet", $iW, $iH, $posx, $posy, $WS_POPUP, $WS_EX_LAYERED, WinGetHandle("[CLASS:Progman]")) GUISetIcon(@TempDir & "\essential2\devilish.ico") GUISetState() ; skin creation area $object_skin = _ImageDraw() $over1 = _ImageDraw("over", 1) $over1 = _ImageDrawText($over1, "Button 1", 22, 15, 0x0123123, 12, 0, "Arial Black") $over1 = ImageColorToTransparent($over1, 0, 0, $iW, $iH, 0x0123123) $over2 = _ImageDraw("over", 2) $over3 = _ImageDraw("over", 3) $over4 = _ImageDraw("over", 4) $over5 = _ImageDraw("over", 5) $over6 = _ImageDraw("over", 6) $over7 = _ImageDraw("over", 7) $over8 = _ImageDraw("over", 8) $over9 = _ImageDraw("over", 9) $over10 = _ImageDraw("over", 10) $over11 = _ImageDraw("over", 11) $pressed1 = _ImageDraw("pressed", 1) $pressed2 = _ImageDraw("pressed", 2) $pressed3 = _ImageDraw("pressed", 3) $pressed4 = _ImageDraw("pressed", 4) $pressed5 = _ImageDraw("pressed", 5) $pressed6 = _ImageDraw("pressed", 6) $pressed7 = _ImageDraw("pressed", 7) $pressed8 = _ImageDraw("pressed", 8) $pressed9 = _ImageDraw("pressed", 9) $pressed10 = _ImageDraw("pressed", 10) $pressed11 = _ImageDraw("pressed", 11) ; gui holding labels (button text, also for getting hover position) $controlgui = GUICreate("ControlGUI", $iW, $iH, $posx, $posy, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_COMPOSITED, $gui) GUISetFont(14, 400, -1, "Comic Sans MS") GUISetBkColor(0x123456, $controlgui) ; control creation area $labelarray[1][5] = GUICtrlCreateLabel("", 12, 9, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[2][5] = GUICtrlCreateLabel("Button 2", 12, 50, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[3][5] = GUICtrlCreateLabel("Button 3", 12, 91, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[4][5] = GUICtrlCreateLabel("Button 4", 12, 132, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[5][5] = GUICtrlCreateLabel("Button 5", 12, 173, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[6][5] = GUICtrlCreateLabel("Button 6", 12, 214, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[7][5] = GUICtrlCreateLabel("Button 7", 12, 255, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[8][5] = GUICtrlCreateLabel("Button 8", 12, 296, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[9][5] = GUICtrlCreateLabel("Button 9", 12, 337, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[10][5] = GUICtrlCreateLabel("Button 10", 12, 378, 144, 36, 0x01 + 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) $labelarray[11][5] = GUICtrlCreateLabel("", 116, 419, 40, 36); exit button GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $labelarray[12][5] = GUICtrlCreateLabel("", 19, 424, 87, 13, 0x01 + 0x0200); status label GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 8) $labelarray[13][5] = GUICtrlCreateLabel("", 19, 436, 87, 13, 0x01 + 0x0200); usage label GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 8) _API_SetLayeredWindowAttributes($controlgui, 0x123456, 230) GUISetState() ; some state variables For $i = 1 To 11 $labelarray[$i][2] = 0 ;used to be $over1 $labelarray[$i][3] = 0 ;used to be $over1a $labelarray[$i][4] = 0 ;used to be $press1 Next Global $pause = 0 Global $lastactive = "" Global $offline = 1 ;setup main skin SetBitmap($gui, $object_skin, 255) While 1 If _IsPressed("24") Then _Pause() $mpos = MouseGetPos() If $mpos[0] > @DesktopWidth - $Sensitivity Then $check = WinGetPos($gui) If $check[0] <> $posx Then $lastactive = WinGetTitle("[active]") GUISetState(@SW_SHOW, $gui) For $j = $posx + 165 To $posx Step -5 WinMove($gui, "", $j, $posy) WinMove($controlgui, "", $j, $posy) Next ;~ ElseIf $check[0] = $posx Then Else $pause = 0 $pos = GUIGetCursorInfo($controlgui) While $mpos[0] > @DesktopWidth - $Sensitivity2 $mpos = MouseGetPos() If _IsPressed("24") Then _Pause() ; button checking part $pos = GUIGetCursorInfo($controlgui) For $i = 1 To 11 If $pos[4] = $labelarray[$i][5] Then If $i > 11 Or $pos[2] = 1 Then ExitLoop While $pos[4] = $labelarray[$i][5] $pos = GUIGetCursorInfo($controlgui) Switch $pos[2] Case 0; not pressed If $labelarray[$i][2] = 0 Then $labelarray[$i][2] = 1 SelectOver() EndIf Case 1; pressed If $labelarray[$i][4] = 0 Then $labelarray[$i][4] = 1 SelectPressed() EndIf While $pos[2] = 1; holding pressed $pos = GUIGetCursorInfo($controlgui) If $pos[4] = $labelarray[$i][5] Then ; on the control If $labelarray[$i][4] = 0 Then $labelarray[$i][4] = 1 $labelarray[$i][3] = 0 SelectPressed() EndIf ;~ ElseIf $pos[4] <> $labelarray[$i][5] Then ; not on the control Else If $labelarray[$i][3] = 0 Then $labelarray[$i][3] = 1 $labelarray[$i][4] = 0 SelectOver() EndIf EndIf Sleep(5) WEnd $labelarray[$i][2] = 0 $labelarray[$i][4] = 0 Switch $pos[4] ;still on the control after release Case $pos[4] = $labelarray[11][5] Beep(1000, 50) Beep(2000, 50) Beep(500, 50) OnAutoItExit() Case $pos[4] = $labelarray[$i][5] RunIt($i) EndSwitch EndSwitch Sleep(5) WEnd SetBitmap($gui, $object_skin, 255) ;~ ElseIf $pos[4] <> $labelarray[$i][5] Then Else GetNetStatus(); update status fields only when not over the control - reduces usage EndIf Next Sleep(1) For $i = 1 To 11 $labelarray[$i][2] = 0 ;used to be $over1 $labelarray[$i][3] = 0 ;used to be $over1a $labelarray[$i][4] = 0 ;used to be $press1 Next WEnd EndIf ;~ ElseIf $mpos[0] < @DesktopWidth - 100 Then Else Switch $pause Case 0 SetBitmap($gui, $object_skin, 255) $pause = 1 Case 1 $check = WinGetPos($gui) If $check[0] <> $posx + 165 Then For $b = $posx To $posx + 165 Step 5 WinMove($gui, "", $b, $posy) WinMove($controlgui, "", $b, $posy) Next GUISetState(@SW_HIDE, $gui) If $lastactive <> "" Then WinActivate($lastactive) ;~ ElseIf $check[0] = $posx + 165 Then Else ; EndIf EndSwitch EndIf Sleep(20) WEnd Func RunIt($whichone) ; replace msgboxes with your code Switch $whichone Case 1 MsgBox(0, "", "Button 1") Case 2 MsgBox(0, "", "Button 2") Case 3 MsgBox(0, "", "Button 3") Case 4 MsgBox(0, "", "Button 4") Case 5 MsgBox(0, "", "Button 5") Case 6 MsgBox(0, "", "Button 6") Case 7 MsgBox(0, "", "Button 7") Case 8 MsgBox(0, "", "Button 8") Case 9 MsgBox(0, "", "Button 9") Case 10 MsgBox(0, "", "Button 10") EndSwitch Beep(1000, 50) Beep(2000, 50) EndFunc ;==>RunIt Func LoadNetChecking() Global Const $MAX_PATH = 260 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxEntryName = 256 Global Const $RAS_MaxDeviceName = 128 Global $tRASCONN = DllStructCreate("dword dwSize;hwnd hRasConn;char szEntryName[" & $RAS_MaxEntryName + 1 & "];" & "char szDeviceType[" & $RAS_MaxDeviceType + 1 & "];" _ & "char szDeviceName[" & $RAS_MaxDeviceName + 1 & "];" & "char szPhonebook[" & $MAX_PATH & "];" & "dword dwSubEntry;byte guidEntry[16];dword dwFlags;byte luid[8]") Global $tRAS_STATS = DllStructCreate("dword dwSize;dword dwBytesXmited;dword dwBytesRcved;dword dwFramesXmited;" & _ "dword dwFramesRcved;dword dwCrcErr;dword dwTimeoutErr;dword dwAlignmentErr;" & "dword dwHardwareOverrunErr;dword dwFramingErr;dword dwBufferOverrunErr;" & _ "dword dwCompressionRatioIn;dword dwCompressionRatioOut;dword dwBps;dword dwConnectDuration") Global $iCntByte = DllStructCreate("dword") Global $iCntConn = DllStructCreate("dword") DllStructSetData($iCntByte, 1, DllStructGetSize($tRASCONN)) DllStructSetData($tRASCONN, "dwSize", DllStructGetSize($tRASCONN)) DllStructSetData($tRAS_STATS, "dwSize", DllStructGetSize($tRAS_STATS)) EndFunc ;==>LoadNetChecking Func GetNetStatus() Global $tRASCONN, $iCntByte, $iCntConn, $tRAS_STATS If @IPAddress1 <> "127.0.0.1" Then If $offline = 1 Then $aRet = DllCall("rasapi32.dll", "int", "RasEnumConnections", "ptr", DllStructGetPtr($tRASCONN), "ptr", DllStructGetPtr($iCntByte), "ptr", DllStructGetPtr($iCntConn)) If $aRet[0] Then SetError(2, $aRet[0], -1) If DllStructGetData($iCntConn, 1) < 1 Then SetError(1, 0, 0) ;Error: not opened connections $offline = 0 GUICtrlSetData($labelarray[12][5], "Online (0')") GUICtrlSetData($labelarray[13][5], "Usage: 0.00 mb") EndIf $aRet = DllCall("rasapi32.dll", "int", "RasGetConnectionStatistics", "hwnd", DllStructGetData($tRASCONN, "hRasConn"), "ptr", DllStructGetPtr($tRAS_STATS)) If $aRet[0] Then SetError(3, $aRet[0], -1) $stat = DllStructGetData($tRAS_STATS, "dwBytesXmited") $stat2 = DllStructGetData($tRAS_STATS, "dwBytesRcved") $stat3 = DllStructGetData($tRAS_STATS, "dwConnectDuration") $sentmb = Round(($stat / 1048576), 2) $receivedmb = Round(($stat2 / 1048576), 2) $totalsummb = Round((($stat + $stat2) / 1048576), 2) $time = Round((($stat3 / 1000) / 60), 2) $split = StringSplit($time, ".") $min = $split[1] $read = GUICtrlRead($labelarray[12][5]) $read2 = GUICtrlRead($labelarray[13][5]) $splitter = StringSplit($read, "Online (", 1) $splitter2 = StringSplit($splitter[2], "')", 1) $accmin = $splitter2[1] $splitter3 = StringSplit($read2, "Usage: ", 1) $splitter4 = StringSplit($splitter3[2], " mb", 1) $accmb = $splitter4[1] If $min <> $accmin Or $totalsummb <> $accmb Then If ($totalsummb - $accmb) >= 0.125 Then ;update every ~125 kb GUICtrlSetData($labelarray[12][5], "Online (" & $min & "')") GUICtrlSetData($labelarray[13][5], "Usage: " & $totalsummb & " mb") ElseIf $min <> $accmin Then GUICtrlSetData($labelarray[12][5], "Online (" & $min & "')") EndIf EndIf ;~ ElseIf @IPAddress1 = "127.0.0.1" Then Else $readoff = GUICtrlRead($labelarray[12][5]) $readoff2 = GUICtrlRead($labelarray[13][5]) If $readoff <> "Offline" Or $readoff = "" Then GUICtrlSetData($labelarray[12][5], "Offline") GUICtrlSetData($labelarray[13][5], "Usage: -") $offline = 1 EndIf EndIf EndFunc ;==>GetNetStatus Func SelectPressed() Switch $i Case 1 SetBitmap($gui, $pressed1, 255) Case 2 SetBitmap($gui, $pressed2, 255) Case 3 SetBitmap($gui, $pressed3, 255) Case 4 SetBitmap($gui, $pressed4, 255) Case 5 SetBitmap($gui, $pressed5, 255) Case 6 SetBitmap($gui, $pressed6, 255) Case 7 SetBitmap($gui, $pressed7, 255) Case 8 SetBitmap($gui, $pressed8, 255) Case 9 SetBitmap($gui, $pressed9, 255) Case 10 SetBitmap($gui, $pressed10, 255) Case 11 SetBitmap($gui, $pressed11, 255) EndSwitch EndFunc ;==>SelectPressed Func SelectOver() Switch $i Case 1 SetBitmap($gui, $over1, 255) Case 2 SetBitmap($gui, $over2, 255) Case 3 SetBitmap($gui, $over3, 255) Case 4 SetBitmap($gui, $over4, 255) Case 5 SetBitmap($gui, $over5, 255) Case 6 SetBitmap($gui, $over6, 255) Case 7 SetBitmap($gui, $over7, 255) Case 8 SetBitmap($gui, $over8, 255) Case 9 SetBitmap($gui, $over9, 255) Case 10 SetBitmap($gui, $over10, 255) Case 11 SetBitmap($gui, $over11, 255) EndSwitch EndFunc ;==>SelectOver Func OnAutoItExit() If IsDeclared("WS_EX_COMPOSITED") Then ;if script wasn't closed by _Singleton _GDIPlus_ImageDispose($normalimage) _GDIPlus_ImageDispose($normalimage_small) _GDIPlus_ImageDispose($normalimage_exit) _GDIPlus_ImageDispose($overimage) _GDIPlus_ImageDispose($overimage_small) _GDIPlus_ImageDispose($overimage_exit) _GDIPlus_ImageDispose($pressedimage) _GDIPlus_ImageDispose($pressedimage_small) _GDIPlus_ImageDispose($pressedimage_exit) _GDIPlus_Shutdown() DllClose("rasapi32.dll") WinActivate($lastactive) DirRemove(@TempDir & "\essential2", 1) EndIf Exit EndFunc ;==>OnAutoItExit Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap Func _Pause() $dll = DllOpen("user32.dll") Sleep(1000) Do Sleep(60) Until _IsPressed("24", $dll) DllClose($dll) Sleep(1000) EndFunc ;==>_Pause Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False) Local Const $AC_SRC_ALPHA = 1 Local Const $ULW_ALPHA = 2 Local Const $LWA_ALPHA = 0x2 Local Const $LWA_COLORKEY = 0x1 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA) If @error Then Return SetError(@error, 0, 0) ElseIf $Ret[0] = 0 Then Return SetError(4, 0, 0) Else Return 1 EndIf EndFunc ;==>_API_SetLayeredWindowAttributes Func _ImageDraw($state = "normal", $case = ""); draw a picture on to png Local $hGraphic1, $hBitmap, $hGraphic2 $image1 = $normalimage $image2 = $normalimage $image3 = $normalimage $image4 = $normalimage $image5 = $normalimage $image6 = $normalimage $image7 = $normalimage $image8 = $normalimage $image9 = $normalimage $image10 = $normalimage $image11 = $normalimage_small $image12 = $normalimage_exit ;Create a new bitmap, this way the original opened png is left unchanged $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow()) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic1) $hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap) ; Draw the original opened png into my newly created bitmap Switch $state Case "normal" Case "pressed" Switch $case Case 1 $image1 = $pressedimage Case 2 $image2 = $pressedimage Case 3 $image3 = $pressedimage Case 4 $image4 = $pressedimage Case 5 $image5 = $pressedimage Case 6 $image6 = $pressedimage Case 7 $image7 = $pressedimage Case 8 $image8 = $pressedimage Case 9 $image9 = $pressedimage Case 10 $image10 = $pressedimage Case 11 $image12 = $pressedimage_exit EndSwitch Case "over" Switch $case Case 1 $image1 = $overimage Case 2 $image2 = $overimage Case 3 $image3 = $overimage Case 4 $image4 = $overimage Case 5 $image5 = $overimage Case 6 $image6 = $overimage Case 7 $image7 = $overimage Case 8 $image8 = $overimage Case 9 $image9 = $overimage Case 10 $image10 = $overimage Case 11 $image12 = $overimage_exit EndSwitch EndSwitch _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image1, 0, 0, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image2, 0, 41, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image3, 0, 82, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image4, 0, 123, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image5, 0, 164, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image6, 0, 205, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image7, 0, 246, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image8, 0, 287, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image9, 0, 328, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image10, 0, 369, 167, 57) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image11, 3, 411, 118, 53) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $image12, 107, 412, 57, 52) ;Cleanup the no longer needed resources _GDIPlus_GraphicsDispose($hGraphic2) _GDIPlus_GraphicsDispose($hGraphic1) ;Return the new bitmap Return $hBitmap EndFunc ;==>_ImageDraw Func ImageColorToTransparent($hImage2, $iStartPosX = 0, $iStartPosY = 0, $GuiSizeX = Default, $GuiSizeY = Default, $iColor = Default) Local $hBitmap1, $Reslt, $width, $height, $stride, $format, $Scan0, $v_Buffer, $v_Value, $iIW, $iIH $iIW = _GDIPlus_ImageGetWidth($hImage2) $iIH = _GDIPlus_ImageGetHeight($hImage2) If $GuiSizeX = Default Or $GuiSizeX > $iIW - $iStartPosX Then $GuiSizeX = $iIW - $iStartPosX If $GuiSizeY = Default Or $GuiSizeY > $iIH - $iStartPosY Then $GuiSizeY = $iIH - $iStartPosY $hBitmap1 = _GDIPlus_BitmapCloneArea($hImage2, $iStartPosX, $iStartPosY, $GuiSizeX, $GuiSizeY, $GDIP_PXF32ARGB) If $iColor = Default Then $iColor = GDIPlus_BitmapGetPixel($hBitmap1, 1, 1); Transparent color $Reslt = _GDIPlus_BitmapLockBits($hBitmap1, 0, 0, $GuiSizeX, $GuiSizeY, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () $width = DllStructGetData($Reslt, "width") $height = DllStructGetData($Reslt, "height") $stride = DllStructGetData($Reslt, "stride") $format = DllStructGetData($Reslt, "format") $Scan0 = DllStructGetData($Reslt, "Scan0") For $i = 0 To $GuiSizeX - 1 For $j = 0 To $GuiSizeY - 1 $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $v_Value = DllStructGetData($v_Buffer, 1) If Hex($v_Value, 6) = Hex($iColor, 6) Then DllStructSetData($v_Buffer, 1, Hex($iColor, 6)); Sets Transparency here. Alpha Channel = 00, not written to. EndIf Next Next _GDIPlus_BitmapUnlockBits($hBitmap1, $Reslt) Return $hBitmap1 EndFunc ;==>ImageColorToTransparent ;The GetPixel method gets the color of a specified pixel in this bitmap. Func GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) Local $tArgb, $pArgb, $aRet $tArgb = DllStructCreate("dword Argb") $pArgb = DllStructGetPtr($tArgb) $aRet = DllCall($ghGDIPDll, "int", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "ptr", $pArgb) Return "0x" & Hex(DllStructGetData($tArgb, "Argb")) EndFunc ;==>GDIPlus_BitmapGetPixel Func _ImageDrawText($hImage, $sText, $iX = 0, $iY = 0, $iRGB = 0x000000, $iSize = 9, $iStyle = 0, $sFont = "Arial") ;draw text on to png Local $hGraphic1, $hBitmap, $hGraphic2, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $aInfo ;Create a new bitmap, this way the original opened png is left unchanged $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow()) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic1) $hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap) ; Draw the original opened png into my newly created bitmap _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hImage, 0, 0, $iW, $iH) ;Create the font $hBrush = _GDIPlus_BrushCreateSolid ("0xFF" & Hex($iRGB, 6)) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate ($sFont) $hFont = _GDIPlus_FontCreate ($hFamily, $iSize, $iStyle) $tLayout = _GDIPlus_RectFCreate ($iX, $iY, 0, 0) $aInfo = _GDIPlus_GraphicsMeasureString ($hGraphic2, $sText, $hFont, $tLayout, $hFormat) ;Draw the font onto the new bitmap _GDIPlus_GraphicsDrawStringEx ($hGraphic2, $sText, $hFont, $aInfo[0], $hFormat, $hBrush) ;Cleanup the no longer needed resources _GDIPlus_FontDispose ($hFont) _GDIPlus_FontFamilyDispose ($hFamily) _GDIPlus_StringFormatDispose ($hFormat) _GDIPlus_BrushDispose ($hBrush) _GDIPlus_GraphicsDispose ($hGraphic2) _GDIPlus_GraphicsDispose ($hGraphic1) ;Return the new bitmap Return $hBitmap EndFunc Link to comment Share on other sites More sharing options...
playlet Posted November 29, 2009 Author Share Posted November 29, 2009 (edited) --- Edited August 18, 2016 by playlet Link to comment Share on other sites More sharing options...
dantay9 Posted November 29, 2009 Share Posted November 29, 2009 Switch is the fastest. Select Case is faster than if elseif. I think Select Case and if else are about the same. A long if elseif statement is the slowest. For loops are the fastest loops. Do Until loops come in second and While loops come in last. You can use TimerInit and TimerDiff to test the speed of a script. Just make sure you use repetition to get a solid result. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now