Leaderboard
Popular Content
Showing content with the highest reputation on 02/15/2014 in all areas
-
vPaint - GDI+ image editor
BBs19 reacted to scintilla4evr for a topic
Hello everyone! As always, I'm proud to present you vPaint. It's an image editor. It uses GDI+ as its drawing library. I want to thank to all members of this forum. Without you, this app wouldn't be ever written. Thank you for everything. Download: vPaint 4 image editor1 point -
Power Calculator
mLipok reacted to scintilla4evr for a topic
Hello. I want to introduce you a SIMPLE calculator made in AutoIt. Features: 3 modes: Basic, Scientific, Statistic Win7 calculator look Name from Big Bang Theory (episode 4x12) - The Suprisingly Helpful Equation-Linked Differential Optimized Numerator (The SHELDON) Here are some screenshots: Basic mode Scientific mode Statistic mode Enjoy! Now you can download it from my website: http://scintilla4evr.aq.pl/powercalculator (source will be added later) Power Calculator.zip (see changes below) Power Calculator.zip There are some errors in first code, so I give you corrected one. Error: When you write formula like this: 98 / pi ( ) it returns !error. Now it'll return 31.1943688460115. Also added "Put in clipboard" button. TODO: Skins1 point -
RESTRICT EDIT UDF Restrict the text that can be entered in an editbox through a String Regular Expression. The UDF works be subclassing the control. >Here is a similar UDF based on Windows Message. Functions The UDF is pretty simple and could be modified with ease. User can set their SRE pattern to block the text entered in the editbox Tooltips can be used in case of an error. The title of the Tooltip is Error_2 where the number(2) signifies the pattern that caused the error. The script is made to use function pointer variables rather than direct patterns, to make it more flexible and broader. Supports +ve and -ve SRE pattern matches. See example for better understanding. Note : The Pattern should be made such that every phase of typing is met, Example, if the user wants The second letter should be always a digit. Then he should make sure that the pattern is also satisfied when user enters the first character, as through the process of typing. Index ; #INDEX# ======================================================================================================================= ; Title .........: RestrictEdit ; Version........: 1.0 ; AutoIt Version : 3.3.8.0++ ; Language ......: English ; Author(s)......: Phoenix XL ; Librarie(s)....: WinAPI, Array and GUIEdit ; Description ...: Functions for restricting the text typed in an Edit control through SRE. ; The edit control is subclassed and the original processing is blocked when pattern isn't satisfied. ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;_Restrict_Edit ; =============================================================================================================================== ; #INTERNAL_USE_ONLY# =========================================================================================================== ; HideToolTip_Edit ;_NewWnd_Proc_ ;_SubClass_ ; =============================================================================================================================== ChangeLog v1.0 - First Release v2.0 - Replaced the SRE pattern parameter(2nd parameter) with function pointer parameter[A script Breaking change]. Added support for positive and negative pattern matches Download v2.0 RestrictEdit(UDF).7z Previous downloads : 1611 point
-
Slym, Fine. Although as I believe the native function uses the Windows API, your request for a "low-level function" will only result in the same dialog appearing. I thought you might like to try the UDF and see if it was in fact the API that was causing your problems as the UDF does not use it. M231 point
-
Please read the remarks in the help file for _IEFormSubmit. Not all websites can be automated using this function.1 point
-
A lot of these days can be calculated via Easter it seems. Mothers Day (Mothering Sunday - UK) #include <Date.au3> $YAY = _MothersDay() MsgBox(0, "Mothers Day", $YAY) ;year/month/day Func _MothersDay() For $iYe = @YEAR To @YEAR + 1 For $iMon = 3 To 4 For $iDa = 1 To 31 If _IsEasterSunday($iDa, $iMon, $iYe) Then $mothersDay = _DateAdd('w', -3, $iYe & "/" & $iMon & "/" & $iDa) Return $mothersDay EndIf Next Next Next EndFunc ;==>_MothersDay Func _IsEasterSunday($iday, $imonth, $iyear) ;http://www.autoitscript.com/forum/topic/120126-iseastersunday/#entry834668 If $iyear < 1 Or $iyear > 9999 Then Return False Exit EndIf $a = Mod($iyear, 19) $b = Mod($iyear, 4) $c = Mod($iyear, 7) $d = Mod(19 * $a + 24, 30) $e = Mod(2 * $b + 4 * $c + 6 * $d + 5, 7) $sunday = 22 + $d + $e $month = 3 If $sunday > 31 Then $month = 4 $sunday -= 31 EndIf If $iday = $sunday And $imonth = $month Then Return True Else Return False EndIf EndFunc ;==>_IsEasterSunday1 point
-
You need to grab the Form element (example: "home-page-demo") not the Div.1 point
-
As you can see _IEFormGetObjByName can't find the object "slider". Which site do you try to automate?1 point
-
Can you post the content of the SciTE output pane after you have run your script by pressing F5?1 point
-
3aberxcs (and/or EMadxcs), You appear to have 2 accounts, which is not permitted here. if this is the case, let me know which of them you would like to keep and I will merge them. If not, then please explain why it appears that way. M231 point
-
You will have to use conditionals, Example #include <GUIConstants.au3> #include <RestrictEdit.au3> #Cs [0]|m121/12, [1]|1231/12, [2]|p1/12, [3]|2/13, [4]|s1/14, [5]|o121/10 #ce Func _Main() #cs Pattern in text that should follow the first character can be any of 'm' 'p' 's' 'o' 'n' or a no. of digits followed by a "/" and then followed by two digits. Then if comma again the above pattern is expected otherwise, if EOL the pattern is satisfied. #ce Local Const $sPattern = "^([mpson]?(?(?=\d+)\d*\d(?(?=/)/(?(?=\d)\d{0,2}(,|$)|$)|$)|$))*$" ;our main GUI GUICreate("Restrict Edit | Phoenix XL", 200, 70) GUICtrlCreateLabel("Pattern : " & $sPattern, 10, 10, 200, 30) GUICtrlCreateInput("", 10, 30, 180, 20) ;subclass the control and set the SRE restriction. _Restrict_Edit(GUICtrlGetHandle(-1), $sPattern, "InCorrect Syntax.") If @error Then MsgBox(16, "Error Code: " & @error, "Extended: " & @extended) GUISetState() Do Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE ;unsubclass the control _Restrict_Edit(GUICtrlGetHandle(-1)) EndFunc ;==>_Main _Main() I'm not decoding the regex. I'm going to release the next version soon that comes with the support of multiple SRE's. Therefore such long patterns won't be required. Regards1 point
-
You already use the IE UDF. Why not use the functions of the UDF to do what you want?1 point
-
Large Ranges in Excel
thatguypursue reacted to water for a topic
Set $oExcel.ScreenUpdating = False before setting the ranges and set it to True again when finished. That should speed up your solution.1 point -
Afaik you cannot use optional parameters in DLLs. This is because the C++ compiler handles the optional parameters at compile time. So if you compile a DLL there is no optional parameter possible. But you just can use AutoIt for using optional parameters in your UDF.1 point
-
Romanz, This thread may be of some use to you. The following is an example of dumping the current 50 type 1 or 41 records from the "System" log. This was run on a Vista OS (don't have an XP or 7 box available right now). See the help file for more details... #include <EventLog.au3> #include <array.au3> OnAutoItExitRegister('_fini') Local $hEventLog, $aEvent, $cnt = 0 $hEventLog = _EventLog__Open("", "System") If $hEventLog = 0 Then ConsoleWrite('Log failed to open' & @LF) Exit EndIf While 1 If $cnt > 50 Then ExitLoop $aEvent = _EventLog__Read($hEventLog, True, False) If $aEvent[0] = False Then Exit If $aEvent[6] = 41 Or $aEvent[6] = 1 Then ConsoleWrite(_ArrayToString($aEvent) & @LF) $cnt += 1 EndIf WEnd Func _fini() _EventLog__Close($hEventLog) EndFunc ;==>_fini kylomas1 point
-
1 point
-
If you substitute this code with your WM_MENUSELECT function, you might be able to work with it. Func WM_MENUSELECT($hWnd, $iMsg, $iwParam, $ilParam) Local $index = _LoWord($iwParam) Local $flags = _HiWord($iwParam) _DebugPrint("index or identifier: " & $index) If BitAND($flags, $MF_BITMAP) Then _DebugPrint("$MF_BITMAP") If BitAND($flags, $MF_CHECKED) Then _DebugPrint("$MF_CHECKED") If BitAND($flags, $MF_DISABLED) Then _DebugPrint("$MF_DISABLED") If BitAND($flags, $MF_GRAYED) Then _DebugPrint("$MF_GRAYED") If BitAND($flags, $MF_HILITE) Then _DebugPrint("$MF_HILITE") If BitAND($flags, $MF_MOUSESELECT) Then _DebugPrint("$MF_MOUSESELECT") If BitAND($flags, $MF_OWNERDRAW) Then _DebugPrint("$MF_OWNERDRAW") If BitAND($flags, $MF_POPUP) Then _DebugPrint("$MF_POPUP") If BitAND($flags, $MF_SYSMENU) Then _DebugPrint("$MF_SYSMENU") If $ilParam Then _DebugPrint("Handle: " & $ilParam) Return $GUI_RUNDEFMSG EndFunc ; Helper functions. Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord Func _DebugPrint($s_text) $s_text = StringReplace(StringReplace($s_text, @CRLF, @LF), @LF, @LF & "!-->") ConsoleWrite( _ "+===========================================================" & @LF & _ "!-->" & $s_text & @LF & _ "+===========================================================" & @LF & @LF) EndFunc ;==>_DebugPrint1 point
-
Need help detecting click on submenu header, not menu item
this-is-me reacted to Danyfirex for a topic
Hi. Change your WM_MENUSELECT for this: Edit. is not all that you want.but this part can help to know if is popup menu. Func WM_MENUSELECT($hWnd, $iMsg, $iwParam, $ilParam) Local $Flags = BitShift($iwParam, 16) If BitAND($Flags, $MF_POPUP) Then Consolewrite("I have An Arrow :)" & @crlf) EndIf Return $GUI_RUNDEFMSG EndFunc Saludos1 point -
The alternative to using Global variables is opting for an API-like system. Example() Func Example() Local $hSomeFunc = SomeFunc_Start(@ScriptFullPath) SomeFunc_DoSomething($hSomeFunc) SomeFunc_Shutdown($hSomeFunc) Sleep(500) Local $hSomeFuncElse = SomeFunc_Start(@AutoItExe) SomeFunc_DoSomething($hSomeFuncElse) SomeFunc_Shutdown($hSomeFuncElse) EndFunc ;==>Example Func SomeFunc_DoSomething(ByRef $aAPI) Local Enum $eAPI_FilePath, $eAPI_StartTime, $eAPI_Max #forceref $eAPI_Max ConsoleWrite('File: ' & $aAPI[$eAPI_FilePath] & ', was started at ' & $aAPI[$eAPI_StartTime] & @CRLF) EndFunc ;==>SomeFunc_DoSomething Func SomeFunc_Start($sFilePath) Local Enum $eAPI_FilePath, $eAPI_StartTime, $eAPI_Max Local $aAPI[$eAPI_Max] $aAPI[$eAPI_FilePath] = $sFilePath $aAPI[$eAPI_StartTime] = @HOUR & @MIN & @MSEC Return $aAPI EndFunc ;==>SomeFunc_Start Func SomeFunc_Shutdown(ByRef $aAPI) Local Enum $eAPI_FilePath, $eAPI_StartTime, $eAPI_Max #forceref $eAPI_FilePath, $eAPI_StartTime For $i = 0 To $eAPI_Max - 1 $aAPI[$i] = 0 Next Return True EndFunc ;==>SomeFunc_Shutdown I have purposely not included any comments as this isn't for the novice user, I'm also trying to inspire you to read more into what I am doing.1 point
-
_WinAPI_SetConsoleTextAttribute()
TheAutomator reacted to Kealper for a topic
I noticed that WinAPI.au3 does not come with a UDF for the WinAPI function SetConsoleTextAttribute, which allows a user to change the text color/background for specific pieces of text, which can be quite useful when trying to get a user's attention to an error (e.g. make the line stating the error bright red), or to say something good has happened (e.g. make the line saying the good news bright green). I have set the UDF up so it could (hopefully) be included into WinAPI.au3 to give us all a more complete WinAPI experience. Example script demonstrating this function below. (Lots of comments for such simple code!) IT MUST BE COMPILED AS A CONSOLE APPLICATION (CUI) TO WORK! #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** If Not @Compiled Then Exit MsgBox(4096, "_WinAPI_SetConsoleTextAttribute", "Please compile this as a console application to see what this function does.") ;Exit if script is not compiled #include <WinAPI.au3> $dll = DllOpen("Kernel32.dll") ;Open Kernel32.dll because we will be using it a lot $hnd = _WinAPI_GetStdHandle(1) ;Get the AutoIt process's standard output handle For $i = 0 To 255 ;Loop through all possible color combinations If $i = 0 Then _WinAPI_SetConsoleTextAttribute($hnd, 240, $dll) ;The color used for 0 is black text with black background, set background to white so first line does not look like blank space ConsoleWrite("0 - Colors" & @CRLF) ;Write first line with white background ContinueLoop ;Skip last two lines in first loop EndIf _WinAPI_SetConsoleTextAttribute($hnd, $i, $dll) ;Change text color to $i ConsoleWrite($i & " - Colors" & @CRLF) ;Write $i so you can see all 256 colors Next While 1 ;Hold script in a loop until closed Sleep(500) WEnd ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_SetConsoleTextAttribute ; Description ...: Changes the text and/or background color of text in the Windows console. ; Syntax.........: _WinAPI_SetConsoleTextAttribute($hConsole, $iColor, $hDLL = "Kernel32.dll") ; Parameters ....: $hConsole - Handle to the console screen buffer ; $iColor - Color style to apply to the console. ; $hDLL - Handle to the DLL to call. (Leave blank to open Kernel32.dll each call) ; Return values .: Success - True ; Failure - False ; Author ........: Ken Piper (Kealper) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: @@MsdnLink@@ SetConsoleTextAttribute ; Example .......: ; =============================================================================================================================== Func _WinAPI_SetConsoleTextAttribute($hConsole, $iColor, $hDLL = "Kernel32.dll") $ret = DllCall($hDLL, "BOOL", "SetConsoleTextAttribute", "HANDLE", $hConsole, "WORD", $iColor) If @error Then Return SetError(@error, @extended, False) Return $ret[0] EndFunc And here is just the function. ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_SetConsoleTextAttribute ; Description ...: Changes the text and/or background color of text in the Windows console. ; Syntax.........: _WinAPI_SetConsoleTextAttribute($hConsole, $iColor, $hDLL = "Kernel32.dll") ; Parameters ....: $hConsole - Handle to the console screen buffer ; $iColor - Color style to apply to the console. ; $hDLL - Handle to the DLL to call. (Leave blank to open Kernel32.dll each call) ; Return values .: Success - True ; Failure - False ; Author ........: Ken Piper (Kealper) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: @@MsdnLink@@ SetConsoleTextAttribute ; Example .......: ; =============================================================================================================================== Func _WinAPI_SetConsoleTextAttribute($hConsole, $iColor, $hDLL = "Kernel32.dll") $ret = DllCall($hDLL, "BOOL", "SetConsoleTextAttribute", "HANDLE", $hConsole, "WORD", $iColor) If @error Then Return SetError(@error, @extended, False) Return $ret[0] EndFunc I hope this could be of use to other people, as the only other reference to coloring console text was a broken link on another post.1 point -
Variables should always be declared in the smallest scope possible in any language (for languages that support it). For example, don't front-load your functions with all the variable declarations. Declare variables right before they are used. If a variable doesn't need to exist in global scope then use it in local scope. Prefer function return values and function parameters to pass data around rather than global variables. Keep variables in existence no more than necessary.1 point