Search the Community
Showing results for tags 'function'.
-
This topic give you access to an AutoIt functions library I maintain which is called PAL, Peter's AutoIt Library. The latest version 1.29 contains 231 functions divided into these topics: window, desktop and monitor GUI, mouse and color GUI controls including graphical buttons (jpg, png) GUI numberbox controls for integer, real, binary and hexadecimal input logics and mathematics include constants string, xml string and file string dialogues and progress bars data lists: lists, stacks, shift registers and key maps (a.ka. dictionaries) miscellaneous: logging/debugging, process and system info Change log and files section on the PAL website (SourceForge). A lot of these functions were created in the development of Peace, Peter's Equalizer APO Configuration Extension which is a user interface for the system-wide audio driver called Equalizer APO.
-
Hi! I have a program that has a specific function that renames the computer. The entire program should be executed only on behalf of the current user, because some registry keys in the HKCU are being changed. The current user does not have administrator rights, so #Requireadmin is not suitable as a solution. The administrator accounts on the computers are different, so "RunAs" is not suitable. Is there a way to trigger a UAC, when running a function? The function code, if you need: Func _RenamePC($Input2) Local $Name = GUICtrlRead($Input2) $objWMIService = ObjGet("winmgmts:\root\cimv2") For $objComputer In $objWMIService.InstancesOf("Win32_ComputerSystem") $oReturn = $objComputer.rename($Name) Next EndFunc
-
I'm new to Auotit but I have built a simple script that "runs" a different "batch" file based on certain days of the workweek. The script works now, but I was wanting to eliminate the need for a manual date entry. For example "First Batch' needs to run every Tuesday thru Thursday however "Second Batch" needs to run only on Friday and "Third Batch" needs to run only on Monday. In addition the 1st batch file runs on Tuesday, say 06/06 (the "FW" section) but then needs to actually report (the F4 date) the next weekday so this Batch actually needs 2 dates verified. What I'm trying to do is when the script is initiated it gets the date, verifies if and which weekday it is and in turn goes to and runs the appropriate "Batch' file. I've found ways to verify weekdays but can't find anything to do all of the above. Any help is MUCH appreciated. ;P10 ShellExecute("C:\Program Files (x86)\Ericom Software\PowerTerm Enterprise\Sessions\mir00p10.PTS") WinWait('(A) Soutwest P10 : PowerTerm Pro Enterprise Suite') WinActivate('(A) Soutwest P10 : PowerTerm Pro Enterprise Suite') Send('$Login) Sleep(3000) Send('{Enter}') Sleep(3000) Send($Password) Send('{Enter}') Sleep(3000) ; ****First Batch file run Send('Batch') Sleep(3000) Send('{Enter}') Send('FW') Send('{Enter}') Send('{DOWN}') Send($Date) Send('{Enter}') Send('{Enter}') Send($Date) Send('{F9}') Send('Y') Sleep(3000) Send('{Enter}') Send('{F4}') Send('Y') Sleep(3000) Send('{Enter}') Send($Date) Send('{Enter}') Send('0620') Send('{Enter}') SEND('{!}SW0410PM.FWR') Send('{Enter}') Sleep(3000) Send('Y') Send('{Enter}') Sleep(3000) Send('{F9}') Sleep(3000) ; ****Second Batch file run Send('Batch') Sleep(3000) Send('{Enter}') Send('FW') Send('{Enter}') Send('{DOWN}') Send($Date) Send('{Enter}') Send('{Enter}') Send($Date) Send('{F9}') Send('Y') Sleep(3000) Send('{Enter}') Send('{F4}') Send('Y') Sleep(3000) Send('{Enter}') Send($Date) Send('{Enter}') Send('0620') Send('{Enter}') SEND('{!}SO0411AM.FWR') Send('{Enter}') Sleep(3000) Send('Y') Send('{Enter}') Sleep(3000) Send('{F9}') Sleep(3000) ; ****Third Batch file run Send('Batch') Sleep(3000) Send('{Enter}') Send('FW') Send('{Enter}') Send('{DOWN}') Send($Date) Send('{Enter}') Send('{Enter}') Send($Date) Send('{F9}') Send('Y') Sleep(3000) Send('{Enter}') Send('{F4}') Send('Y') Sleep(3000) Send('{Enter}') Send($Date) Send('{Enter}') Send('0620') Send('{Enter}') SEND('{!}SW0411AM.LOA') Send('{Enter}') Sleep(3000) Send('Y') Send('{Enter}') Sleep(3000) Send('{F9}') Sleep(3000) Send('EXIT')
-
I seem to have lost my sense of how the Global scope works. In this example $p is Global but I can't seem to set $p in function __One and then pass that version of $p to function __Two. I thought you could set a Global to a new value from within a function and it would affect the Global value. I've stared and played with this code for over an hour and I'm missing something really basic. Help appreciated. #AutoIt3Wrapper_run_debug_mode=Y ; use this to debug in console window <--- LOOK Global $p = 999 MsgBox(0, "DEBUG", "MAIN - $p = '" & $p & "'") __One() Exit Func __One() ;Global $p ;this seems to make no difference - comment it out to see - how does one affect the Global in a function? MsgBox(0, "DEBUG", "Entering Func __One() - $p = '" & $p & "'") For $p = 1 to 3 MsgBox(0, "DEBUG", "IN Func __One() - $p = '" & $p & "'") __Two() Next EndFunc Func __Two() MsgBox(0, "DEBUG", "Entering __Two() $p = '" & $p & "'") EndFunc
-
My au3 script program needs administrator privileges on win10 to be executed correctly, because it needs to be added to the boot---Script code:RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName, "REG_SZ", @ScriptFullPath) I need to let the program automatically get administrator privileges, so I use a function of #RequireAdmin. Although the program can be added to the boot, but does not execute after system boot up? why is that? What should I do? -------------------------------------------------------------------- Update: I found that after using the #RequireAdmin function, the program cannot be executed after system boot up. An example is given below. after it is compiled, it will not be executed after system boot up in the following two ways. 1. C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\ 2. RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName, "REG_SZ", @ScriptFullPath) why is that? example #include <MsgBoxConstants.au3> #RequireAdmin Func test() MsgBox(0, "", "this is test message") EndFunc ;==>test test()
-
Hi, here are few functions for the ListBox. I have searched the forum, but most of the functions are for listview, so i took one example code from melba23 (clear selection) and wrote few more functions. (Because my current project needs them). These functions work only on a Multi-selection ListBox . Edit: Only 1 function does not work with single selection box. The functions do: Clear Selection, Delete Selected items, Invert Selection, Move selected items up and down. The example code has 2 Listboxes. The selected items on the left ListBox can be moved up and down. The right Listbox has buttons for the other functions. #include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> #include <Array.au3> Local $singlesel = 0, $iMsgBoxAnswer = 0 ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=Question, Modality=Task Modal $iMsgBoxAnswer = MsgBox(8228, "Choose Listbox selecton type", "Yes for single, No for multi selection box") If $iMsgBoxAnswer = 6 Then $singlesel = 1 ;Yes Local $BL_1,$BL_2,$BR_1,$BR_2,$BR_3,$BR_4,$BR_5,$BR_6 Global $hForm1 = GUICreate("Listbox test", 349, 287) $LB_1 = GUICtrlCreateList("", 6, 40, 157, 244, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $WS_HSCROLL, $WS_VSCROLL, $LBS_DISABLENOSCROLL)) If $singlesel = 1 Then $LB_2 = GUICtrlCreateList("", 179, 40, 157, 244, BitOR($LBS_NOTIFY, $WS_HSCROLL, $WS_VSCROLL, $LBS_DISABLENOSCROLL)) Else $LB_2 = GUICtrlCreateList("", 179, 40, 157, 244, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $WS_HSCROLL, $WS_VSCROLL, $LBS_DISABLENOSCROLL)) $BR_3 = GUICtrlCreateButton("Reverse Sel", 272, 22, 68, 17) EndIf $BL_1 = GUICtrlCreateButton("Up", 20, 3, 35, 18) $BL_2 = GUICtrlCreateButton("Down", 60, 3, 35, 18) $BR_1 = GUICtrlCreateButton("Up", 200, 3, 35, 18) $BR_2 = GUICtrlCreateButton("Down", 240, 3, 35, 18) $BR_4 = GUICtrlCreateButton("Clear Sel", 217, 22, 52, 17) $BR_5 = GUICtrlCreateButton("Delete", 175, 22, 40, 17) $BR_6 = GUICtrlCreateButton("Populate", 290, 3, 50, 18) GUISetState(@SW_SHOW) For $x = 0 To 50 If $x <= 10 Then GUICtrlSetData($LB_1, $x & " test", 0) GUICtrlSetData($LB_2, $x & " Test", 0) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BL_1 $a = Listbox_ItemMoveUD($LB_1, -1) If $a > -1 Then WinSetTitle($hForm1, "", "Moved items: " & $a) Case $BL_2 $a = Listbox_ItemMoveUD($LB_1, 1) If $a > -1 Then WinSetTitle($hForm1, "", "Moved items: " & $a) Case $BR_1 Listbox_ItemMoveUD($LB_2, -1) Case $BR_2 Listbox_ItemMoveUD($LB_2, 1) Case $BR_3 Listbox_ReverseSelection($LB_2) Case $BR_4 Listbox_ClearSelection($LB_2) Case $BR_5 Listbox_DeleteSelectedItems($LB_2) Case $BR_6 ;Populate GUICtrlSetData($LB_2, "") ; Clears the listbox For $x = 0 To 50 GUICtrlSetData($LB_2, $x & " Test", 0) Next EndSwitch WEnd ;note $hLB_ID - is the Listbox id Func Listbox_DeleteSelectedItems($hLB_ID) Local $aSel = _GUICtrlListBox_GetSelItems($hLB_ID) ;Get selected items Local $i, $slb = 0, $y, $x If $aSel[0] = 0 Then ;If the array is empty, there is no selection, or it is a single selection listbox For $x = 0 To _GUICtrlListBox_GetCount($hLB_ID) - 1 $y = _GUICtrlListBox_GetSel($hLB_ID, $x) If $y = True Then $slb = 1 _GUICtrlListBox_DeleteString($hLB_ID, $x) ;Perform a delete on single sel. LB ExitLoop EndIf Next EndIf If $slb = 0 Then _GUICtrlListBox_BeginUpdate($hLB_ID) For $i = $aSel[0] To 1 Step -1 ;Loop backwards and delete the selected items _GUICtrlListBox_DeleteString($hLB_ID, $aSel[$i]) Next _GUICtrlListBox_EndUpdate($hLB_ID) EndIf EndFunc ;==>Listbox_DeleteSelectedItems Func Listbox_ClearSelection($hLB_ID) ;Removes the selection from multi and single selection ListBox Local $aSel = _GUICtrlListBox_GetSelItems($hLB_ID) ;Code from Melba23 - Autoit Forum Local $slb, $x, $y If $aSel[0] = 0 Then _GUICtrlListBox_SetCurSel($hLB_ID, -1) $slb = 1 EndIf If $slb = 0 Then _GUICtrlListBox_BeginUpdate($hLB_ID) For $i = 1 To $aSel[0] _GUICtrlListBox_SetSel($hLB_ID, $aSel[$i], False) Next _GUICtrlListBox_EndUpdate($hLB_ID) EndIf EndFunc ;==>Listbox_ClearSelection Func Listbox_ReverseSelection($hLB_ID) ;Logically, this function works only on multi-selection listboxes Local $i Local $aCou = _GUICtrlListBox_GetCount($hLB_ID) Local $cSel = _GUICtrlListBox_GetCaretIndex($hLB_ID) ;Save the caret _GUICtrlListBox_BeginUpdate($hLB_ID) For $i = 0 To $aCou _GUICtrlListBox_SetSel($hLB_ID, $i, Not (_GUICtrlListBox_GetSel($hLB_ID, $i))) Next _GUICtrlListBox_SetCaretIndex($hLB_ID, $cSel) ;Restore the caret _GUICtrlListBox_EndUpdate($hLB_ID) EndFunc ;==>Listbox_ReverseSelection Func Listbox_ItemMoveUD($hLB_ID, $iDir = -1) ;Listbox_ItemMoveUD - Up/Down Move Multi/Single item in a ListBox ;$iDir: -1 up, 1 down ;Return values -1 nothing to do, 0 nothing moved, >0 performed moves Local $iCur, $iNxt, $aCou, $aSel, $i, $m = 0, $y, $slb = 0 ;Current, next, Count, Selection, loop , movecount $aSel = _GUICtrlListBox_GetSelItems($hLB_ID) ;Put selected items in an array $aCou = _GUICtrlListBox_GetCount($hLB_ID) ;Get total item count of the listbox If $aSel[0] = 0 Then $y = _GUICtrlListBox_GetCurSel($hLB_ID) If $y > -1 Then _ArrayAdd($aSel, $y) $aSel[0] = 1 $slb = 1 EndIf EndIf ;WinSetTitle($hGUI, "", $aSel[0]) ;Debugging info Select Case $iDir = -1 ;Move Up For $i = 1 To $aSel[0] If $aSel[$i] > 0 Then $iNxt = _GUICtrlListBox_GetText($hLB_ID, $aSel[$i] - 1) ;Save the selection index - 1 text _GUICtrlListBox_ReplaceString($hLB_ID, $aSel[$i] - 1, _GUICtrlListBox_GetText($hLB_ID, $aSel[$i])) ;Replace the index-1 text with the index text _GUICtrlListBox_ReplaceString($hLB_ID, $aSel[$i], $iNxt) ;Replace the selection with the saved var $m = $m + 1 EndIf Next For $i = 1 To $aSel[0] ;Restore the selections after moving If $aSel[$i] > 0 Then If $slb = 0 Then _GUICtrlListBox_SetSel($hLB_ID, $aSel[$i] - 1, 1) Else _GUICtrlListBox_SetCurSel($hLB_ID, $aSel[$i] - 1) EndIf EndIf Next Return $m Case $iDir = 1 ;Move Down If $aSel[0] > 0 Then For $i = $aSel[0] To 1 Step -1 If $aSel[$i] < $aCou - 1 Then $iNxt = _GUICtrlListBox_GetText($hLB_ID, $aSel[$i] + 1) _GUICtrlListBox_ReplaceString($hLB_ID, $aSel[$i] + 1, _GUICtrlListBox_GetText($hLB_ID, $aSel[$i])) _GUICtrlListBox_ReplaceString($hLB_ID, $aSel[$i], $iNxt) $m = $m + 1 EndIf Next EndIf For $i = $aSel[0] To 1 Step -1 ;Restore the selections after moving If $aSel[$i] < $aCou - 1 Then If $slb = 0 Then _GUICtrlListBox_SetSel($hLB_ID, $aSel[$i] + 1, 1) Else _GUICtrlListBox_SetCurSel($hLB_ID, $aSel[$i] + 1) EndIf EndIf Next Return $m EndSelect Return -1 EndFunc ;==>Listbox_ItemMoveUD
-
I want to use the winsock overlapped/completion routine method of i/o, but how do I get the pointer to my user function. I know it is possible because when using the old method of windows messages, the user function name was used instead of a pointer.
-
SciTE Hopper : Jump to Any line by one click and many other helpfull functions ! As Ashalshaikh suggested me after leaving me the task to continue >SciTE Hopper, i open a new Topic about it. It will be more easy for futures updates. Many helpfull functions in contextual menu. SciTE Hopper is now multipurpose. • Color Catcher added • BinaryToAu3Kompressor added • TinyAu3Search replaced by StringFinder • RegJumper added • Edit With SciTE added (available in Options) • SpecialCharactersViewer added (available in Tray menu) New Contextual Menu : For a right Click on a function : • Copy function name • Insert a function header • Cut function • Copy function • Delete function • Create a variables List • Remove usseless Blank lines • Remove Debug lines ( all lines starting with ConsoleWrite or _ArrayDisplay ) • Set AutoIt Code Layout • Remove Comments For entire script : • Create a functions List • Create a variables List • Remove usseless Blank lines • Remove Debug lines ( all lines starting with ConsoleWrite or _ArrayDisplay ) • Set AutoIt Code Layout • Remove Comments • ( Open in SciTE a ) Duplicate of current Script in Temp Dir • ( Open in SciTE a ) Duplicate of current Script in Same Dir • Explore Parent Script Folder • Copy Script name • Copy Script path • Find Unused Functions • Find Unused Variables • Set all functions in alphabetic order.( func headers and regions ( in fact, all lines between functions ) are not supported.) SciTE Editor New Contextual Menu if SciTE Hopper is added ( in Options ) to SciTE Editor : when you made a selection in SciTE Editor you can : • Open a Reg Key in Regedit using RegJumper • Open a Url in your default Browser • Search on google in your default Browser • Search on AutoIt Website in your default Browser Now Can be added to windows start (minimized) Options are available by Tray Menu. A double click on tray icon will open clipboard content to SciTE Editor ( Handy when you have copied some code from your browser ) How to proceed for add SciTE Hopper to SciTE Editor : Run Scite Editor, run Scite Hopper ( compiled! ) go to Options and select Add/Remove to SciTE Tab. then click on Add button and it's done ! Right click on SciTE Editor and choose SciTE Hopper in Contextual Menu for run it when you need it ! Update of 07 Dec 2017 TinyAu3Search is replaced by StringFinder Previous downloads : 1287 Script and compiled version are available in the download section Thanks to Ashalshaikh, Melba23, Th3 MMA, Alzri2, taitel, Manadar, taz742, Yashield, Authenticity, Xenobiologist for their help and asdf8 for his >Includes Helper and azjio for his >FileSearch. Hope it help you and happy Scripting !
-
Hi All, MAIN QUESTION: Is it possible to Call specific function within a GUI So I have a script with multiple functions although I don't want to use every function every time. My Idea is to create a simple GUI which allows me to select what functions I want to use then run the funtions by clicking a button. I have already made a GUI which allows me to select specific .exe's I would like to run after selection it runs the .exe one by one. This script is on my work laptops and cannot access it right now. Who can help me with this? GUIcreate Func1 Func2 Func3 Then have a boxes which allows me to select the specif Func.(I used GUIChecked and Unchecked in my other script) Then a button which executes/calls the selected functions
-
Hi, can anybody explain "pure virtual function" and how to make use of them?
-
Good evening everyone I was trying to insert function header to the functions of my script, but, in the SciTE console, this appears: Function or struct definition not found, unable to insert header. @Jos Any suggestion? Thanks in advance. Best Regards.
-
Hi! I have another problem with AutoIT. You see, I'm still the one who's just starting out with this great programming language. I have a problem with AutoIT, it seems not to recognize the "StringReplace" function even when it is by default. The code was made half in KODA and half of my own. It is a software programmed for the Italian language (I am Italian) and translate the SMS language into Italian correct. Would you help me? Thanks in advance. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $hull = "hello" StringReplace($hull, "hello", "hellx") $Form1 = GUICreate("Linguaggio SMS A Italiano", 507, 498, 192, 124) $Edit1 = GUICtrlCreateEdit("", 24, 40, 465, 177) GUICtrlSetData(-1, "") $Label1 = GUICtrlCreateLabel("Inserisci qui il testo che non riesci a capire:", 24, 8, 205, 17) $Label2 = GUICtrlCreateLabel("Ecco il testo tradotto(non toccare questo campo):", 27, 237, 237, 17) $Edit2 = GUICtrlCreateEdit("", 24, 264, 465, 137) GUICtrlSetData(-1, "") $Button1 = GUICtrlCreateButton("Traduci", 104, 424, 249, 49) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 StringReplace(GUICtrlGetData($Label1), "qlc", "qualcuno") StringReplace(GUICtrlGetData($Label1), "qls", "qualcosa") StringReplace(GUICtrlGetData($Label1), "ke", "che") StringReplace(GUICtrlGetData($Label1), "x", "per") StringReplace(GUICtrlGetData($Label1), "pls", "per favore") StringReplace(GUICtrlGetData($Label1), "tu6", "tu sei") StringReplace(GUICtrlGetData($Label1), "zzz", "mi fai dormire") StringReplace(GUICtrlGetData($Label1), "hagn", "Buonanotte") StringReplace(GUICtrlGetData($Label1), "tvtb", "Ti voglio tanto bene") StringReplace(GUICtrlGetData($Label1), "tat", "Ti amo tanto") StringReplace(GUICtrlGetData($Label1), "lafs", "Amore a prima vista") StringReplace(GUICtrlGetData($Label1), "fli?", "Flirtiamo?") StringReplace(GUICtrlGetData($Label1), "msidt", "Mi sono innamorato di te") StringReplace(GUICtrlGetData($Label1), "ba", "Bacio") StringReplace(GUICtrlGetData($Label1), "midi", "Mi dispiace.") StringReplace(GUICtrlGetData($Label1), "ntm", "Non ti merito") StringReplace(GUICtrlGetData($Label1), "tdp", "Togliti dai piedi.") StringReplace(GUICtrlGetData($Label1), "amò", "Amore") StringReplace(GUICtrlGetData($Label1), "ap", "A presto!") StringReplace(GUICtrlGetData($Label1), "cmq", "comunque") StringReplace(GUICtrlGetData($Label1), "cvd", "Ci vediamo dopo") StringReplace(GUICtrlGetData($Label1), "Tvb", "Ti voglio bene") StringReplace(GUICtrlGetData($Label1), "nn", "non") StringReplace(GUICtrlGetData($Label1), "risp", "rispondimi") StringReplace(GUICtrlGetData($Label1), "cel", "cellulare") StringReplace(GUICtrlGetData($Label1), "dom", "qualcosa") StringReplace(GUICtrlGetData($Label1), "nm", "numero") StringReplace(GUICtrlGetData($Label1), "fv", "favore") StringReplace(GUICtrlGetData($Label1), "-male", "meno male") StringReplace(GUICtrlGetData($Label1), "disc", "discoteca") StringReplace(GUICtrlGetData($Label1), "se#", "settimana") StringReplace(GUICtrlGetData($Label1), "+ o -", "più o meno") StringReplace(GUICtrlGetData($Label1), "ts", "torno subito") StringReplace(GUICtrlGetData($Label1), "tvtbcoa", "Ti voglio tanto bene come amica") EndSwitch WEnd
-
As with a lot of programming, the less manual repetition done to achieve the same outcome...the better. I package programs for network deployment at the organization I work for. Sometimes these applications require verbose messaging to the user, and sometimes by special request we have to turn that off and deploy silently. The way I currently handle these 2 scenarios is this. I have a function that builds the splashwin display screen to variable size depending on message length, and displays the desired message to the end user. Then at each point throughout my script as I need to make the user aware of what is currently happening, I inject a splashwin function call with the unique message pertaining to that specific event. ie. "Installing Microsoft Office, please wait..." In effort to build a more universal script to handle any type of request submitted. I've incorporated a switch command of '/silent' If cmdlineraw detects the usage of that switch when the script is triggered it sets a variable flag, ie. $silent = "on" Then at every splashwin call I make, I'm prefixing it with an IF statement that checks for the flag, and then does NOT display the message if that flag is "on". Or does display it if its not. Has worked for me just fine. But while I grow my programming skills and look for more streamlined ways of handling areas I find myself creating repetition. I'm curious if I can relocate that flag check. Taking it out of every single splashwin call, and injecting it into the function itself. Example of how I currently display or hide the splashwin based on command line... If StringInStr($cmdlineraw, "/silent", 0) Then $SilentSwitch = "ON" EndIf If $SilentSwitch = "OFF" Then SplashWin($Uninstalling & $ProductInfo[1][0]) Some scripts have dozens of those splashwin calls littered throughout, so Is this the best approach I can take already? Or as stated earlier, can I pull the IF statement away from the splashwin call. And left the function as a whole either activate or deactivate as a result of the command line check.
-
Hello, I am new to both Programming and this forum. I have done a few tiny projects that were successful and fell in love with Autoit. So now I am trying to learn new things as I go. I have read the Help docs on my following question, I have gone thru all of that. and I am sure as soon as you see my code you will be saying OMG why did he do that, or OMG how can you forget to add this.. But when your new you take the path of least resistance to get the outcome you want. SETUP: I am trying to make a code that will open a piece of software, then open a browser (which has a handful of tabs already open) go to a web page (one of the tabs) and search an area of the web page for a specific color, if that color is found I want it to close the browser and go back and start again. If that color is not found on that page I want it to switch tabs and search that page for the color. If the color is found on that page I want it to close the browser and start again. If the color is not found on either page, I want it to open another browser and go to website and do some things I will add once i get past this obstacle. I already have it almost there my code will open my software, open the browser, do the searches, find or not find the color, the part I am having trouble with is the if and else and what happens if and what it does if it does not. So the first code I have does everything I want except if it finds the color on the first run it closes the browser, but then when it starts the process again it doesnt check for the color. its like it skips the scanning part and goes straight to the opening of the second browser and finishes the code. Run( "C:\Programs\myprogram.exe", "", @SW_SHOWDEFAULT ) Sleep(4000) MouseClick("left", 613,272) ;click in program Sleep(500) Example() Func Example() MouseClick("left", 632,456) ;click in program Sleep(500) MouseClick("left", 527,456) ;click in program Sleep(15000) Run( "C:\Programs\browser1.exe", "", @SW_SHOWMAXIMIZED ) Sleep(Random(4000,6000)) EndFunc ;==>Example MouseClick("left", 162,14) ;switch tab Sleep(Random(5000,8000)) MouseClick("left", 354,14) ;switch tab Sleep(Random(5000,8000)) $aCoord = PixelSearch(873, 485, 900, 600, 0xDD0000, 10) ;search for color If Not @error Then MouseClick("left", 1338,6) ;close browser1 Sleep(1000) Call("Example") Else MouseClick("left", 162,14) ;switch tab Sleep(1000) EndIf MouseClick("left", 162,14) ;click tab again just to be sure its loaded Sleep(4000) $aCoord = PixelSearch(1052, 308, 1120, 431, 0xFF0000, 10) ;search for this color If Not @error Then MouseClick("left", 1338,6) ;close browser1 Sleep(1000) Call("Example") Else Run( "C:\Programs\browser2.exe", "", @SW_SHOWMAXIMIZED ) Sleep(2000) EndIf MouseClick("left", 134,45) ;click on address bar Sleep(1000) Send("aspecificwebpage.com") ;input website Send("{enter}") ;hit enter Sleep(15000) MouseClick("left", 1338,6) ;close browser2 Sleep(500) MouseClick("left", 1338,6) ;close browser1 Sleep(500) MouseClick("left", 625,454) ;click in program Sleep(500) MouseClick("left", 634,271) ;click in program Sleep(500) MouseClick("left", 917,245) ;close program Sleep(500) SO it makes the first scan and is successful, if the color is found it closes as I want, but then when nit starts the code again it does not scan anything the second time. and on the other side, if the color is not found naturally everything works as it is written. I want to guess by all the weird colors in the code sniplet I have a massive amount of errors. It is like a rainbow of text up there. different from what i see in AutoIT Any help would be appreciated.
-
Hi, I wonder if AutoIt3Wrapper_run_debug_mode = Y can include run information about functions which are called within the main code. So far I noticed in the console that the function itself is called but no specific run information from inside the function is provided. Is there a chance to show the entire debug log including functions in the console? I furthermore noticed a stop of information when a loop is entered. What could be the reason for that? Thanks for help.
- 4 replies
-
- autoit3wrapper
- function
-
(and 1 more)
Tagged with:
-
Is this possible: Executing a function from an include, but taking the function name from a gui input and then executing that function using the include: #include <Something.au3> ;input reads "Tree" $functionName = GuiCtrlRead($input1) $functionName(1) And the include is gonna have Func Tree($x) If $x = 1 Then $this = "text" MsgBox(0,$this,"whatever") EndFunc is it possible?
-
Hello, i'm making a little script that lets users enter a question and if the script can't answer to, it ask what would be the answer (a bit like siri on IPhones). And I try to display the "supposed array" I still have an error.. I searched on Google and got nothing looked in the help file too.. I'm here to know if someone have a solution to my error please. Here is where $a and $b should become arrays : Dim $dossier = @AppDataDir & "\Siri2" Dim $chemin = $dossier & "\data.ini" Global $a = _InfoRead($chemin, 0) Global $b = _InfoRead($chemin, 1) with this function : Func _InfoRead($path, $mode = 0) If DirGetSize($dossier) = -1 Then Return SetError(-4) If Not FileExists($chemin) Then Return SetError(-5) Local $readed = IniReadSection($path, "data") If @error Then Return SetError(-3) $size = $readed[0][0] Local $return[$size] For $i = 1 To $size Step 1 $return[$i - 1] = $readed[$i][$mode] Next Return $return EndFunc and the thing that i don't understand is that, after _InfoRead return affected to $a, I can't use _ArrayDisplay because of error 1 "$aArray is not an array" (and same fpr the variable $b).. Can please someone help me to understand why is it doing this ? -hcI
-
Hi, I have a problem, my functions do not work with each other. Separately, each works very well. Features that do not work together it's loot() and pos1(). It looks that after spreadsheet function loot() script stops working even though everything is in the While 1-Wend loop. Can someone help me please?
-
Hi I am trying to check a number of applications are up to date and install the update if required. This will run as a shutdown script, pushed out through Group Policy. I am querying various registry keys to determine if The software is actually installed The software is at the correct version Once the need for update is determined then it calls another function to run the update. If the software is up to date or not installed, it moves down to the next software section which changes the registry key variables and calls the registry query function again I have managed to get the function for (un)installs to work but I am having trouble with the registry query function #NoTrayIcon #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> ; Here we go! ;########################################################################################################## ;Declare variables Global $RegKey86, $RegKey64, $RegValueName, $RegValueData, $CheckVersion86, $CheckVersion64 ; 7Zip ;########################################################################################################## _7Zip_Function() Func _7Zip_Function() ; Registry location and values that are checked for current software version ; Ensure the x64 key is preceeded with 'HKLM64' $RegKey86="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" $RegKey64="HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" $RegValueName="DisplayVersion" $RegValueData="16.04" ; Excecution ; --------------------------------------------------------------------------------------------------------- If _CheckSW() = 1 Then _UninstallOldVer() _InstallSW() EndIf EndFunc ;==>_7Zip_Function ; Functions ;########################################################################################################## Func _CheckSW() $CheckVersion86=RegRead ($RegKey86, $RegValueName) $CheckVersion64=RegRead ($RegKey64, $RegValueName) If $CheckVersion86=$RegValueData Or $CheckVersion64=$RegValueData Then Return 0 ElseIf $CheckVersion86="" And $CheckVersion64="" Then Return 0 Else Return 1 EndIf EndFunc ;==>CheckSW
- 11 replies
-
Hi guys, Hope you are fine today I'm trying to restart a function by calling it back in the script: Here's my code so far: Func f_VPN() $iInputBox = InputBox("Password", "Please Enter the User's password.") If @Error = 1 Then GUICtrlSetState($fVPN, $GUI_UNCHECKED) Else ShellExecute("C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe") $hVPN = WinWait("Cisco AnyConnect Secure Mobility Client", "Ready to connect") ControlClick($hVPN, "", "Button1") $hVPN1 = WinWait("Cisco AnyConnect | SEE VPN", "Cancel") ControlSetText($hVPN1, "", "Edit2", @Username) Sleep(250) ControlSetText($hVPN1, "", "Edit3", $iInputBox) Sleep(250) ControlClick($hVPN1, "", "Button1") Sleep(5000) If ControlGetText("Cisco AnyConnect Secure Mobility Client", "", "Static2") = "Login Failed" Then ControlClick("Cisco AnyConnect Secure Mobility Client", "", "Button4") WinClose($hVPN) f_VPN() Else ShellExecute("C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe") If ControlGetText("Cisco AnyConnect Secure Mobility Client", "", "Static2") = "Connected To SEE VPN." Then ControlClick("Cisco AnyConnect Secure Mobility Client", "", "Button1") Sleep(1000) WinClose("Cisco AnyConnect Secure Mobility Client", "") ProcessClose("vpnui.exe") ; ProcessClose("explorer.exe") <<< TO UNCOMMENT IniWrite($oIniFile, "LaptopChkBox", "VPN", "1") EndIf EndIf EndFunc I'd like to the function to be restarted in the case the password provided is not correct. I've googled many things but nothing very relevant. Any ideas over here? Thanks -31290
-
Hi guys, Could someone please tell me what I'm doing wrong with this code? I'm trying to take user input and then run a function with the same name, but it's not calling the function. So in the below after pressing Shift+F8 I would enter the text (without quotes) "testFunc". As you can see I've also tried this with IF statements, I'm new to using Switch/Case. HotKeySet("+{F8}", RunManually) Func RunManually() ;Use a case statement with 1 hot key and an InputBox to manually run functions $funcName = InputBox("Which Func to Run?", "Enter the name of the function to run") MsgBox(0, "Entered value", $funcName) ;If $funcName = testFunc Then testFunc() ;If $funcName = test2Func Then test2Func() Switch $funcName Case testFunc MsgBox(0, "Calling", "Calling Function") testFunc() MsgBox(0, "Called", "Function call finished") Case test2Func MsgBox(0, "Calling", "Calling Function") test2Func() MsgBox(0, "Called", "Function call finished") EndSwitch EndFunc While 1 ;testFunc() Sleep(1000) WEnd Func testFunc() MsgBox(0, "func running", "Seems to work!") EndFunc Func test2Func() MsgBox(0, "func 2 running", "2 Seems to work!") EndFunc Thanks!
-
LAST VERSION - 1.0 28-May-12 This small utility designed for viewing the exported DLL functions and is written specifically for AutoIt community. Nothing excess, just the tools you need. Especially useful are Drag-and-Drop and support for command line that allows you to add DLL Helper in the Windows Explorer context menu. To do this, you can use the following .reg file. Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\dllfile\shell\View] @="View exported function" [HKEY_CLASSES_ROOT\dllfile\shell\View\command] @=""C:\Program Files\DLLHelper\DLLHelper.exe" "%1""Also worth noting is fairly fast enumeration of exported DLL functions and the ability to export the function list into a text or HTML document. As usualy, I will be glad to any feedback and suggestions. Major program features Support for both x86 and x64 DLL files.Fast enumeration of exported DLL functions.Support for command line (use the full path in the first parameter).Support Drag-and-Drop.Web search for functions with the ability to add user-defined services (up to 10, via registry).Ability to view the undecorated names of DLL function.Ability to specify a filter to display the functions of interest.Sort the function list by any column.Copying any data (by column) from the list to the clipboard.Export list of function to the .txt or .html file.List of recently opened files (up to 10).Simple and intuitive interface. License Supported operating systems Windows XP, Vista, 7 Files to download Binary Redirection to DLLHelper_bin.zip, 475 KB DLLHelper_bin.html Source Redirection to DLLHelper_source.zip, 657 KB DLLHelper_source.html
-
Could someone please explain to me how you can use Func_SearchLastState more than once in the same script. My situation is I am trying to use it in the same script under different case scenarios: e.g. Case 1 Func_SearchLastState($sMachine) Case 2 Func_SearchLastState($sLaptop) Even though these are under different case scenarios the Func_SearchLastState is getting picked up as a duplicate function name. How can I use this function more than one in my script without getting the error?
-
Hi all, Can this function be modified to support @CRLF in the MsgBox's text? ; Move Message Box ; Author - herewasplato _MoveMsgBox(0, "testTitle", "testText", 0, 10) Func _MoveMsgBox($MBFlag, $MBTitle, $MBText, $x, $y) Local $file = FileOpen(EnvGet("temp") & "\MoveMB.au3", 2) If $file = -1 Then Return;if error, give up on the move Local $line1 = 'AutoItSetOption(' & '"WinWaitDelay", 0' & ')' Local $line2 = 'WinWait("' & $MBTitle & '", "' & $MBText & '")' Local $line3 = 'WinMove("' & $MBTitle & '", "' & $MBText & '"' & ', ' & $x & ', ' & $y & ')' FileWrite($file, $line1 & @CRLF & $line2 & @CRLF & $line3) FileClose($file) Run(@AutoItExe & " /AutoIt3ExecuteScript " & EnvGet("temp") & "\MoveMB.au3") MsgBox($MBFlag, $MBTitle, $MBText) FileDelete(EnvGet("temp") & "\MoveMB.au3") EndFunc;==>_MoveMsgBox Thanks
-
i have a file flower.txt with the name of the flowers and there picture location and information about that kind of flower. i wana cerat a gui that will display the flower picture and it information here is the script #include <Misc.au3> #include <EditConstants.au3> #include <Constants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <AVIConstants.au3> #include <TreeViewConstants.au3> #include <GuiComboBox.au3> #include <GuiTab.au3> #include <file.au3> #include <array.au3> Global $sfPath = 'flowers.txt' Global $aFlowers _FileReadToArray($sfPath,$aFlowers,$FRTA_NOCOUNT,'|') _ArrayColDelete($aFlowers,0) ;row 0 has no data so deleting $Form1 = GUICreate("Search Flower Name",320, 480) $input = GUICtrlCreateInput("", 60, 360, 209, 25) $idss = GUICtrlCreateButton("Search", 130, 400, 73, 65) GUISetState(@SW_SHOW) Func Searchf() Global $Fname = GUICtrlRead($input) For $iNo = 0 To UBound($aFlowers[0][0]) - 1 ; if $Fname = $aFlowers[$iNo][0] then MsgBox($MB_SYSTEMMODAL, "","Flower nfo", ""& $aFlowers[$iNo][1] &"") pic() EndIf Next EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $nMsg = $idss Searchf() EndSwitch WEnd func pic() For $iNo = 0 To UBound($aFlowers[0][0]) - 1 GUICtrlCreatePic($aFlowers[$iNo][2], 20, 30, 280, 280) Next EndFunc here is the flower.txt file |Hibiscus|Hibiscus is a hardy perennial which grows in variety of colors, sizes and fragrances. Actually they are tropical flowers which require ample sunlight and moisture to grow well. These flowers start blooming in late spring and continuously bloom through July and August.|C:\T-in\IMG\2.jpg |Lilies|There are different types of lily flowers which bloom in August including water lilies, tiger lilies and gold band lilies. Tiger lilies generate orange flowers having black spots. This lily blooms in delayed July and beginning of August. Gold band lily produce exotic white blooms. All varieties of lilies need enough space to grow and protection from summer sun.|C:\T-in\IMG\1.jpg |Turtlehead|Growing in humid areas, turtleheads are small flowers which bloom from July to September. They mostly produce flowers of white and pink color.|C:\T-in\IMG\3.jpg |Hydrangea|These are ever green bushes which produce flowers in different colors including white, purple, blue and pink. They are easy to grow bushes and can grow 3 to 10 feet tall. They require morning sun to grow but they should be protected from noon and afternoon sun.|C:\T-in\IMG\4.jpg |Dahlias|August proves to be the peak blooming season for dahlias. Dahlias come in colors like white, orange, yellow, red and purple. They can tolerate all types of soil and require full sun to grow.|C:\T-in\IMG\5.jpg am still trying to learn about how the ubound work and the _filereadtoarray