Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/14/2013 in all areas

  1. Are you annoyed by the limitations of the standard Windows message dialog created by MsgBox? Would you like to have coloured backgrounds and text? To choose the justification and font? Do you want to be able to place the message box other than in the centre of the screen? Centred on your GUI, for example, or at a particular location on screen? What about having user-defined text on as many buttons as you need? And user-defined icons? Or a visible countdown of the timeout? Finally, would you like to choose whether the message box has a button on your already too-crowded taskbar? If the answer to any of these questions is "YES" then the ExtMsgBox UDF is for you! [NEW VERSION] 16 Feb 24 Changed: Some additional functionality added to the "TimeOut" parameter of _ExtMsgBox: - A positive integer sets the EMB timeout as before. - A negative integer will double the size of the countdown timer if it is used. - A colon-delimited string (eg: "10:5") will set the normal EMB timeout (first integer) and will also initially disable the EMB buttons for the required period (second integer). New UDF and examples in the zip. Older version changes: ChangeLog.txt As always, I realise nearly all of the DLL calls in these UDFs could be made by using commands in other UDFs like WinAPI.au3 - but as with all my UDFs (which you can find in my sig below) I am trying to prevent the need for any other include files. The UDF and examples (plus StringSize) in zip format: ExtMsgBox.zip Courteous comments and constructive criticisms welcome - guess which I prefer! M23
    1 point
  2. I've noticed a strange phenomenon, namely the script loops indefinitely when I use "Array" word in the string. Try this: #include <Array.au3> Global $aStrings = StringSplit("Apple,Orange,Array,Milk", ",") _ArrayDisplay($aStrings) For $array = 1 To $aStrings[0] MsgBox(32, "", $aStrings[$array]) Assign($aStrings[$array], $aStrings[$array], 2) Next It never ends, right? Now try another one. Just change "Array" to "Cola" for example. It should works fine. I'm not sure, is it a bug?
    1 point
  3. You get the second popup because you have a ConsoleWrite after the While loop. I added 2 parameters to the _getDOSOutput function for the computer name and the user name, I also set their default values to the current computer and current user on the computer. If I were you I would remove the MsgBox in the function and have the function return the text instead, this way you can do what you want with it afterwards, and there's no annoying pop up in the function itself. Here's an updated script with some basic error checking, and it pings the computer to see if it's alive. ;~ #include <ButtonConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> ;~ #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $ComputerName, $SIDUserName, $Check, $ComputerName_read, $SIDUserName_read #region ### START Koda GUI section ### Form=c:\users\pankajmi\desktop\is\autoit - pankaj\koda files\sidchecker.kxf $Form1_1 = GUICreate("SID Checker V1.0 Agneepath", 613, 145, 192, 124) GUICtrlCreateLabel("Computer Name", 16, 8, 80, 17) $ComputerName = GUICtrlCreateInput("", 16, 32, 233, 21) GUICtrlCreateLabel("SID/User Name", 16, 64, 80, 17) $SIDUserName = GUICtrlCreateInput("", 16, 88, 569, 21) $Check = GUICtrlCreateButton("Check", 268, 112, 97, 25) GUICtrlSetState(-1, $GUI_FOCUS) $InputCommandResult = GUICtrlCreateEdit("", 8, 344, 649, 140, $ES_AUTOVSCROLL + $WS_VSCROLL) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Select Case $msg = $Check $ComputerName_read = GUICtrlRead($ComputerName) $SIDUserName_read = GUICtrlRead($SIDUserName) MsgBox($MB_SYSTEMMODAL, "SID for User Name: " & $SIDUserName_read, _getDOSOutput("psgetsid.exe", $ComputerName_read, $SIDUserName_read)) Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func _getDOSOutput($command, $computer = @ComputerName, $user = @UserName) Local $text = '' If Ping($computer) Then Local $Pid = Run($command & " \\" & $computer & " " & $user, "", @SW_HIDE, 2 + 4) If Not @error Then While 1 $text &= StdoutRead($Pid) If @error Then ExitLoop Sleep(10) WEnd Else $text = "An error occurred running PSGetSID.exe, the error returned was: " & @error EndIf Else $text = "Computer not reachable, error returned was: " & @error EndIf Return $text EndFunc ;==>_getDOSOutput
    1 point
  4. Try this, this assumes that psgetsid is in the same folder as your script, if it's not you need the full path to the exe to get it to run. #include <ButtonConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $ComputerName, $SIDUserName, $Check, $ComputerName_read, $SIDUserName_read #region ### START Koda GUI section ### Form=c:\users\pankajmi\desktop\is\autoit - pankaj\koda files\sidchecker.kxf $Form1_1 = GUICreate("SID Checker V1.0 Agneepath", 613, 145, 192, 124) GUICtrlCreateLabel("Computer Name", 16, 8, 80, 17) $ComputerName = GUICtrlCreateInput("", 16, 32, 233, 21) GUICtrlCreateLabel("SID/User Name", 16, 64, 80, 17) $SIDUserName = GUICtrlCreateInput("", 16, 88, 569, 21) $Check = GUICtrlCreateButton("Check", 268, 112, 97, 25) GUICtrlSetOnEvent(-1, "_getDOSOutput") GUICtrlSetState(-1, $GUI_FOCUS) $InputCommandResult = GUICtrlCreateEdit("", 8, 344, 649, 140, $ES_AUTOVSCROLL + $WS_VSCROLL) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Select Case $msg = $Check $ComputerName_read = GUICtrlRead($ComputerName) $SIDUserName_read = GUICtrlRead($SIDUserName) _getDOSOutput("psgetsid.exe", $ComputerName_read, $SIDUserName_read) Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd ConsoleWrite(_getDOSOutput("psgetsid.exe") & @CRLF) Func _getDOSOutput($command, $computer = @ComputerName, $user = @UserName) Local $text = '', $Pid = Run('"' & @ComSpec & '" /c ' & $command & " \\" & $computer & " " & $user, '', @SW_HIDE, 2 + 4) While 1 $text &= StdoutRead($Pid) If @error Then ExitLoop Sleep(10) WEnd MsgBox(0, "SID for User Name", $text) Return StringStripWS($text, 7) EndFunc ;==>_getDOSOutput
    1 point
  5. JLogan3o13

    Reading remote registry

    I would suggest you begin by opening the registry, browsing to the remote machine and the key that you're looking to target, and then looking at the permissions set on that key. There are a couple different ways to set permissions on remote registry. If you do a google search there should be a couple of MS articles near the top.
    1 point
  6. AHRIMANSEFID, this is not a forum where you make a request and we barf up code for you. This forum is dedicated to assisting users overcome hurdles with their own scripts, after they have tried something on their own by reading through the help file. We are more than willing to help, but you need to show at least some level of effort. If you are looking for a site to pay for someone to code for you, may I suggest www.freelancer.com. Otherwise, please explain in detail what you're trying to accomplish, and what you have tried already on your own. Then post your code, even if it isn't working they way you would like it to.
    1 point
  7. Hi, Take a look at the Example 2 of the TCPSend/Recv function in the helpfile of the latest autoit beta Br, FireFox.
    1 point
  8. lolipop, SREs are complicated beasts and need a lot more than the limited page the AutoIt Help file can offer. I often say that they are the hardest thing in computing terms I have ever tried to learn - and I stand in awe of the real gurus around here. I recommend this site as a good place to start learning about them - one of the gurus always suggests here. Your choice. Good luck - and do not blame us when your brain begins to bleed! M23
    1 point
  9. lolipop, ^ - Start at the beginning of the string and ... (.*<value>) - ...capture a group up to and including <value> - this is stored as $1 (.*) - Capture a group of any number of characters (including none at all) up to the beginning of the next group - this is stored as $2 (</value>.*) - Capture a group (stored as $3) from </value> to... $ - ...the end of the string $1hello$2 - Replace it (ie the whole thing as we have capture all of it) with group $i, "hello" and group $3 Clearer now? M23 Edit: Spot on kylomas. And I am by no means expert.
    1 point
  10. lolipop, (<value>) first capturing group ([^<]*) second capturing group - capture anything that is not a "<", repeat set 0 or more times (</value) third capturing group $1 and $3 correspond to first and third capturing group I am no where near the expert that M23 is but I'll try to explain his pattern ^ start of string (.*<value>) first caputuring group - capture everything up to and including <value> (.*) second capturing group - capture any single char, repeat 0 or more times (</value>.*) third caputuring group capture <value> and everything after till $ end of string kylomas
    1 point
  11. lolipop, Try this: $sOutput = StringRegExpReplace($sInput, '^(.*<value>)(.*)(</value>.*)$', '$1hello$3') M23
    1 point
  12. lolipop, Try this local $str = '<prop oor:name="givenname" oor:op="fuse"><value>qwerty</value></prop>' $str = stringregexpreplace($str,'(<value>)([^<]*)(</value)','$1' & ' some other string ' & '$3') ConsoleWrite('! ' & $str & @LF) kylomas
    1 point
  13. James

    SDL 2.0.0 is released

    SDL 2.0.0 has finally been released. I know this will make a certain MVP very happy. Source.
    1 point
  14. cyberbit

    UpdateEngine UDF

    Updated original post with UDF, examples, and other stuff.
    1 point
  15. Basic for clarity. I'm not suggesting it is always possible to avoid using global variables, only that it's generally good practice. The phrase in English is 'If everything was so simple'. You have the Russian version.
    1 point
  16. Notable mention is using prefix to indicate the type of expected variable. . $aStuff ;array $sStuff ;string $oStuff; object $hStuff; handle $bStuff ; binary, true/false $iStuff ; integer $nStuff ;number $g*stuff ; global variable $c*stuff ; constant If there is a more complete list, a link would be appreciated. I think there is a name for that syntax after some old school programmer, but for the life of me can't remember. I used to be really bad at doing that, and still revert to bad syntax when throwing out examples. I don't know what is a normal prefix for static, I never saw that keyword before perusing this thread. At first I didn't even get why people put those prefixes in, then once I got it I thought it would slow me down. Now I can't see myself doing anything halfway serious without it.
    1 point
  17. OK?! So there was no need for me to respond then? This is easier to read. #include <Array.au3> Global $g_aArray[2] = [1, 2] SomeFunc() Func SomeFunc() ReDim $g_aArray[3] ; Re-size the array and keep its content. _ArrayDisplay($g_aArray) Local $aArrayN[2] ; Create a new array. $g_aArray = $aArrayN ; Assign to the Global variable. $aArrayN = 0 ; Destroy array contents. _ArrayDisplay($g_aArray) EndFunc ;==>SomeFunc
    1 point
  18. ok, what I said is a little bit wrong. Here is my example : Global $var Local $var ;these vars are declared in the global scope, no matter of their statement, it's Global. ;to avoid any ambiguity, use only the Global statement. Global $aArray[2] = [1, 2] ;just an array. Func _myFunc() Local $var ;only use the local statement inside functions, if you want to declare a Global var, ;it's better to first initialize it in the global scope. ReDim $aArray[3] ;resize the array and keep its content. Dim $aArray[2] ;erases the content of the array. [and resizes it] ;it's better to use Dim/ReDim to edit an array, otherwise use Local or Global to declare a var. EndFunc Of course I don't say it's right nor I'm the one to follow and I'm opened to criticisms. @czardas If you declare a non existing var with the Dim statement, then It will be declared according to the current scope, otherwise it will take the scope of the declared var.
    1 point
  19. Declaring variables in loops (For, While, Do etc..) can have an affect on efficiency: #include <MsgBoxConstants.au3> ; Declaring variables inside loops should be avoided as the variable is re-declared on each repetition. For $i = 1 To 10 ; $i is in 'loop scope.' Local $iInt = $i Next MsgBox($MB_SYSTEMMODAL, '', $iInt) ; This will display 10. #include <MsgBoxConstants.au3> ; Declaring variables outside of loops is more efficent in the long run. Local $iInt = 0 For $i = 1 To 10 ; $i is in 'loop scope.' $iInt = $i Next MsgBox($MB_SYSTEMMODAL, '', $iInt) ; This will display 10.
    1 point
  20. Declaring Global variables in a Function is never a good idea: #include <MsgBoxConstants.au3> ; Calling Example() first will initialise the Global variable $vVariableThatIsGlobal and therefore calling SomeFunc() won't return an error. ; Now look at Example 2. Example() Func Example() ; Declaring a variable in a function can cause serious problems, hence why all Global variables should be declared at the top of a script. Global $vVariableThatIsGlobal = 'This is a variable that has ''File Scope'' aka Global.' SomeFunc() EndFunc ;==>Example Func SomeFunc() MsgBox($MB_SYSTEMMODAL, '', $vVariableThatIsGlobal) ; As the variable was initialised this will not return an error. EndFunc ;==>SomeFuncExample 2: #include <MsgBoxConstants.au3> ; Calling SomeFunc() first will bypass the Global variable $vVariableThatIsGlobal being initialised and therefore AutoIt has no idea of what data the variable ; $vVariableThatIsGlobal contains. SomeFunc() Func Example() ; Declaring a variable in a function can cause serious problems, hence why all Global variables should be declared at the top of a script. Global $vVariableThatIsGlobal = 'This is a variable that has ''File Scope'' aka Global.' SomeFunc() EndFunc ;==>Example Func SomeFunc() MsgBox($MB_SYSTEMMODAL, '', $vVariableThatIsGlobal) ; As the variable wasn't initialised this will return an error of "variable used without being declared." EndFunc ;==>SomeFunc Question: What if I want to retain variable data once returned from a Function and only use that variable in that particular Function, can't it be declared as Global then? Answer: Static variables. #include <MsgBoxConstants.au3> Example() Func Example() SomeFunc() ; This will display a message box of 1, 1. SomeFunc() ; This will display a message box of 1, 2. SomeFunc() ; This will display a message box of 1, 3. EndFunc ;==>Example Func SomeFunc() ; This initialises a Static variable in Local scope. When a variable is declared just in Local scope (within a Function,) ; it's destroyed when the Function ends/returns. This isn't the case for a Static variable. The variable can't be ; accessed from anywhere else in the script apart from the Function it was declared in. Local Static $vVariableThatIsStatic = 0 Local $vVariableThatIsLocal = 0 $vVariableThatIsLocal += 1 ; This will always be 1 as it was destroyed once returned from SomeFunc. $vVariableThatIsStatic += 1 ; This will increase by 1. MsgBox($MB_SYSTEMMODAL, $vVariableThatIsLocal, $vVariableThatIsStatic) EndFunc ;==>SomeFunc
    1 point
  21. smita

    Application Login

    I have written a script for login page of application which we are going to test : #include <IE.au3> $oIE = _IECreate ("http://12.44.178.188/",0,1,1) $oForm = _IEFormGetCollection ($oIE, 0) $oLogin = _IEFormElementGetObjByName($oForm, "login") $oPass = _IEFormElementGetObjByName($oForm,"passwd") _IEFormElementGetObjByName($oLogin,"login") _IEFormElementGetObjByName($oPass,"passwd") $USERNAME = 'username' $PASSWORD = 'username' _IEFormElementSetValue($oLogin,$USERNAME) _IEFormElementSetValue($oPass,$PASSWORD) _IEFormSubmit($oForm) In this script login page is taking username but its not taking the password ! Password text box is below Username textbox $oPass = _IEFormElementGetObjByName($oForm,"passwd") Should be $oPass = _IEFormElementGetObjByName($oForm,"password") if I'm not mistaken... Thank u ! Now it's taking password! There are two buttons on the login page one is "Connect" & another is "Exit" Want 2 click on "Connect" button but this script is not clicking any buttons! Can u please help me in this? Hi,I have written scirpt for login page of the application which we are going to test. $oIE = _IECreate ("http://12.44.178.188/",0,1,1) $oForm = _IEFormGetCollection ($oIE, 0) $oLogin = _IEFormElementGetObjByName($oForm, "login") $oPass = _IEFormElementGetObjByName($oForm,"password") ;$osignin = _IEFormElementGetObjByName ($oForm, "SI") $USERNAME = 'admin' $PASSWORD = 'admin' _IEFormElementSetValue($oLogin,$USERNAME) _IEFormElementSetValue($oPass,$PASSWORD) _IEFormSubmit ($oForm) In login page there are two buttons , "Connect" & "Exit" . When I am running the script it's not clicking on the "Connect" button , so I am not getting the main page. Can you please help me how to click on "Connect" button using this scirpt? The name of the Connect button is "btnConnect", not "SI". Use that and then add _IEAction($osignin, "click") Recommend you get DebugBar (see my sig) to make this easier. Dale
    1 point
×
×
  • Create New...