Leaderboard
Popular Content
Showing content with the highest reputation on 07/28/2013 in Posts
-
AutoIt v3.3.9.12 Beta
jaberwacky and one other reacted to Jon for a topic
No investigation needed, it's pretty much by design in place of a "hack" we used in the previous version. Here is what is going on. The quick answer is that you need to use ShellExecute() instead. There are two ways to launch a program in Windows: CreateProcess (which we wrap up using Run()) and ShellExecute(which we wrap up using ShellExecute()). Executables (general executables, nothing to do with AutoIt) have a manifest section added to a resource which says the level they should run at. Typically this is asInvoker (runs as a user) or requireAdministrator (wants to run as admin). The weird part is when we are running as user (by default with UAC) and we CreateProcess a file that is tagged with requireAdministrator the OS actually fails and returns a "can't run, this needs elevation" error code. CreateProcess (Run()) cannot execute a process in such a way that it moves from a user to administrator level. Try it on other "admin" executables and they will all fail in the same way. ShellExecute() on the other hand is the way that most things are launched in windows. Double click a file, double click a file extension. Type in a file extension in cmd.exe, etc. This does have elevation code in it and it is the place where you get the UAC prompt. Going through this ShellExecute+UAC code is the only way to elevate. Run/ShellExecute have different features, especially around capturing process IDs, and ShellExecute was a later addition to AutoIt so we've all gotten in the habit of using Run all the time. The default function to use would be ShellExecute really. So how come this used to work in 3.3.8.1? Well in the beta #requireadmin causes the compiled exe to have a proper manifest resource. This means it acts completely like a normal exe - this is a much better solution. But in 3.3.8.1 we didn't have the facility to properly write the manifest file so we tagged all files as "asInvoker". Then when the compiled exe ran the first thing that happened is that we detected that the script contained #requireAdmin and then silently reran itself using ShellExecute. So it looked that you ran the script once, but it actually ran twice. You see this sort of thing in a number of Windows programs like Disk CleanUp. By default it is manifested "asInvoker" and runs as a user, but then you can click a button to "clean up system files" and it vanishes for a second before working - this is because it's doing a similar rerun trick. You might ask why can't I leave the new proper manifest behaviour in and put the rerun hack back in. Well, think about it for a second and you'll see why. (Edit: actually there is a sort of workaround by decoupling #requireadmin and #pragma compile but I'm not sure it would be too confusing)2 points -
This is not supported by Jos (who is the author of AutoIt3Wrapper) so please keep both his thread and my thread on topic. Thanks. This script will convert AutoIt3Wrapper directives into valid pragma directives. There is also an option to overwrite the script with the new directives so you don't have to. What could be easier! If you need more help on how to use, then please don't hesitate to ask. AutoIt3WrapperToPragma.zip Note: This doesn't replace all directives. AutoIt3Wrapper is still a valuable tool and offers additional directives that pragma doesn't support at present. This is the old version. I have left it here so you can do a source code comparison of how much of the code I actually changed. [OLD STYLE] AutoIt3WrapperToPragma.zip1 point
-
AutoIt3WrapperToPragma - Convert wrapper directives to pragma.
jaberwacky reacted to guinness for a topic
FireFox, I am not getting that in my tests. Look at line 130 and you will see how I check for VERSION resource changes. jaberwocky6669,1 point -
Reading through this thread I guess you are not. This thread is closed and opening another one on the same topic will urn you some naughty spot time. *Click*1 point
-
1 point
-
jiks, As I have explained, we do not provide working code as a freebie - and certainly not for anything as complicated as you say you "need". We expect you to make an effort and start to learn how to code in AutoIt, then we will help you as much as we can. So it is up to you to make an effort now. M231 point
-
jiks, I see lots of "I need" in your posts. We do not write code to order - we help you get your code working correctly. Think of the old saying: "Give a man a fish, you feed him for a day; give a man a net and you feed him forever". We try to be net makers and repairers, not fishmongers. So I suggest that you start by reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) - this will help you enormously. You should also look at this excellent tutorial - you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading. Once you have a good idea of how Autoit works then you can try and produce some code yourself - we will then be delighted to help you getting over any difficulties you encounter. So please - no more "I need" posts from you - clear? M231 point
-
When using Not, wrap the expression in parenthesese e.g. Not (This == Something). There was a topic about this last week.1 point
-
hi jiks have a look to this link (_TalkOBJ), it may be a first step for the "talking" part http://www.autoitscript.com/wiki/Snippets_%28_AutoIt_Audio_%29#TalkOBJ1 point
-
Do you mean something like this here? ;coded by UEZ 2013 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPI.au3> _GDIPlus_Startup() $hGUI = GUICreate("Pac-Man Progressbar Beta by UEZ 2013", 640, 200) GUISetBkColor(0x101040) $iPB = GUICtrlCreatePic("", 160, 83, 420, 35, $SS_SUNKEN) $iBtnStart = GUICtrlCreateButton("Start", 40, 80, 40, 40) $iLabelPerc = GUICtrlCreateLabel("0.00%", 95, 90, 50, 40) GUICtrlSetFont(-1, 10) GUICtrlSetColor(-1, 0xF0F0F0) _GDIPlus_PacmanProgressbar(0, $iPB) GUISetState() Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() _GDIPlus_Shutdown() Exit Case $iBtnStart $iMax = 133 For $i = 0 To $iMax $fProg = $i / $iMax * 100 _GDIPlus_PacmanProgressbar($fProg, $iPB) GUICtrlSetData($iLabelPerc, StringFormat("%.2f%", $fProg)) Sleep(30) Next MsgBox(0, "Test", "Done", 30, $hGUI) _GDIPlus_PacmanProgressbar(0, $iPB) GUICtrlSetData($iLabelPerc, StringFormat("%.2f%", 0)) EndSwitch Until False ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_PacmanProgressbar ; Description ...: An alternativ progressbar ; Syntax ........: _GDIPlus_PacmanProgressbar($iProgress, $iCtrl[, $iScalar = 15[, $iPacManSize = 0[, $iDotSize = 0[, ; $iPacManColor = 0xFFFFFF00[, $iDotColor = 0xFFFFFFFF[, $iFinishColor = 0xFF00FF00[, $iBGColor = 0xFF404040[, ; $iPacManSpeed = 125]]]]]]]]) ; Parameters ....: $iProgress - An integer value between 0 and 100. ; $iCtrl - An integer value (control id). ; $iPacManColor - [optional] An integer value. Default is 0xFFFFFF00. ; $iScalar - [optional] An integer value. Default is 15. ; $iPacManSize - [optional] An integer value. Default is 0 = automatically calculated. ; $iDotSize - [optional] An integer value. Default is 0 = automatically calculated. ; $iDotColor - [optional] An integer value. Default is 0xFFFFFFFF. ; $iFinishColor - [optional] An integer value. Default is 0xFF00FF00. ; $iBGColor - [optional] An integer value. Default is 0xFF404040. ; $iPacManSpeed - [optional] An integer value. Default is 125 (the higher the value the slower the pac-man). ; Return values .: None ; Author ........: UEZ ; Version .......: 0.90 build 2013-07-28 beta ; Modified ......: ; Remarks .......: need GDIPlus.au3 ; Related .......: GDI+, GUI ; =============================================================================================================================== Func _GDIPlus_PacmanProgressbar($iProgress, $iCtrl, $iPacManColor = 0xFFFFFF00, $iScalar = 15, $iPacManSize = 0, $iDotSize = 0, $iDotColor = 0xFFFFFFFF, $iFinishColor = 0xFF00FF00, $iBGColor = 0xFF404040, $iPacManSpeed = 125) ; coded by UEZ build 2013-07-28 beta Local $hGUI, $hCtrl, $aResult, $hBitmap, $hGfxCtxt, $aCtrlSize, $hB, $hGDIBmp, $hBrush, $i, $fSpace, $iX, $fDX, $iC = 0, $iProgressMax = 100 Local Static $iFrame = 0, $iTimer = TimerInit() $hCtrl = GUICtrlGetHandle($iCtrl) $hGUI = _WinAPI_GetAncestor($hCtrl) If @error Then Return SetError(1, 0, -1) $aCtrlSize = ControlGetPos($hGUI, "", $iCtrl) If @error Then Return SetError(2, 0, -2) ;$GWL_STYLE = 0xFFFFFFF0, $GWL_EXSTYLE = 0xFFFFFFEC If BitAND(_WinAPI_GetWindowLong($hCtrl, 0xFFFFFFF0), 0x1000) = 0x1000 Or _ ;$SS_SUNKEN BitAND(_WinAPI_GetWindowLong($hCtrl, 0xFFFFFFEC), 0x00020000) = 0x00020000 Then $iC += 2 ;$WS_EX_STATICEDGE If BitAND(_WinAPI_GetWindowLong($hCtrl, 0xFFFFFFEC), 0x00000200) = 0x00000200 Then $iC += 4 ;$WS_EX_CLIENTEDGE If BitAND(_WinAPI_GetWindowLong($hCtrl, 0xFFFFFFF0), 0x00800000) = 0x00800000 Then $iC += 2 ;$WS_BORDER $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $aCtrlSize[2] - $iC, "int", $aCtrlSize[3] - $iC, "int", 0, "int", $GDIP_PXF32ARGB, "ptr", 0, "int*", 0) $hBitmap = $aResult[6] $hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsClear($hGfxCtxt, $iBGColor) _GDIPlus_GraphicsSetSmoothingMode($hGfxCtxt, 2) $hBrush = _GDIPlus_BrushCreateSolid($iDotColor) If Not $iDotSize Then $iDotSize = ($aCtrlSize[3] - $iC) / 4 If Not $iPacManSize Then $iPacManSize = $iDotSize * 2 $fSpace = $aCtrlSize[2] / $iScalar $fDX = -3 + (($aCtrlSize[2] - $iC) - ($fSpace * $iScalar - $fSpace + $iDotSize)) / 2 If $iProgress < $iProgressMax Then For $i = Int($iProgress / 100 * $iScalar) To $iScalar - 2 $iX = $fDX + $fSpace * $i DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hGfxCtxt, "handle", $hBrush, "float", $iX, "float", (($aCtrlSize[3] - $iC) - $iDotSize) / 2, "float", $iDotSize, "float", $iDotSize) Next _GDIPlus_BrushSetSolidColor($hBrush, $iFinishColor) $iX = $fDX + $fSpace * $i - $iDotSize / 2 DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hGfxCtxt, "handle", $hBrush, "float", $iX, "float", (($aCtrlSize[3] - $iC) - $iDotSize) / 2.5, "float", $iDotSize * 1.5, "float", $iDotSize * 1.5) _GDIPlus_BrushSetSolidColor($hBrush, $iPacManColor) $iX = -$fSpace + $fDX + ($iProgress / $iScalar / 100) * $iScalar * ($aCtrlSize[2] - $iC) Switch Mod($iFrame, 2) Case 0 DllCall($ghGDIPDll, "int", "GdipFillPie", "handle", $hGfxCtxt, "handle", $hBrush, "float", $iX, "float", (($aCtrlSize[3] - $iC) - $iPacManSize) / 2, "float", $iPacManSize, "float", $iPacManSize, "float", 45, "float", 270) Case Else DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hGfxCtxt, "handle", $hBrush, "float", $iX, "float", (($aCtrlSize[3] - $iC) - $iPacManSize) / 2, "float", $iPacManSize, "float", $iPacManSize) EndSwitch _GDIPlus_BrushSetSolidColor($hBrush, 0xFF000000) DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hGfxCtxt, "handle", $hBrush, "float", $iX + $iDotSize, "float", $iDotSize / 5 + (($aCtrlSize[3] - $iC) - $iDotSize * 2) / 2, "float", $iDotSize / 4, "float", $iDotSize / 4) If TimerDiff($iTimer) > $iPacManSpeed Then $iFrame += 1 $iTimer = TimerInit() EndIf EndIf $hGDIBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) $hB = GUICtrlSendMsg($iCtrl, 0x0172, 0, $hGDIBmp) ;$STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0 If $hB Then _WinAPI_DeleteObject($hB) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfxCtxt) _GDIPlus_BitmapDispose($hBitmap) _WinAPI_DeleteObject($hGDIBmp) EndFunc ;==>_GDIPlus_PacmanProgressbar It is beta! Br, UEZ1 point
-
USBMon
TheSeeker reacted to delphifocus for a topic
rasim: Link was broken, please uploaded again. Thanks1 point -
The following code is an adaptation of the IE.au3 UDF. By including this, you will be able to access Iframes and their content based on their ID's instead of their Names. As always, Critisism is welcome! Regards. Orrin Gradwell #include-once #include "WinAPIError.au3" ; #FUNCTION# ==================================================================================================================== ; Name...........: _IEFrameGetObjById ; Description ...: Returns an object reference to a Frame by ID ; Parameters ....: $o_object - Object variable of an InternetExplorer.Application, Window or Frame object ; $s_id - ID of the Frame you wish to match ; Return values .: On Success - Returns an object variable pointing to the Window object in a Frame, @EXTENDED = Frame count ; On Failure - Returns 0 and sets @ERROR ; @ERROR - 0 ($_IEStatus_Success) = No Error ; - 3 ($_IEStatus_InvalidDataType) = Invalid Data Type ; - 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type ; - 7 ($_IEStatus_NoMatch) = No Match ; @Extended - Contains invalid parameter number ; Origional Author ........: Dale Hohm ; Adapted By ..............: Orrin Gradwell ; =============================================================================================================================== Func _IEFrameGetObjById(ByRef $o_object, $s_id) If Not IsObj($o_object) Then __IEErrorNotify("Error", "_IEFrameGetObjById", "$_IEStatus_InvalidDataType") Return SetError($_IEStatus_InvalidDataType, 1, 0) EndIf ; Local $oTemp, $oFrames If Not __IEIsObjType($o_object, "browserdom") Then __IEErrorNotify("Error", "_IEFrameGetObjById", "$_IEStatus_InvalidObjectType") Return SetError($_IEStatus_InvalidObjectType, 1, 0) EndIf If __IEIsObjType($o_object, "document") Then $oTemp = $o_object.parentWindow Else $oTemp = $o_object.document.parentWindow EndIf If _IEIsFrameSet($oTemp) Then $oFrames = _IETagNameGetCollection($oTemp, "frame") Else $oFrames = _IETagNameGetCollection($oTemp, "iframe") EndIf If $oFrames.length Then For $oFrame In $oFrames If $oFrame.id = $s_id Then Return SetError($_IEStatus_Success, 0, $oTemp.frames($s_id)) Next __IEErrorNotify("Warning", "_IEFrameGetObjById", "$_IEStatus_NoMatch", "No frames matching Id") Return SetError($_IEStatus_NoMatch, 2, 0) Else __IEErrorNotify("Warning", "_IEFrameGetObjById", "$_IEStatus_NoMatch", "No Frames found") Return SetError($_IEStatus_NoMatch, 2, 0) EndIf EndFunc ;==>_IEFrameGetObjById1 point