Jump to content

manit

Active Members
  • Posts

    73
  • Joined

  • Last visited

Everything posted by manit

  1. I downloaded controlviewer(source v0.2024.9.16). In it there is cv.au3 script which has lot of code . Do i have to use that ? I think , you are saying that my search parameter " [CLASS:Button; INSTANCE:1] " has to be fine-tuned .
  2. Please note that I used autoit window info tool to identify the ok button when audacity crash window had appeared . ControlGetHandle does not return any coordinates . mousemove needs coordinates . How can I get those ?
  3. Here is my code I am trying to press a button that comes up when audacity application crashes. To my surprise , autoit says it is present in a normal window also . How to highlight the button it has found ? #include <MsgBoxConstants.au3> AutoItSetOption ( "WinTitleMatchMode" , 2) Local $audwnd = WinWait("Audacity","",10) If $audwnd == 0 Then MsgBox($MB_ICONERROR, "Script_Info", "No window with title audacity found . Bye !") Else     Local $hButton = ControlGetHandle($audwnd, "", "[CLASS:Button; INSTANCE:1]")     If $hButton Then         MsgBox($MB_SYSTEMMODAL, "", "The handle of ok button in audacity is : " & $hButton)     EndIf EndIf Thanks.
  4. Edited my post with code tag (Also, i will remember in future). Thanks.
  5. Thanks Nine I wrote following code to get expected results #include <MsgBoxConstants.au3> #include <FileConstants.au3> Example() Exit(0) Func Example()         ; Wait 10 seconds for the xirrus window to appear.         Local $hWnd = WinWait("Xir", "", 10)         If $hWnd = 0 Then                 MsgBox($MB_SYSTEMMODAL, "", "Window with title Xir not found")                 Exit(1)         EndIf         ; Get data from window         Local $signal_value = ControlGetText($hWnd, "", "[NAME:labelSignalValue]")         If $signal_value = "" Then                 MsgBox($MB_SYSTEMMODAL, "", "Signal value not found in Xir window")                 Exit(3)         EndIf         Local $BSSID_value = ControlGetText($hWnd, "", "[NAME:labelBSSIDValue]")         If $BSSID_value = "" Then                 MsgBox($MB_SYSTEMMODAL, "", "BSSID value not found in Xir window")                 Exit(4)         EndIf         Local $channel_value = ControlGetText($hWnd, "", "[NAME:labelChannelValue]")         If $channel_value = "" Then                 MsgBox($MB_SYSTEMMODAL, "", "Signal value not found in Xir window")                 Exit(5)         EndIf         ; Show data obtained from window         MsgBox($MB_SYSTEMMODAL, "", "Signal: " & $signal_value & @CRLF & "BSSID: " & $BSSID_value & @CRLF & "channel: " & $channel_value)         ; Open file for overwriting         Local $hFileOpen = FileOpen("signal-bssid-channel-data.txt", $FO_OVERWRITE)         If $hFileOpen = -1 Then                 MsgBox($MB_SYSTEMMODAL, "", "An error occurred when writing the file.")                 Exit(2)         EndIf         ; Write data shown to file         FileWrite($hFileOpen, "Signal: " & $signal_value & @CRLF & "BSSID: " & $BSSID_value & @CRLF & "channel: " & $channel_value)         ; Close the handle returned by FileOpen.         FileClose($hFileOpen) EndFunc   ;==>Example I compiled au3 to exe file then relevant part of my batch file is @echo off get-data-from-xir-window-x86.exe if %errorlevel%==0 (    echo "SUCCESS"    echo "Data in signal-bssid-channel-data.txt" ) else if %errorlevel%==1 (    echo "ERROR"    echo "Xir window not found" ) else if %errorlevel%==2 (    echo "ERROR"    echo "Cannot open data file for writing signal bssid channel values" ) else (    echo "ERROR"    echo "signal or bssid or channel Values not found in Xir window" ) Let me know if there is better coding practice I should follow . Thanks.
  6. hi , I am using windows 11 OS . My aim is to get text from another window and save it in a file. Here is my target window (see xirrus.png) I want to capture ssid , bssid , channel and signal data of wireless section in it . I ran autoit info tool on that area and I got following details (see window-info.png) I want to save all data in a text file so that a batch file will extract values from text file . How can I accomplish this ? Thanks.
  7. I will try AutoIt3 Interpreter . Thanks .
  8. hi , I don't know exact word for it but say we run 'python' then we get a prompt in which we can run commands line by line. Similioarly , before writing a script in autoit , i want to try out commands then i will make a script which contains command relevant to my requirement. How is that possible ? Thanks.
  9. Hi, Here is my code Opt("WinTitleMatchMode", 2) Local $TextFileName = "Log-of-audacity-window.txt" If WinExists("Cross-Platform") Then $Logging = "Audacity« Cross-Cross-Platform Sound Editor window found" &@CRLF FileWrite($TextFileName, $Logging) Local $Cross-Platform_window_handle = WinGetHandle("Cross-Platform") $Logging = "Window handle is " &$Cross-Platform_window_handle &@CRLF FileWrite($TextFileName, $Logging) Local $found_win_title = ?? $Logging = "Window title is " &$found_win_title&@CRLF FileWrite($TextFileName, $Logging) EndIf Here, I am searching a window using a substring of title . Now I want to know the full title of window that was found . How can I do that ? Thanks.
  10. hi , I have written a script to simulate keypresses and click on some windows The work is repetitive. Here I activate 'foobar' and click on a place in it then press few down arrow keys . Then some keypresses in 'reboot' window ... (1)It sometimes happen that am external window pops up taking focus away from action being performed by script . As a result ,say, 'reboot' window does not appear . How should I bring scipt to run from beginning (of while loop) again ? (2)I used window info tool to find coordinates of place to click . Is it possible that window info tool keeps updating mouse coordinate even when I do not drag its finder ? (3)I would also like to add functionality to do an action on window 'new IP' , if found , in the infinite while loop . Please give directions. Thanks. #include <AutoItConstants.au3> HotKeySet("{ESC}", "dummy") AutoItSetOption("WinTitleMatchMode",2); Local $hWnd, $x, $y, $pos, $reponse While 1 $hWnd = WinGetHandle("foobar") $pos = WinGetPos($hWnd) $x = 360 ; $y = 77 ; WinActivate($hWnd) MouseClick("left", $pos[0] + $x, $pos[1] + $y) Send("{DOWN}") WinWaitActive($hWnd) Send("{DOWN}") WinWaitActive($hWnd) Send("{DOWN}") WinWaitActive($hWnd) Send("{DOWN}") WinWaitActive($hWnd) Send("{DOWN}") Send("{DOWN}") WinWaitActive($hWnd) WinWaitActive($hWnd) Send("{ENTER}") $reboot_window = WinWait("Reboot") WinWaitActive($reboot_window) Send("{TAB}") WinWaitActive($reboot_window) Send("{SPACE}") WinWaitActive($reboot_window) Send("{TAB}") WinWaitActive($reboot_window) Send("{DOWN}") Send("{DOWN}") WinWaitActive($reboot_window) Send("{TAB}") WinWaitActive($reboot_window) Send("{DOWN}") WinWaitActive($reboot_window) Send("{TAB}") WinWaitActive($reboot_window) Send("{SPACE}") Sleep(1000) $response = WinGetHandle("Reboot") $pos = WinGetPos($response) $x = 168 ; 530-362 $y = 258 ; 376-118 WinActivate($response) MouseClick("left", $pos[0] + $x, $pos[1] + $y) Sleep(50000) WEnd Func dummy() EndFunc ;==>dummy
  11. That is so stupid of me, I used the same variable i at two places .
  12. Sorry , I meant to say - when I give user input as 1,2-5,4,7-3,8,9 .I see that commands get run for 1,4,9. The code written above will pass commands to newly opened notepad window. I am unable to find any fault in my program. Can you help ?
  13. I wrote this program to accept a number separated comma list with allowance of range using startnumber-endnumber This program will help me to run same sequence of commands (which involve checking process ,contents of cfg file,pinging gateway after manipulating wan0,three-digit-number interface address) on different systems with unique IP as fed by user. $userinput = InputBox("VOIP IP separated by comma,give range using -", "") $ips = StringSplit($userinput,",") For $i = 1 To $ips[0] If StringInStr($ips[$i],"-") Then $vlan = StringSplit($ips[$i],"-") $startvlan = $vlan[1] $endvlan = $vlan[2] MsgBox(1,"range","start ip is "&$startvlan&" end ip is "&$endvlan) Else $startvlan = $ips[$i] $endvlan = $ips[$i] MsgBox(1,"ip","ip is "&$startvlan&" = "&$endvlan) Endif WinActivate ( "Untitled" ) For $i = $startvlan To $endvlan Step 1 Send("telnet 192.168.7."&$i&"{ENTER}") ;Sleep(1000) Send("root{ENTER}") ;Sleep(1000) Send("root{ENTER}") ;Sleep(1000) Send("ps | grep -i audio{ENTER}") ;Sleep(1000) Send("cat /tmp/CdotGponVoip.cfg | grep -i 2659{ENTER}") ;Sleep(1000) Send("ifconfig | grep -EA1 'wan0\.[0-9][0-9][0-9][{^}0-9]' {ENTER}") ;Sleep(1000) Send("pingip=$(ifconfig |sed -rn '/wan0.[0-9][0-9][0-9][{^}0-9]/{{}np{}}'|sed 's/inet addr:\(.*\) Bcast.*/\1/'){ENTER}") ;Sleep(1000) Send("echo $pingip{ENTER}") ;Sleep(1000) Send("pinggw=$( echo $pingip | sed -r 's/\.[0-9]$/\.1/'){ENTER}") ;Sleep(1000) Send("echo $pinggw{ENTER}") ;Sleep(1000) Send("ping -c 2 $pinggw{ENTER}") ;Sleep(1000) Send("exit{ENTER}") Msgbox(0,"Operation halted","Continue?") Next Next
  14. So I added line at the top 'Global $var' Now , all is well. thanks BrewManNH You are the most valuable penguin. Also , can you suggest any improvement in my program - like unnecessary use of particular variable , function or ways to optimize executable as refreshing takes a little time ?
  15. hi guys , I added refresh button #Include <File.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> Opt("WinTitleMatchMode", 4) Global $fClick = False Global $count = 0 Global $aCheck[4] $Gui = GUICreate("windows information", 1000, 650) $listview = GUICtrlCreateListView("check|count|handle|title|visible|number", 10, 10, 900, 600, $LVS_SORTASCENDING, $LVS_LIST) $hWndListView = GUICtrlGetHandle($listview) _GUICtrlListView_SetExtendedListViewStyle($hWndListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)) _GUICtrlListView_SetColumnWidth($hWndListView, 3, $LVSCW_AUTOSIZE_USEHEADER) Call("createtable") ;MsgBox ( 0 , "windows with some title/all level 1 " , $count & "/" & $var[0][0]) ReDim $aCheck[$count] _GUICtrlListView_RegisterSortCallBack($listview) $Button_1 = GUICtrlCreateButton("refresh", 910, 0, 90) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $listview _GUICtrlListView_SortItems($listview, GUICtrlGetState($listview)) Case $Button_1 Call("refreshtable") ;Run('notepad.exe') ; Will Run/Open Notepad EndSwitch ; If an item was double clicked If $fClick Then $fClick = False For $i = 0 To $count - 1 $fCheck = _GUICtrlListView_GetItemChecked($hWndListView, $i) If $fCheck <> $aCheck[$i] Then $aCheck[$i] = $fCheck Switch $fCheck Case True $fullrow = _GUICtrlListView_GetItemTextString($listview, $i) $individualelements = StringSplit( $fullrow , "|" , 2 ) $windownumber = $individualelements [ UBound($individualelements) - 1 ] $returned = WinSetState( $var[$windownumber][1], "", @SW_MINIMIZE ) ;MsgBox ( 0, "was window found " , $var[$windownumber][1] & " : " & $returned) Case False $fullrow = _GUICtrlListView_GetItemTextString($listview, $i) $individualelements = StringSplit( $fullrow , "|" , 2 ) $windownumber = $individualelements [ UBound($individualelements) - 1 ] $returned = WinSetState( $var[$windownumber][1], "", @SW_HIDE ) EndSwitch ExitLoop EndIf Next EndIf WEnd _GUICtrlListView_UnRegisterSortCallBack($listview) Func refreshtable() ;MsgBox(4096, "Test", "This box will time out in 10 seconds", 10) _GUICtrlListView_DeleteAllItems($listview) createtable() EndFunc ;refresh table Func createtable() $var = WinList() $count = 0 For $i = 1 to $var[0][0] $empty = StringRegExp ( $var[$i][0] , "\A\s*\z") if $empty = 0 Then $count = $count + 1 $everyitem = GUICtrlCreateListViewItem("nullemptyvoid|" & $count & "|" & $var[$i][1] & "|" & $var[$i][0] & "|" & BitAND( WinGetState($var[$i][1]), 2 ) & "|" & $i , $listview) GUICtrlSetData($everyitem,"") EndIf Next GUISetState() EndFunc ;refresh table Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK $fClick = True EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc
  16. It has been a while. Recently , I realized that internet connection can be checked by pinging a website . www.example.com is an ideal choice. It seems , yet the question remains as asked before.
  17. Can you suggest a way that in an infinite loop something is checked every time to exit if user has clicked a button ?
  18. #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> Global $fClick = True $hGUI = GUICreate("My GUI") ; will create a dialog box that when displayed is centered $btn1 = GUICtrlCreateRadio("START", 10, 10, 100, 50) $btn2 = GUICtrlCreateRadio("STOP", 110, 10, 50, 50) GUISetState(@SW_SHOW) ; will display an empty dialog box While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $btn1 Then _LetUsRunCommand() If $msg = $btn2 Then $fClick = False WEnd Func _LetUsRunCommand() While $fClick $command = 'cmd /c ping -n 1 www.google.com | find /i "reply"';<-Your command RunWait($command & ">>" & @ScriptDir & "output.txt", "", @SW_HIDE) $output = FileRead(@ScriptDir & "output.txt", FileGetSize(@ScriptDir & "output.txt")) ;FileDelete( @scriptdir & "output.txt") ;$Output now contain the Console output of $Command ;MsgBox(0, "Output of command read is : ", $output) WEnd EndFunc ;==>_LetUsRunCommand I was hoping that on selecting STOP button the pinging will end but the file output.txt kept growing
  19. I tried this #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> $hGUI = GUICreate("My GUI") ; will create a dialog box that when displayed is centered $btn1 = _GUICtrlButton_Create($hGUI, "START", 10, 10, 100, 50, $BS_AUTORADIOBUTTON) $btn2 = _GUICtrlButton_Create($hGUI, "STOP", 110, 10, 50, 50, $BS_AUTORADIOBUTTON) GUISetState(@SW_SHOW) ; will display an empty dialog box While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $btn1 Then _LetUsRunCommand() WEnd Func _LetUsRunCommand() $command="cmd /c dir c: /s";<-Your command RunWait($command & ">" & @scriptdir & "output.txt","",@sw_hide) $output = FileRead( @scriptdir & "output.txt",FileGetSize(@scriptdir & "output.txt")) ;FileDelete( @scriptdir & "output.txt") ;$Output now contain the Console output of $Command MsgBox ( 0 , "Output of command read is : " , $output) EndFunc Neither output.txt gets created in current folder nor message box appears on selecting start.
  20. I have requested to bayden & also found inline command input in free commander 2009.02b Must say that it does not provide automatic-file completion leave alone , cycling among alternatives.
  21. So far I created window with start & stop buttons . #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> $hGUI = GUICreate("My GUI") ; will create a dialog box that when displayed is centered $btn1 = _GUICtrlButton_Create($hGUI, "START", 10, 10, 100, 50, $BS_AUTORADIOBUTTON) $btn2 = _GUICtrlButton_Create($hGUI, "STOP", 110, 10, 50, 50, $BS_AUTORADIOBUTTON) GUISetState(@SW_SHOW) ; will display an empty dialog box While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Somewhere I also saw $Command="cmd /c dir c: /s";<-Your command RunWait($command & ">" & @scriptdir & "output.txt","",@sw_hide) $OutPut = FileRead( @scriptdir & "output.txt",FileGetSize(@scriptdir & "output.txt")) FileDelete( @scriptdir & "output.txt") ;$Output now contain the Console output of $Command which will help me to store command output in variable. How do I associate a function which runs on selecting one of those buttons ?
  22. Sorry , that looked like asking for bespoke code with theme as input . I will try & show scaffolding I come up with .
  23. hi , I intend to write following script (because I want to calculate the availability of internet on my connection . It is so intermittent that drives me crazy .) loop forever { ping -n 1 www.google.com | find /i "reply" #If above command gives string as output . It will be like #Reply from 173.194.36.19: bytes=32 time=44ms TTL=54 #Had there been no internet then above command would produce no output because #Ping request could not find host www.google.com. Please check the name and try again. increment 'tries' variable by 1 increment 'success' variable by 1 if reply received as told above do nothing for 1 minute if user has pressed stop checkmark button then wait till user unselects it } The GUI I can imagine is stop checkmark & two greyed out text field showing number of attempts & sucesses . Please suggest .
  24. sleepydvdr , please reply.
  25. i am using free commander 2009.02b I see on pressing ctrl+d , a dosbox opens up for current folder but not an integrated commandline text input box as you have said.
×
×
  • Create New...