Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/04/2016 in all areas

  1. nend

    Regex toolkit

    This is a program that I made to help my self learn better regular expressions. There are a lot of other programs/website with the similar functions. The main advantage of this program is that you don't have to click a button after every changes. The program detected changes and react on it. Function: Match Match of arrays Match and replace Load source data from website Load source data from a website with GET/POST Load text data from file Clear fields Export and Import settings (you can finish the expression a other time, just export/import it) Cheat sheet DPI aware Generate AutoIt code example code The source code is not difficult and I think most user will understand it. In the zip file there is a export files (reg back example), you can drag and drop this files on the gui to import it. EDIT: Updated to version V1.2.0 Changes are: Expand and collapse of the cheat sheet (Thanks to Melba23 for the Guiextender UDF) Usefull regular expressions websites links included in the program Text data update time EDIT: Updated to version V1.3.0 Changes are: Automatic generate AutoIt code Icons on the tab Few minor bug fixes EDIT: Updated to version V1.4.0 Changes are: Link to AutoIt regex helpfile If the regular expression has a error than the text becomes red Option Offset with Match and array of Matches Option Count with Match and replace Some small minor bug fixed EDIT: Updated to version V1.4.1 Changes are: Small bug in "create AutoIt" code fixed EDIT: Updated to version V1.4.2 Changes are: Small bug in "create AutoIt" code fixed Bug with website data fixed EDIT: Updated to version V1.4.3 Changes are: DPI aware Click function on cheat sheet to insert function in the regex input field (Sourcode, example and compiled exe file) Regex toolkit.zip
    2 points
  2. Sers, while working on another project I was in need of desktop notifications. I wanted an own implementation and from time to time the code grew and I thought about sharing it with the world. I know that there is a similar UDF out there but when my project got bigger an UDF was the best choice for me. As you can see the UDF's differ in usage and style of notifications. So, what do we have? The UDF offers the usage of permanent desktop notifications for your own script in a very easy way. Notifications are starting in the bottom right corner of your main screen and will be shown on top until there is no more space. Further notifications will be shown if previous ones are closed. The notifications have a nice minimalistic design in two colors. By default they match the look of the dark taskbar in Windows 10, but colors and other things can be set differently if wished (see example scripts). The UDF works for GUIOnEventMode activated and deactivated and detects it automatically. Show me! Each notification has its GUI, a title, the message, a seperating line, date label, time label and a closing button (and if activated, a border around the notification). The color of the title, message, seperating line, date, time and closing button (+ border if activated) have all the text color. Right now notifications have a fixed size. I thought about variable sizes but did not add it because I didn't need it so far. Some people may notice the shorter seperating line when border is activated, thats just because of better looks Notifications will be colored as the following: Windows 10: they match the design of the taskbar Windows 8/8.1: On most designs: they match the border color of active windows, else they are black with transparency (see screenshot) Windows 7 and earlier: black with transparency (sry aero) How do I use notifications in my script? include UDF call _Notifications_Startup() (after you determined if you want to use GUIOnEventMode or not) If GUIOneventMode deactivated: call _Notifications_CheckGUIMsg($__GUIMsg) in your main loop create a notification using _Notifications_Create($__title, $__message) Between step 2 and 3 you can set various options: _Notifications_SetAnimationTime _Notifications_SetBorder _Notifications_SetButtonText _Notifications_SetBkColor _Notifications_SetColor _Notifications_SetDateFormat _Notifications_SetSound _Notifications_SetTextAlign _Notifications_SetTimeFormat _Notifications_SetTransparency You can also set own functions to be called when notifications are clicked (see advanced example). And now? You can find more information in the UDF. There also are two example scripts to show the usage for GUIOnEventMode activated and deactivated. Another advanced example shows the usage of the Set-Functions. Thats it? Yup, have fun. Changelog Notifications.au3 ( v1.2) Notifications GUIMsg Example.au3 Notifications OnEvent Example.au3 Notifications Advanced Example.au3
    1 point
  3. Trap your Launch function in an infinite while loop with a 10 minute (or however long you want) sleep at the end. While (True) launch() Sleep(10 * 60000) ; 10 minutes WEnd Func launch() Local $sFileContent = "" Local $hFile = FileOpen("c:\url.txt", 0) ; If the file opens, it will fail if the file doesn't exist so no need to check if it exists first If ($hFile) Then FileClose($hFile) ; Be sure to close the file when you're done EndIf EndFunc ;==>launch
    1 point
  4. It's not declared because neither of your If statements resolve to TRUE so the variable declaration never happens. Find out why neither of those are TRUE and that should fix the problem. Although as a good coding practice you should never declare a variable that way, declare the variable first then use the If/Then to set its value.
    1 point
  5. #include <GDIPlus.au3> #include <GUIConstants.au3> #include <WinAPI.au3> Global $hMain = GUICreate("Example", 1024, 768) Global $picImage = GUICtrlCreatePic("", 0, 0, 1024, 768) Global $hHBitmapImages = CreateImage() _WinAPI_DeleteObject(GUICtrlSendMsg($picImage, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmapImages)) GUISetState(@SW_SHOW, $hMain) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _WinAPI_DeleteObject($hHBitmapImages) Func CreateImage() _GDIPlus_Startup() Local $hBitmap = _GDIPlus_BitmapCreateFromScan0(1024, 768) Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $sRegPath = "HKLM\SOFTWARE\Wow6432Node\AutoIt v3\AutoIt" Local $sAutoitPath = RegRead($sRegPath, "InstallDir") Local $hImageMsoobe = _GDIPlus_ImageLoadFromFile($sAutoitPath & "\Examples\GUI\msoobe.jpg") Local $hImageMsLogo = _GDIPlus_ImageLoadFromFile($sAutoitPath & "\Examples\GUI\mslogo.jpg") Local $hImageTorus = _GDIPlus_ImageLoadFromFile($sAutoitPath & "\Examples\GUI\torus.png") Local $hHReturn = Null _GDIPlus_GraphicsClear($hGraphics) _GDIPlus_GraphicsDrawImage($hGraphics, $hImageMsoobe, 0, 0) _GDIPlus_GraphicsDrawImage($hGraphics, $hImageMsLogo, 0, 768 - _GDIPlus_ImageGetHeight($hImageMsLogo)) _GDIPlus_GraphicsDrawImage($hGraphics, $hImageTorus, (1024 / 2) - (_GDIPlus_ImageGetWidth($hImageTorus) / 2), 0) $hHReturn = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() Return $hHReturn EndFunc ;==>DrawImages
    1 point
  6. The Z-Order is in the order of creating. When PNG-File has transparency it is used. I use GUICtrlPic.au3 for creating Controls with PNG-image. #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUICtrlPic.au3> Global $aHoverBtn[5][5] $aHoverBtn[0][1] = @ScriptDir & "\Pictures\Up.png" $aHoverBtn[0][2] = @ScriptDir & "\Pictures\UpHovered.png" $aHoverBtn[0][3] = @ScriptDir & "\Pictures\UpPressed.png" $aHoverBtn[0][4] = False $aHoverBtn[1][1] = @ScriptDir & "\Pictures\Down.png" $aHoverBtn[1][2] = @ScriptDir & "\Pictures\DownHovered.png" $aHoverBtn[1][3] = @ScriptDir & "\Pictures\DownPressed.png" $aHoverBtn[1][4] = False $aHoverBtn[2][1] = @ScriptDir & "\Pictures\Left.png" $aHoverBtn[2][2] = @ScriptDir & "\Pictures\LeftHovered.png" $aHoverBtn[2][3] = @ScriptDir & "\Pictures\LeftPressed.png" $aHoverBtn[2][4] = False $aHoverBtn[3][1] = @ScriptDir & "\Pictures\Right.png" $aHoverBtn[3][2] = @ScriptDir & "\Pictures\RightHovered.png" $aHoverBtn[3][3] = @ScriptDir & "\Pictures\RightPressed.png" $aHoverBtn[3][4] = False $aHoverBtn[4][1] = @ScriptDir & "\Pictures\Exit.png" $aHoverBtn[4][2] = @ScriptDir & "\Pictures\ExitHovered.png" $aHoverBtn[4][3] = @ScriptDir & "\Pictures\ExitPressed.png" $aHoverBtn[4][4] = False Global $hGui = GUICreate("Hovered Ping-Buttons", 612, 369, 271, 235) Local $sAutoItPath = StringReplace(@AutoItExe, "autoit3.exe", "") ConsoleWrite($sAutoItPath & "Examples\GUI\msoobe.jpg" & @CRLF) Local $Background = _GUICtrlPic_Create($sAutoItPath & "Examples\GUI\msoobe.jpg", 0, 0, 612, 369, $SS_CENTERIMAGE, Default) GUICtrlSetState(-1, $Gui_DISABLE) Local $idTorus = _GUICtrlPic_Create($sAutoItPath & "Examples\GUI\Torus.png", 8, 8, 68, 71, $SS_CENTERIMAGE, Default) GUICtrlSetState(-1, $Gui_DISABLE) $aHoverBtn[0][0] = _GUICtrlPic_Create($aHoverBtn[0][1], 460, 8, 48, 48, BitOR($SS_CENTERIMAGE, $SS_NOTIFY), Default) ;Up $aHoverBtn[1][0] = _GUICtrlPic_Create($aHoverBtn[1][1], 460, 138, 48, 48, BitOR($SS_CENTERIMAGE, $SS_NOTIFY), Default) ;Down $aHoverBtn[2][0] = _GUICtrlPic_Create($aHoverBtn[2][1], 400, 73, 48, 48, BitOR($SS_CENTERIMAGE, $SS_NOTIFY), Default) ;Left $aHoverBtn[3][0] = _GUICtrlPic_Create($aHoverBtn[3][1], 520, 73, 48, 48, BitOR($SS_CENTERIMAGE, $SS_NOTIFY), Default) ;Right $aHoverBtn[4][0] = _GUICtrlPic_Create($aHoverBtn[4][1], 540, 266, 48, 48, BitOR($SS_CENTERIMAGE, $SS_NOTIFY), Default) ;Exit GUISetState() While 1 #Region ;Hover Or Not? $Info = GUIGetCursorInfo($hGui) For $i = 0 To UBound($aHoverBtn) - 1 If $Info[4] = $aHoverBtn[$i][0] Then If $aHoverBtn[$i][4] Then _GUICtrlPic_SetImage($aHoverBtn[$i][0], $aHoverBtn[$i][2], True) $aHoverBtn[$i][4] = False Else If Not $aHoverBtn[$i][4] Then _GUICtrlPic_SetImage($aHoverBtn[$i][0], $aHoverBtn[$i][1], True) $aHoverBtn[$i][4] = True EndIf Next #EndRegion ;Hover Or Not? $nMsg = GUIGetMsg() $aPos = ControlGetPos($hGui, "", $idTorus) Switch $nMsg Case $Gui_EVENT_CLOSE Exit Case $aHoverBtn[0][0] If _GuiCtrlPic_AnimButton($hGui, $aHoverBtn[0][0], $aHoverBtn[0][1], $aHoverBtn[0][3]) Then $aPos[1] -= 5 ;nach oben Case $aHoverBtn[1][0] If _GuiCtrlPic_AnimButton($hGui, $aHoverBtn[1][0], $aHoverBtn[1][1], $aHoverBtn[1][3]) Then $aPos[1] += 5 ;nach unten Case $aHoverBtn[2][0] If _GuiCtrlPic_AnimButton($hGui, $aHoverBtn[2][0], $aHoverBtn[2][1], $aHoverBtn[2][3]) Then $aPos[0] -= 5 ;nach links Case $aHoverBtn[3][0] If _GuiCtrlPic_AnimButton($hGui, $aHoverBtn[3][0], $aHoverBtn[3][1], $aHoverBtn[3][3]) Then $aPos[0] += 5 ;nach rechts Case $aHoverBtn[4][0] If _GuiCtrlPic_AnimButton($hGui, $aHoverBtn[4][0], $aHoverBtn[4][1], $aHoverBtn[4][3]) Then Exit EndSwitch ControlMove($hGui, "", $idTorus, $aPos[0], $aPos[1]) WEnd What have you tried?
    1 point
  7. scintilla4evr

    Advanced Math UDF

    Version 1.4: Added SolveDiff() for numerically solving differential equations Added Fresnel integrals (FresnelC and FresnelS) Added some statistical functions (more later) Added Clausen() Added IncompleteGamma() Added basic genetic algorithm functions (see Genetic.au3) Fixed issues with _Degree(), _Radian() and _MathCheckDiv() I'll try to make an example of a genetic algorithm and include it in the next version. Advanced Math UDF
    1 point
  8. Thanks for the credit point out Ascend4nt. Ive thought about doing the same type of expansion myself with the code below and passing an array of process handles. My only worry was how far off would the system times be by the time I got to the last call of getprocesstimes. But might be over thinking it Decipher, Heres another example you could adapt from thats a little cleaner then I wrote back then with more of the updated syntax that autoit currently has. When I originally wrote it the main thought in my head was everything could be all in one function cause Im only monitoring the process itself. Hense the static var for the process handle. If the handle might change, I would recommend functions like below that except the handle as a parameter. I realize it was just a quick fix, but a global var that changes a local static var is not a good choice. Also note the use of the _ProcessExists function Im using. Its much more efficient than autoits built in one due to how autoit enumerates all processes, then goes throught the list looking for the pid. This returns both total cpu and process cpu. #AutoIt3Wrapper_UseX64=n #include <winapi.au3> #include <Timers.au3> ;Press ESC to Exit HotKeySet('{ESC}', '_Exit') ;Press Alt-L to generate a test load HotKeySet('!l', '_TestLoad') ;Define requested access rights depending on which os is being used Global $iAccess = 0x0400 ; PROCESS_QUERY_INFORMATION (xp) If (@OSBuild > 3790) Then $iAccess = 0x1000 ; PROCESS_QUERY_LIMITED_INFORMATION (Vista and up) ;Get Handle to autoit process Global $g_hAutoItProcess = _WinAPI_OpenProcess($iAccess, 0, @AutoItPID) If @error Then Exit (ConsoleWrite('Error getting handle' & @LF)) ;Call _GetProcessCPU() 1/sec AdlibRegister('_ProcessCPUExample', 1000) ;Sleep till exit While Sleep(600000) WEnd Func _ProcessCPUExample() Static Local $aEnd, $aStart = _GetProcessUsage($g_hAutoItProcess) $aEnd = _GetProcessUsage($g_hAutoItProcess) ;Get both total and process cpu usage Local $aCPU = _CalcUsage($aStart, $aEnd) ;Make sure cpu values are valid If $aCPU[0] >= 0 And $aCPU[0] <= 100 Then ConsoleWrite('Total CPU Usage = ' & $aCPU[0] & '%' & @TAB & @TAB & 'AutoIt CPU Usage = ' & $aCPU[1] & '%' & @LF) EndIf ;copy last cpu times to start. $aStart = $aEnd EndFunc ;==>_GetProcessCPU Func _GetProcessUsage($hProc) Static Local $tIdle = DllStructCreate("dword;dword"), $tUser = DllStructCreate("dword;dword"), $tKernel = DllStructCreate("dword;dword") Static Local $tCreation = DllStructCreate("dword;dword"), $tExit = DllStructCreate("dword;dword") ;Make sure process still exists If Not _ProcessExists($hProc) Then Return SetError(1, 0, -1) ;Array for holding idle, System and process cpu times Local $aTimes[3] ;Get system CPU times DllCall('Kernel32.dll', "int", "GetSystemTimes", "struct*", $tIdle, "struct*", $tUser, "struct*", $tKernel) $aTimes[0] = DllStructGetData($tIdle, 1) $aTimes[1] = DllStructGetData($tUser, 1) + DllStructGetData($tKernel, 1) ;Get Process cpu times DllCall('Kernel32.dll', "int", "GetProcessTimes", "handle", $hProc, "struct*", $tCreation, "struct*", $tExit, "struct*", $tKernel, "struct*", $tUser) $aTimes[2] = DllStructGetData($tUser, 1) + DllStructGetData($tKernel, 1) Return $aTimes EndFunc ;==>_GetProcessUsage Func _CalcUsage($aCpuStart, $aCpuEnd, $nPercent = True) ;Calculate time difference for idle, system, process Local $iIdle = ($aCpuEnd[0] - $aCpuStart[0]), $iSystem = ($aCpuEnd[1] - $aCpuStart[1]), $iProcess = ($aCpuEnd[2] - $aCpuStart[2]) ;Calculate Total and Process CPU values Local $aCPUTimes[2] $aCPUTimes[0] = ($iSystem - $iIdle) / $iSystem ; Total CPU Usage $aCPUTimes[1] = $iProcess / $iSystem ; Process CPU Usage ;Convert to percent If $nPercent Then $aCPUTimes[0] = Round($aCPUTimes[0] * 100) $aCPUTimes[1] = Round($aCPUTimes[1] * 100) EndIf Return $aCPUTimes EndFunc ;==>_CalcUsage Func _ProcessExists($hProc) Local $aRet = DllCall('kernel32.dll', 'bool', 'GetExitCodeProcess', 'handle', $hProc, 'dword*', 0) If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0) Return ($aRet[2] = 259) EndFunc ;==>_ProcessExists Func _TestLoad() Local $iA For $i = 1 To 500000 $iA = $iA / 3 Next EndFunc ;==>_TestLoad Func _Exit() _WinAPI_CloseHandle($g_hAutoItProcess) Exit EndFunc ;==>_Exit Edit: Changes to OpenProcess. Access rights should be set according to OS version used. Also debug privilages not needed in this case.
    1 point
×
×
  • Create New...