Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/03/2019 in all areas

  1. MattyD

    Big Analogue Clock

    Hey folks, This is actually the beginnings of something else - but I was pretty happy with how this part turned out. So hey, here is a clock. it is drag-able Escape (after clicking on clock) : Exit Wheel: Grow & Shrink Click Wheel: Reset Size Edit: somehow missed an include directive... #AutoIt3Wrapper_Au3Check_Parameters = -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #NoTrayIcon #include <GDIPlus.au3> #include <GUIConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Global $hGUI, $iWinH, $iWinW, $iChSize, _ $iStartSz, $iMargin, $iCanvasSz, $iWinXStartPos Global Const $PI = 4 * ATan(1) Global Const $MAGIC_PINK = 0xFF00FF, $MAGIC_PINK_ARGB = 0xFFFF00FF $iWinH = @DesktopHeight $iWinW = $iWinH $iCanvasSz = $iWinH $iMargin = 4 $iStartSz = Int($iWinH / 4) - (2 * $iMargin) $iWinXStartPos = 0 ;Right Side: ide@DesktopWidth - ($iStartSz + (2 * $iMargin)) $hGUI = GUICreate("Clock", $iWinW, $iWinH, $iWinXStartPos, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetBkColor($MAGIC_PINK) _WinAPI_SetLayeredWindowAttributes($hGUI, $MAGIC_PINK, 0xF0) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") GUIRegisterMsg($WM_NCMBUTTONDOWN, "WM_NCMBUTTONDOWN") Clock() Func Clock() Local $hGraphic, $hClockBitmap, $hClockGraphic Local $iSize, $iDigSize, $iOrigin Local $iNumDist, $iDigXOffset, $iDigYOffset Local $ixOffset, $iyOffset Local $hFrameBrush, $hNoseBrush, $hHighlightBrush, $hFaceBrush Local $hBlackPen, $hSecPen, $hMinPen, $hHourPen Local $iSec, $iMin, $iHour Local $ixSecOffset, $iySecOffset, $ixMinOffset, $iyMinOffset, _ $ixHourOffset, $iyHourOffset $iDigSize = $iSize / 20 $iChSize = $iStartSz _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hClockBitmap = _GDIPlus_BitmapCreateFromGraphics($iCanvasSz, $iCanvasSz, $hGraphic) $hClockGraphic = _GDIPlus_ImageGetGraphicsContext($hClockBitmap) _GDIPlus_GraphicsSetSmoothingMode($hClockGraphic, 4) $hFrameBrush = _GDIPlus_BrushCreateSolid(0xFF80BBCC) $hNoseBrush = _GDIPlus_BrushCreateSolid(0xEE778888) $hHighlightBrush = _GDIPlus_BrushCreateSolid(0x44FF00FF) $hFaceBrush = _GDIPlus_BrushCreateSolid(0xFFEEF0FF) $hSecPen = _GDIPlus_PenCreate(0xBB882255, 1) $hMinPen = _GDIPlus_PenCreate(0xBBFF8833, 4) $hHourPen = _GDIPlus_PenCreate(0xEE4488AA, 5) $hBlackPen = _GDIPlus_PenCreate(0xFF000000, 4) Do If $iSize <> $iChSize Or @SEC <> $iSec Then $iSize = $iChSize $iDigSize = $iSize / 20 $iOrigin = Int($iSize / 2) + $iMargin $iNumDist = $iSize / 2 - ($iSize / 8) $iDigXOffset = .55 * $iDigSize $iDigYOffset = -(.7 * $iDigSize) _GDIPlus_GraphicsClear($hClockGraphic, $MAGIC_PINK_ARGB) _GDIPlus_GraphicsFillEllipse($hClockGraphic, $iMargin, $iMargin, $iSize, $iSize, $hFrameBrush) _GDIPlus_GraphicsFillEllipse($hClockGraphic, $iMargin + 8, $iMargin + 8, $iSize - 8, $iSize - 8, $hHighlightBrush) _GDIPlus_GraphicsFillEllipse($hClockGraphic, $iMargin + 8, $iMargin + 8, $iSize - 16, $iSize - 16, $hFaceBrush) _GDIPlus_GraphicsDrawEllipse($hClockGraphic, $iMargin, $iMargin, $iSize, $iSize, $hBlackPen) For $i = 1 To 12 $ixOffset = Int($iNumDist * Sin($i * ($PI / 6))) $iyOffset = Int($iNumDist * Cos($i * ($PI / 6))) $ixOffset -= (StringLen($i) * $iDigXOffset) $iyOffset -= $iDigYOffset _GDIPlus_GraphicsDrawString($hClockGraphic, $i, ($iOrigin + $ixOffset), ($iOrigin - $iyOffset), "Symbol", $iDigSize) Next $iSec = @SEC $iMin = 60 * @MIN + $iSec $iHour = (3600 * @HOUR) + $iMin $ixSecOffset = Int((0.83 * $iNumDist) * Sin($iSec * ($PI / 30))) $iySecOffset = Int((0.83 * $iNumDist) * Cos($iSec * ($PI / 30))) $ixMinOffset = Int((0.85 * $iNumDist) * Sin($iMin * ($PI / 1800))) $iyMinOffset = Int((0.85 * $iNumDist) * Cos($iMin * ($PI / 1800))) $ixHourOffset = Int((0.65 * $iNumDist) * Sin($iHour * ($PI / 21600))) $iyHourOffset = Int((0.65 * $iNumDist) * Cos($iHour * ($PI / 21600))) _GDIPlus_GraphicsDrawLine($hClockGraphic, $iOrigin, $iOrigin, $iOrigin + $ixHourOffset, $iOrigin - $iyHourOffset, $hHourPen) _GDIPlus_GraphicsDrawLine($hClockGraphic, $iOrigin, $iOrigin, $iOrigin + $ixMinOffset, $iOrigin - $iyMinOffset, $hMinPen) _GDIPlus_GraphicsDrawLine($hClockGraphic, $iOrigin, $iOrigin, $iOrigin + $ixSecOffset, $iOrigin - $iySecOffset, $hSecPen) _GDIPlus_GraphicsFillEllipse($hClockGraphic, $iOrigin - 3, $iOrigin - 3, 6, 6, $hNoseBrush) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hClockBitmap, 0, 0, $iCanvasSz, $iCanvasSz) EndIf Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_BrushDispose($hFrameBrush) _GDIPlus_BrushDispose($hNoseBrush) _GDIPlus_BrushDispose($hHighlightBrush) _GDIPlus_BrushDispose($hFaceBrush) _GDIPlus_PenDispose($hSecPen) _GDIPlus_PenDispose($hMinPen) _GDIPlus_PenDispose($hHourPen) _GDIPlus_PenDispose($hBlackPen) _GDIPlus_BitmapDispose($hClockBitmap) _GDIPlus_GraphicsDispose($hClockGraphic) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Clock Func WM_NCMBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam $iChSize = $iStartSz EndFunc ;==>WM_NCMBUTTONDOWN Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Local $iWheelDist, $iRate $iRate = 0.25 $iWheelDist = BitShift($wParam, 16) $iChSize -= Int($iRate * $iWheelDist) If $iChSize < 120 Then $iChSize = 120 If $iChSize > $iCanvasSz - (2 * $iMargin) Then $iChSize = $iCanvasSz - (2 * $iMargin) EndFunc ;==>WM_MOUSEWHEEL Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Return $HTCAPTION EndFunc ;==>WM_NCHITTEST
    2 points
  2. Some direction to get you started (fully in AutoIt no VBS needed) https://www.autoitscript.com/autoit3/docs/functions/Run.htm Example() Func Example() ; Run Notepad with the window maximized. Local $iPID = Run(chr(34)&"C:\Program Files (x86)\Canon\IJ Scan Utility\SCANUTILITY.exe"&chr(34), "", @SW_SHOWMAXIMIZED) ; Wait 10 seconds for the window to appear. WinWait("Canon IJ Scan Utility", "", 10) ; Wait for 2 seconds. Sleep(2000) ControlClick ( "Canon IJ Scan Utility","","[CLASS:Button; Text:Auto; INSTANCE:1]" ) ; Wait for 20 seconds. Sleep(20000) ; TODO: Whatever your needs are ; Close the process using the PID returned by Run. ProcessClose($iPID) EndFunc ;==>Example For taskkill https://www.autoitscript.com/autoit3/docs/functions/ProcessList.htm https://www.autoitscript.com/autoit3/docs/functions/ProcessClose.htm
    1 point
  3. @masusaca as mentioned, you're not going to get much in the way of VBScript help on an AutoIt forum. Please look at the AutoIt help file for Run, including the examples - much easier than VBS...
    1 point
  4. This is an Autoit forum, not a VB Script forum
    1 point
  5. Changed script in previous post of me a little sizing of the overlay window a little better added a pixelgetcolor to have same background as titlebar (unsure if there is a function to get actual color)
    1 point
  6. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> #include <ColorConstants.au3> #include <WinAPISys.au3> Local $ySize=_WinAPI_GetSystemMetrics ( 31 ) + 8 ;~ SM_CYSIZE Local $xSize=_WinAPI_GetSystemMetrics ( 30 ) + 10 ;~ SM_CXSIZE Local $sizeBlock=40 Local $adjustment=$sizeBlock+ 8 + 6 ;~ Local $hGui=GUICreate("Test", $sizeBlock, $sizeBlock, 100, 100, $WS_POPUPWINDOW, BitOr ($WS_EX_TOOLWINDOW , $WS_EX_TRANSPARENT)) ;~ Local $hGui=GUICreate("Test", $sizeBlock, $sizeBlock, 100, 100, $WS_POPUPWINDOW) Local $hGui=GUICreate("Welcome", $xSize, $ySize, 100, 100, BitOR($WS_SYSMENU,$WS_POPUP), 0) GUISetBkColor($COLOR_WHITE,$hGui) ; Display the GUI. $hwndActive=wingethandle("[ACTIVE]", "") GUISetState(@SW_SHOW, $hGUI) WinActivate($hwndActive) ; Loop until the user exits. While 1 $hwndActive=wingethandle("[ACTIVE]", "") if ($hWndActive <> $hGui) Then $hwndPrevious=$hwndActive $aPos = WinGetPos("[ACTIVE]") $newColor=pixelgetcolor($apos[0] + $aPos[2] - 16, $aPos[1] + 4) GUISetBkColor($newColor,$hGui) EndIf ;~ WinMove($hGui,"",$apos[0], $aPos[1]) ; Apply the style _WinAPI_SetWindowPos($hGui, $HWND_TOPMOST, $apos[0] + $aPos[2] - $adjustment, $apos[1]+1, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOSIZE)) Switch GUIGetMsg() Case $GUI_EVENT_PRIMARYDOWN tooltip("You shouldnt do that, I will stop now preventing you to click on top right") ; Set the background color local $i for $i=1 to 5 GUISetBkColor($COLOR_RED,$hGui) sleep(250) GUISetBkColor($COLOR_GREEN,$hGui) sleep(250) Next ToolTip("") winactivate($hwndPrevious) exit Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd
    1 point
  7. Works like a charm! Thank you!
    1 point
  8. KaFu

    dll call failed

    #include <ScreenCapture.au3> #include <GDIPlus.au3> _GDIPlus_Startup() ;initialize GDI+ $hDLL = DllOpen("DXGCap32.dll") ;~ void init() DllCall($hDLL, "none:cdecl", "init") If @error Then Exit -1 ;~ void* create_dxgi_manager() $aCall = DllCall($hDLL, "ptr:cdecl", "create_dxgi_manager") If @error Then Exit -2 ; Read data $pManager = $aCall[0] ;~ void get_output_dimensions(void*const dxgi_manager, uint32_t* width, uint32_t* height) $aCall = DllCall($hDLL, "none:cdecl", "get_output_dimensions", "ptr", $pManager, "uint*", 0, "uint*", 0) If @error Then Exit -3 ConsoleWrite("Width = " & $aCall[2] & ", Height = " & $aCall[3] & @CRLF) $iWidth = $aCall[2] $iHeight = $aCall[3] ;~ uint8_t get_frame_bytes(void* dxgi_manager, size_t* o_size, uint8_t** o_bytes) Local $pBuffer, $iBufferSize $aCall = DllCall($hDLL, "byte:cdecl", "get_frame_bytes", "ptr", $pManager, "uint*", 0, "ptr*", 0) If @error Then Exit -4 ; Read data $iBufferSize = $aCall[2] $pBuffer = $aCall[3] ; Fill the buffer $aCall = DllCall($hDLL, "byte:cdecl", "get_frame_bytes", "ptr", $pManager, "uint*", $iBufferSize, "ptr", $pBuffer) If @error Then Exit -5 #cs ; Make the data accessible thru dllstruct $tData = DllStructCreate("byte[" & $iBufferSize & "]", $pBuffer) If @error Then Exit -6 #ce ConsoleWrite($iWidth & @TAB & $iHeight & @TAB & $pBuffer & @CRLF) Local $hBMP = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $GDIP_PXF32ARGB, 4 * $iWidth, $pBuffer) ConsoleWrite($hBMP & @CRLF) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP) _GDIPlus_ImageDispose($hBMP) ConsoleWrite($hBitmap & @CRLF) ConsoleWrite(_ScreenCapture_SaveImage(@ScriptDir & "\test.bmp", $hBitmap) & @CRLF) _WinAPI_DeleteObject($hBitmap) ;~ void delete_dxgi_manager(void* dxgi_manager) DllCall($hDLL, "none:cdecl", "delete_dxgi_manager", "ptr", $pManager) If @error Then Exit -7 _GDIPlus_Shutdown()
    1 point
  9. Oh this thread again. Neat I'd love to see AutoIt on Linux, however it's unlikely to happen. Regardless, if it does start to happen hit me up with the Repository info. That being said... I had a small workaround with AutoIt. I was working on a "WineBridge" in which a made a bash script that would handle the stdout and stderr pipes from the executable and converting those to python or other language commands. I don't think I ever figured out passing data back into AutoIt, or if I did I don't have the code for it anywhere. It gave Autoit the ability to run commands from wine and I'm sure it could be expanded further. EDIT: I was able to find some of my old 2012-era code on my github. Please ignore any bad coding practices, I was a lot worse back then, using magic numbers and all sorts of No-Nos. https://github.com/rcmaehl/Discontinued-Projects/tree/master/WineBridge I think half the code is missing as I remember it having more functionality than this.
    1 point
  10. Exactly! It doesn't seem to affect any other "action" less the automatic navigation to the about:blank; by the way, happy to have helped (even if a little bit)
    1 point
  11. Doesn't _GUICtrlListView_SetItemImage() do what you want? Take a look at the example for this function in the help-file.
    1 point
  12. @Adele If you look in the Help file, you can see that if you run your script on Windows 8, you'll get WIN_8, else, if you run your script on Windows 8.1, you'll get WIN_81
    1 point
  13. Hello from the other side. Thanks, this was the first thing that i thought, but i dont have them installed. Do you know what are the build numbers?
    1 point
  14. @Adele "Hello!" Cit. Check the @OSVersion macro in the Help file for its return value
    1 point
  15. hi, just for your information: i have just run a test on your script and used the example file "RTF_Printer_Examples.au3" and an error occurs at line 653. autoit states the following error: >Running AU3Check (3.3.14.5) from:C:\AutoIt3 input:C:\AutoIt3\testscripts\RTF_Printer_Examples.au3 "C:\AutoIt3\Include\RTF_Printer.au3"(653,55) : error: _WinAPI_GetDeviceCaps(): undefined function. Local $dotInchX = _WinAPI_GetDeviceCaps($hPrintDc, 88) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AutoIt3\testscripts\RTF_Printer_Examples.au3 - 1 error(s), 0 warning(s) !>08:58:36 AU3Check ended. Press F4 to jump to next error.rc:2 i just thought you might want to know that. kind regards
    1 point
  16. that should work if you put the code into a page saved in your pc, then have chrome load that page every time it opens,
    1 point
  17. Maybe if you add some javascript thry your addressbar or as a bookmarklet javascript:window.onbeforeunload = confirmExit;function confirmExit() {return "You attempt to leave this page. Are you sure?";} Not fully tested but seems to work. Maybe other events are better for above trick.
    1 point
  18. if you accidentally close multiple tabs, just re-open chrome and press ctrl+shift+t to load all tabs that were closed.
    1 point
×
×
  • Create New...