Jump to content

Yodavish

Active Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by Yodavish

  1. @FrancescoDiMuro I'm not familiar with that, but I'll look into it.
  2. @FrancescoDiMuro Ran out of ideas, so I tried to force by sending it keystrokes Send("{TAB}") Send("{TAB}") Send("{TAB}") Send("{TAB}") Send("{d}") Send("{Enter}") This does the trick.
  3. @FrancescoDiMuroI tired that as well removing the space, the listbox changes ID as well. Since there is code before it that opens the window that contains the listbox, I suppose the "ID" wouldn't be very consistent.
  4. @FrancescoDiMuro Thanks for the suggestion, I did an "If @error Then MsgBox() exit..." behind both the WinGetHandle and ControlGetHandle and I'm failing on the "ControlGetHandle". I've tried replacing the "controlID" portion with "[CLASS: WindowsForms10.LISTBOX.app.0.33c0d9d; INSTANCE: 1]" "[ID: 2363260]" " [NAME:TemplateList]" But it continues to fail on the control handle, I have the update code below: $hWindow = WinGetHandle("[CLASS:WindowsForms10.Window.8.app.0.33c0d9d]") If @error Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when trying to retrieve the WINDOW handle of Fusion.") Exit EndIf consoleWrite('handle window: ' & $hWindow & @CRLF) $hControl = ControlGetHandle($hWindow, "", "[ID: 2363260]") If @error Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when trying to retrieve the CONTROL handle of Fusion.") Exit EndIf consoleWrite('handle control: ' & $hControl & @CRLF) ControlCommand($hWindow, "", $hControl, "SelectString", "Dictated in Dragon") Any thoughts?
  5. Hello barely novice user for Autoit here. I'm trying to select an item (called "Dictated in Dragon") in a listbox from a 3rd party app and eventually within the same window click on a button to close this window, however, all my attempts have failed to do so. This is the code I have currently that stops at selecting the item first. $hWindow = WinGetHandle("Insert Audio Normal - Double Click or Press Enter to Select.") $hControl = ControlGetHandle($hWindow, "", "[CLASS:WindowsForms10.LISTBOX.app.0.33c0d9d; INSTANCE:1]") ControlCommand($hWindow, "", $hControl, "SelectString", "Dictated in Dragon") And below is Summary of the AutoIt Window Info of the window I'm trying to select the item from: Any help on this would be greatly appreciated!
  6. Thanks @Nine I tried your suggestion and that lead me to see that the issue was due to the fact that _IECreate has issues with creating intranet addresses. So I modified the code and I think it works now, but I'll continue to test it. Adjust code below: Func moveProTrackerWindow() ; Code below was copied from AutoIt Help by searching "_WinAPI_EnumDisplayMonitors" and altered slightly Local $aPos, $aData = _WinAPI_EnumDisplayMonitors() If IsArray($aData) Then ReDim $aData[$aData[0][0] + 1][5] For $i = 1 To $aData[0][0] $aPos = _WinAPI_GetPosFromRect($aData[$i][1]) If($aPos[0] <> 0) Then For $j = 0 To 3 Switch $j Case 0 ; index for X-position of secondary monitor $secondMonitorPosition = $aPos[$j] Case 2 ; index for width of secondary monitor $secondMonitorWidth = $aPos[$j] Case 3 ; index for height of secondary monitor $secondMonitorHeight = $aPos[$j] EndSwitch Next EndIf Next EndIf ;WinActivate($proTrackerWindowTitle) ShellExecute("iexplore.exe", "about:blank") sleep(3000) $oIE = _IEAttach("about:blank", "url") _IENavigate($oIE, "intranet URL address") Local $hWnd = _IEPropertyGet($oIE, "hwnd") ; Checks to see if proTracker is maximized If BitAND(WinGetState($hWnd), 32) Then ;consoleWrite ("Maximized" & @CRLF) ; Gets proTracker position Local $aPos = WinGetPos($hWnd) ;consoleWrite ("Pos: " & $aPos[0] & @CRLF) ; Checks if the position is at the second monitor If $aPos[0] <> $secondMonitorPosition Then ;consoleWrite ("Maximized but position is wrong" & @CRLF) WinMove($hWnd, "", $secondMonitorPosition, 0,$secondMonitorWidth, $secondMonitorHeight) WinWait($hWnd) WinSetState($hWnd, "", @SW_MAXIMIZE) EndIf Else ;consoleWrite ("Not Maximized" & @CRLF) WinMove($proTrackerWindowTitle, "", $secondMonitorPosition, 0, $secondMonitorWidth, $secondMonitorHeight) WinWait($hWnd) WinSetState($hWnd, "", @SW_MAXIMIZE) EndIf $proTrackerMovedFlag = True ;_ArrayDisplay($aData, '_WinAPI_EnumDisplayMonitors') ; displays monitor numbers consoleWrite("Width: " & $secondMonitorWidth & " Height: " & $secondMonitorHeight & " Second Monitor Position: " & $secondMonitorPosition & @CRLF) EndFunc
  7. I have this AutoIt script executable in the Windows 10 startup folder, along with 3 other things in the startup folder: Internet Explorer (IE ) to a specific webpage, 3rd party application for the client to use, and another AutoIt script. Once a user logs into Windows, one of the many tasks the AutoIt script will do is a loop to check if the specific IE title exists and move it to the secondary monitor, however, it always fails. Either, it doesn't move it at all or I see a gray blank IE page on the secondary monitor. This only occurs on the first login, if I close the AutoIt.exe down and re-run the AutoIt.exe again it will then move the IE over correctly. Other things I've tried so far but have failed: Tested different times to delay, sleep(10000), before the script goes into the while Adding a RunWait() to open up the specific page in question first before the while Here is specific code in question, I can add the whole thing if needed: Global Const $proTrackerWindowTitle = IniRead("gross.ini", "default", "proTrackerWindowTitle", "NONE") ; The title of ProTracker window Global $proTrackerMovedFlag = '' While 1 ;---------------------------------------------------------- ; Moves IE Window to secondary monitor only once ; $proTrackerMovedFlag = '' is the one time trigger ;---------------------------------------------------------- If WinExists($proTrackerWindowTitle) and $proTrackerMovedFlag = '' Then moveProTrackerWindow() EndIF Sleep(100) ; Sleep to reduce CPU usage WEnd ;--------------------------------------------------------------- ; Functions ;--------------------------------------------------------------- Func moveProTrackerWindow() Local $aPos, $aData = _WinAPI_EnumDisplayMonitors() If IsArray($aData) Then ReDim $aData[$aData[0][0] + 1][5] For $i = 1 To $aData[0][0] $aPos = _WinAPI_GetPosFromRect($aData[$i][1]) If($aPos[0] <> 0) Then For $j = 0 To 3 Switch $j Case 0 ; index for X-position of secondary monitor $secondMonitorPosition = $aPos[$j] Case 2 ; index for width of secondary monitor $secondMonitorWidth = $aPos[$j] Case 3 ; index for height of secondary monitor $secondMonitorHeight = $aPos[$j] EndSwitch Next EndIf Next EndIf $hWnd=WinActivate($proTrackerWindowTitle) ; Checks to see if proTracker is maximized If BitAND(WinGetState($hWnd), 32) Then ;consoleWrite ("Maximized" & @CRLF) ; Gets proTracker position Local $aPos = WinGetPos ($proTrackerWindowTitle) ;consoleWrite ("Pos: " & $aPos[0] & @CRLF) ; Checks if the position is at the second monitor If $aPos[0] <> $secondMonitorPosition Then ;consoleWrite ("Maximized but position is wrong" & @CRLF) WinMove($hWnd, "", $secondMonitorPosition, 0,$secondMonitorWidth, $secondMonitorHeight) WinWait($hWnd) WinSetState($hWnd, "", @SW_MAXIMIZE) EndIf Else ;consoleWrite ("Not Maximized" & @CRLF) WinMove($hWnd, "", $secondMonitorPosition, 0, $secondMonitorWidth, $secondMonitorHeight) WinWait($hWnd) WinSetState($hWnd, "", @SW_MAXIMIZE) EndIf $proTrackerMovedFlag = True ;_ArrayDisplay($aData, '_WinAPI_EnumDisplayMonitors') ; displays monitor numbers consoleWrite("Width: " & $secondMonitorWidth & " Height: " & $secondMonitorHeight & " Second Monitor Position: " & $secondMonitorPosition & @CRLF) EndFunc
  8. Hello, I have a current script that is being used to do several tasks on 8 different workstations, but I want to add a one time check if Internet Explorer is open and have it moved to the "non-main screen monitor". Problem is, each station has 2 monitors, where the main screen can be on different sides. I'm not sure what is the best way to do this, any suggestions on to start this?
  9. @Nine Unfortunately, that bit of code was given to me as I didn't write it. I wrote the primary script it calls at the end and all the batch files.
  10. @Nine Yep only when the user first logs into windows, I've placed the script in the Windows startup folder to run once to run all those batch files.
  11. OK, I have just been informed of some crucial information that I was unaware of before. This issue only occurs when the user first logins, which then points me to a different au3 script that must be the problem. As it is responsible for running a few batch files, then it will launch the 3rd party application and calls the script that I've been trying to troubleshoot. After 30 minutes the Case # window will not work. But, this is never a problem again, when the user closes both the 3rd party ap and script and reopens them again. Even with an hour break between it works still. All it does is run scripts with admin rights. So I'm not sure why it would cause this issue. The initial launch script is below: ;Elevate with the Admin account. **** DO NOT MODIFY THIS CODE BLOCK, IT IS FOR MAKING THE SCRIPT RUN AS ADMIN **** If @UserName <> $sAdminUser And Not IsAdmin() Then     $sParameters = ""     If Not @Compiled Then         $sParameters = ' "' & @ScriptFullPath & '"'     EndIf     If RunAs($sAdminUser, $sDomain, $sAdminPassword, $iLogOnFlag, @AutoItExe & $sParameters) Then         Exit     Else         Exit MsgBox(16 + 262144, "ERROR!", "Unable to run under administrator account.")     EndIf EndIf ;Run with Admin Token in Windows Vista and Higher.  **** DO NOT MODIFY THIS CODE BLOCK, IT IS FOR MAKING THE SCRIPT RUN AS ADMIN **** If @UserName = $sAdminUser And Not IsAdmin() And Not StringRegExp(@OSVersion, "_(XP|200(0|3))") Then     $sParameters = ""     If Not @Compiled Then         $sParameters = '"' & @ScriptFullPath & '"'     EndIf     If ShellExecute(@AutoItExe, $sParameters, "", "runas") Then         Exit     Else         Exit MsgBox(16 + 262144, "ERROR!", "Unable to elevate to Admin due to UAC.")    EndIf EndIf $fusionServerNameCmd = "cmd.exe /c sc queryex type= service state= all | find /i ""SERVICE_NAME: FUSION"" > fusionServiceName.txt" RunWait($fusionServerNameCmd, @ScriptDir) $cleanFusionFoldersCmd = "cmd.exe /c "& @ScriptDir & "\cleanFusionFolder.bat" RunWait($cleanFusionFoldersCmd, @ScriptDir) $setFusionFilesCmd = "cmd.exe /c "& @ScriptDir & "\setFusionFiles.bat" RunWait($setFusionFilesCmd, @ScriptDir) $setDefaultSound = "cmd.exe /c "& @ScriptDir & "\setDefaultSound.bat" RunWait($setDefaultSound, @ScriptDir) Run("C:\Program Files (x86)\Fusion Dictate\FusionDictate.exe") Do    Sleep(250) Until WinExists("Case #") ; Shell execute used to ensure shortcut.lnk works and is able to fetch its ini file ShellExecute("C:\gross\Gross shortcut.lnk")
  12. @Nine Yea, I can provide the entire script but having the 3rd party application called Fusion Dictate is different story.
  13. @seadoggie01 So this is where I'm not entirely sure which one is the bug, however, when it's idle for 30 minutes, I've closed down the Au3 script and then just manually enter or scan in the data to the 3rd party application "Case #" and it works as normal. But when I open up the script again, it still won't send the data or hit the enter key. The best method so far is to close down the 3rd party application and opening it up again for everything to work. As a possible workaround, I'm thinking of doing an idle time check and just sending a blank enter key to the Case # and if possible delete that Case to open up the "Case #" again. My idea below: Global $idleFlag = False While 1    If WinExists($fusionWindowTitle) and WinExists($fusionCaseNumWinTitle) Then       If $idleFlag == False Then          $idleTimeStart = TimerInit()          consoleWrite("IDLE TIME START: "& $idleTimeStart & @CRLF)          $idleFlag = True       Else         $fDiff = TimerDiff($idleTimeStart)         If $fDiff > '1500000' Then ; <== Greater than 25 minutes             WinActivate($fusionCaseNumWinTitle, "")             WinWaitActive($fusionCaseNumWinTitle)             Send("{ENTER}")             $idleFlag = False         EndIf       EndIf    EndIF WEnd
  14. @Danp2 Thanks for the reply, everything runs fine when the system has not been idle for 30 minutes. But when it has been 30+ minutes, the "WinActivate("Case #")" i.e. WinActivate($fusionCaseNumWinTitle, "") works as I can see the handle being properly returned. However, the data will not be inputted nor will the "Enter" key be sent. I've tried hard coding in the "ControlID" after it's been idle for 30 minutes as well, but it still will not work. The code I've tried: ControlSetText("Case #","", "[ID:2362094]", $caseTxt) Send("{ENTER}") I've also tried giving the ControlSetText the handle, but none of these work for the 30-minute idle issue. $hwnd = WinActivate("Case #", "") ControlSetText($hwnd,"", "[ID:2362094]", $caseTxt) Send("{ENTER}") Here is the current Control ID of the field in question. One thing to note is that the "Case #" windows will open and close depending on the end-user as they perform a task. This produces a new Control ID each time a "Case #" window appears and since I didn't have a reliable way to get that control ID, I used the ( TEXT = "" ) which I found from the AutoIt Window Info above. This is always consistent rather than CLASS or CLASSNN which can also change when the 3rd party application is loaded for each end-user. Hence the code below: ControlSetText("Case #","", "", $data) My reasoning for this was from the AutoIT Help documentation listed under "Controls" says TEXT is an option to use. I've tried also to use the "CLASSNN" as well, but yet again on when the application has been idle for 30 minutes it will not send the data or hit enter. $hwnd = WinActivate("Case #", "") ControlSetText($hwnd,"", "[CLASSNN:WindowsForms10.Window.8.app.0.33c0d9d1]", $caseTxt) Send("{ENTER}")
  15. My AutoIt script works fine, for the most part, however, if it goes idle for roughly 30 minutes, it will won't be able to send data to a 3rd party application window titled, "Case #". The problem lies within the function "SendFusion", it's able to see the handle for the "WinActivate" and "WinWaitActivate" (I've also tried putting in 10 seconds in the WinWaitActivate as well, doesn't work). However, if we have been idle, it will always fail to send data afterward. On what I've tried so far: "Send" function with the data and a {ENTER} i.e. Send($CaseTxt & "{ENTER}"), this won't even hit the enter key ControlSetText, tried passing the handle from WinActivate, using the title "Case #" that was copied directly from the Autoit Window Info, hard coding the title, Using CLASS:WindowsForms10... always returns a 0 ControlCommand (same as above) always returns a 0 ControlGetFocus always returns a 0 ControlFocus, always returns a 0 Creating a new and simple Au3 script that just sends data to "Case #", also fails NOTE: If I close the Au3 script and just scan the data directly into the "Case #" or even type it, it works fine with no issues. I'm confused as to why it would not work after a long idle period? Below are the essential parts of the script, I can provide the entire thing if needed. Any suggestions would be greatly appreciated! #include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <Process.au3> #include <Misc.au3> #include <IE.au3> ;--------------------------------------------------------------- ; Only one instance can run ;--------------------------------------------------------------- If _Singleton("gross.exe", 1) = 0 Then MsgBox($MB_SYSTEMMODAL, "Warning", "Gross.exe is already running. Please exit the existing version first (check the icons in the lower right corner of your screen) before running it again.") Exit EndIf ;--------------------------------------------------------------- ; AutoIt Options ;--------------------------------------------------------------- Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Opt("WinWaitDelay", 0) ; Alters how long a script should briefly pause after a successful window-related operation. Time in milliseconds to pause (default=250). Opt("WinTextMatchMode", 1) ; Alters the method that is used to match window text during search operations. 2 = Quick mode Opt("SendKeyDelay", 0) ; Alters the length of the brief pause in between sent keystrokes. A value of 0 removes the delay completely. Time in milliseconds to pause (default=5). if ($fusionWindowTitle="NONE" or $fusionCaseNumWinTitle="NONE" or $appWindowTitle="NONE" or $winActivateTimeout="NONE" or $winCloseTimeout="NONE" or $winWaitTimeout="NONE" or $pdfViewerWidth="NONE" or $pdfViewerHeight="NONE" or $pdfViewerLeft="NONE" or $pdfViewerWindowName="NONE" or $pdfViewerExeName="NONE" or $pdfUrl="NONE" or $pdfDownloadCommand="NONE") Then Msgbox(0,"ERROR", "gross.ini is missing or does not contain all settings. Please contact Help Desk with this information") Exit -1 EndIf ;--------------------------------------------------------------- ; application settings/constants ;--------------------------------------------------------------- Global Const $[VARIABLE] = IniRead("gross.ini", "default", "[TitleOfVariable]", "NONE") Global Const $[VARIABLE] = IniRead("gross.ini", "default", "[TitleOfVariable]", "NONE") Global Const $[VARIABLE] = IniRead("gross.ini", "default", "[TitleOfVariable]", "NONE") Global Const $[VARIABLE] = IniRead("gross.ini", "default", "[TitleOfVariable]", "NONE") ;--------------------------------------------------------------- ; create the main window ;--------------------------------------------------------------- Local $mainWindow = GUICreate($appWindowTitle, 380, 190) ; create the main GUI window GUISetOnEvent($GUI_EVENT_CLOSE, "handleCloseClick") ; when the click the windows close button call handleCloseClick() WinSetOnTop($appWindowTitle, '', 1) ; Sets main GUI always on top ;--------------------------------------------------------------- ; create the controls on the main window ;--------------------------------------------------------------- Local $okButton = GUICtrlCreateButton("OK", 160, 160, 54,24) ; create OK button GUICtrlSetOnEvent($okButton, "validateInput") ; when they click ok, call handleInputProcessRequest() GUICtrlCreateLabel("Scan Input", 10, 10) ; create a label Global $inputScan = GUICtrlCreateInput("", 10,134,358) ; create the input scan box GUICtrlSetOnEvent($inputScan, "validateInput") ; when they press enter in the scan input box, call handleInputProcessRequest() GUICtrlSetState($inputScan,$GUI_FOCUS) ; automatically sets focus on the input field GUISetState(@SW_SHOW) ; main GUI loop that runs at all times ;--------------------------------------------------------------- While 1 ;---------------------------------------------------------- ; If sumatraPDF active, resets focus back to GUI ;---------------------------------------------------------- If WinActive($pdfViewerWindowName) Then consoleWrite('While Loop sumatraPDF was active' & @CRLF) setMainWindow() ;---------------------------------------------------------- ; After data sent to ProTracker, check for mismatch ; save button to trigger the event handler when clicked ;---------------------------------------------------------- ElseIf WinActive($proTrackerWindowTitle) Then $ie = _IEAttach("ProTracker") $mismatchButton = _IEGetObjByName($ie, $proTrackerMisMatchButtonId) $oEvent = ObjEvent($mismatchButton, "mismatchButton_") If @error Then setMainWindow() ;--------------------------------------------------------------------- ; If Fusion is prompting for the case #, focus back to main GUI input ; If second GUI 'Unknown' detect do nothing ;--------------------------------------------------------------------- ElseIf WinExists($fusionWindowTitle) and WinExists($fusionCaseNumWinTitle) and Not WinActive($mainWindow) and Not WinExists('Unknown Input') Then setMainWindow() EndIF ;--------------------------------------------------------------------- ; Checks if $processFlag = Done, if so, shows PDF viewer and clears ; processFlag for next iteration ;--------------------------------------------------------------------- IF WinExists($pdfViewerWindowName) and $processFlag == 'Done' Then WinSetState ($pdfViewerWindowName, '', @SW_SHOW) $processFlag = '' setMainWindow() EndIF Sleep(100) ; Sleep to reduce CPU usage WEnd Func handleInputProcessRequest($input) $processFlag = True Local $hTimer = TimerInit() consoleWrite('> handleInputProcessRequest: ' & @CRLF) Local $idInput = identifyInput($input) ; Select a proccess to run based on id input Select Case $idInput = "container" ; regex that captures only the case number $caseTxt = StringUpper(StringRegExpReplace($strippedInputData, '\??(\w*\d*-\d*|\d*).*$','$1')) If WinExists($fusionWindowTitle) and WinExists($fusionCaseNumWinTitle) Then sendProTracker(StringUpper($strippedInputData)) sendFusion($caseTxt) ; gets pdf for sumatraPDF in seperate script, since that function is the slowest Run("viewPDF.exe " & $caseTxt) ;getSumatraPDF($caseTxt) $lastCaseNum = $caseTxt Else ; Checks to make sure the previous "Container" case num is the same ; to the current Container case num, before sending to ProTracker If($lastCaseNum <> $caseTxt) Then ; If not the same case number send alert sound SoundPlay("error.wav") Else sendProTracker($strippedInputData) EndIf EndIf Case $idInput = "user" sendProTracker($strippedInputData) Case $idInput = "cassette" sendProTracker(StringUpper($strippedInputData)) Case $idInput = "unknown" selectUnknown() EndSelect Local $fDiff = TimerDiff($hTimer) $processFlag = 'Done' consoleWrite('> handleInputProcessRequest Completed Total time: ' & $fDiff & ' ' &@CRLF&@CRLF&@CRLF) EndFunc Func sendFusion($caseTxt)     Local $hTimer = TimerInit()     consoleWrite('+ sendFusion initiated: ' & $caseTxt & @CRLF)     If $caseTxt = "" Then         MsgBox(0, "Error", "Not a valid case number")     Else         ;$fusionCaseNumWinTitle = "Case #"         $retVal1 = WinActivate($fusionCaseNumWinTitle, "")         consoleWrite("ReturnValue WinActivate " & $retVal1 & @CRLF)         $retVal2 = WinWaitActive($fusionCaseNumWinTitle,"",$winActivateTimeout)         consoleWrite("ReturnValue WinWaitActive: " & $retVal2 & @CRLF)         $retVal3 = ControlSetText($fusionCaseNumWinTitle, "", "", $caseTxt)         ;$retVal3 = ControlCommand($fusionCaseNumWinTitle, "", "", "EditPaste", $caseTxt)         consoleWrite("ReturnValue ControlSetText: " & $retVal3 & @CRLF)         ;Send($caseTxt & "{ENTER}")         WinWaitClose($fusionCaseNumWinTitle, "", $winCloseTimeout)         consoleWrite('+ sendFusion WinWaitClose: ' & @CRLF)     EndIf     Local $fDiff = TimerDiff($hTimer)     ConsoleWrite('+ sendFusion Completed Total time:' & $fDiff & ' ' & @CRLF) EndFunc Console logs from the SciTLE Window (x86) Info matches the correct handle for the WinActivate and WinWaitActivate Window Control (x86) Info, I've tried the CLASS, the ID, also I just noticed that the "handle" in "Control" and "Window" appear to be different as well. So far the only work-around is to close down the 3rd party application and the AutoIt script, re-open them and it works all completely fine. But this is a pain for the end-user since it's all touch screen and it slows down their workflow, which they can be extremely sensitive about.
  16. I have 2 questions both are related in the same area of my script. First, the script will check for a specific Internet Explorer title is active if so, it forces the focus back to GUI window input box. The one time it doesn't is when it detects an elemental name within a modal popup. When this does happen, it will go to an event handler to wait for a button to be clicked and then shift focus back to the GUI window input box. This works fine when the AutoIt script is first launched with a refreshed browser since the "_IEGetObjByName" is unable to find the element name in the modal pop up, the @error occurs. However, once the modal pop up does occur, AutoIt will no longer send the focus back to the main GUI when the specific browser is active. I'm sure there is a better way than to detect for the specific element name within the modal? But I'm not sure. Here is the core AutoIt script that I'm speaking of: While 1    If WinActive($proTrackerWindowTitle) Then       ConsoleWrite('+ While loop ProTracker active detected! ' & @MSEC & @CRLF)       $ie = _IEAttach("ProTracker")       ConsoleWrite('+ While loop ProTracker _IEAttach! ' & @MSEC & @CRLF)       $mismatchButton = _IEGetObjByName($ie, $proTrackerMisMatchButtonId)       ConsoleWrite('+ While loop ProTracker _IEGetObjByName ' & @MSEC & @CRLF)       $oEvent = ObjEvent($mismatchButton, "mismatchButton_")       If @error Then setMainWindow()    EndIf    Sleep(100) ; Sleep to reduce CPU usage WEnd Func mismatchButton_onclick($oEvtObj) ConsoleWrite('_MY_EVENT_HANDLER_onclick: ' & $oEvtObj & @CRLF) setMainWindow() EndFunc Func setMainWindow() consoleWrite("setMainWindow initiated: " & @CRLF) ; resets focus back to main GUI window WinActivate($mainWindow) consoleWrite("setMainWindow WinActivate: " & @MSEC & @CRLF) $hWnd = WinWait($mainWindow) consoleWrite("setMainWindow WinWait: " & @MSEC & @CRLF) WinSetOnTop($hWnd, "", $WINDOWS_ONTOP) consoleWrite("setMainWindow WinSetOnTop: " & @MSEC & @CRLF) ControlFocus($hWnd, "", $inputScan) consoleWrite("setMainWindow complete: " & @MSEC & @CRLF) EndFunc Second, when the modal does pop up and I click the mismatched button, the Autoit event handler sends it 3-4 times. Is this correct? How can I reduce it to only when it clicks once? Here are the SciLite Logs of the event handler: _MY_EVENT_HANDLER_onclick: 0 setMainWindow initiated: setMainWindow WinActivate: 042 setMainWindow WinWait: 053 setMainWindow WinSetOnTop: 053 setMainWindow complete: 053 _MY_EVENT_HANDLER_onclick: 0 setMainWindow initiated: setMainWindow WinActivate: 053 setMainWindow WinWait: 063 setMainWindow WinSetOnTop: 063 setMainWindow complete: 063 _MY_EVENT_HANDLER_onclick: 0 setMainWindow initiated: setMainWindow WinActivate: 064 setMainWindow WinWait: 075 setMainWindow WinSetOnTop: 075 setMainWindow complete: 075
  17. @Danp2 Ah I solved it since you mentioned a possible exit immediately before the event is captured, I decided to move this portion of the code up in my while loop and it now triggers the event properly when the browser is active. Thanks everyone for your help. I'll need to put consoleWrites all on my functions to see the order of which occur to see the order of it properly.
  18. @Nine I've updated my code and tried to run in on Windows 7, however, it no longer works here, but I'll try it on Windows 10 and check. Below is the code: $ie = _IEAttach("Website Title") ; Also tried passing the handle here $objElement= _IEGetObjById ($ie, "elementId") Local $oDocument = $ie.document consoleWrite('ButtonElement: ' IsObj($objElement) & @CRLF) Global $oEvent = ObjEvent($oDocument, "_MY_EVENT_HANDLER_", "HTMLDocumentEvents2") ;if @error <> 0 Then MsgBox(0,"ERROR DETECTED",@error) ;ConsoleWrite('ObjEvent: ' & IsObj($oEvent) & @CRLF
  19. @Danp2 Thanks, I've modified the consoleWrite and added and a @error for a popup msgbox under the objEvent but didn't receive any msgbox either. My code is below: If WinActive("Website Title - Internet Explorer") Then $ie = _IEAttach("Website Title") ; Also tried passing the handle here $objElement= _IEGetObjById ($ie, "elementId") consoleWrite('ButtonElement: ' IsObj($objElement) & @CRLF) local $oEvent = ObjEvent($objElement, "_MY_EVENT_HANDLER_") if @error <> 0 Then MsgBox(0,"ERROR DETECTED",@error) ConsoleWrite('ObjEvent: ' & IsObj($oEvent) & @CRLF EndIf Func _MY_EVENT_HANDLER_onclick($oEvtObj) ConsoleWrite('_MY_EVENT_HANDLER_onclick: ' & IsObj($oEvtObj) & @CRLF) setMainWindow() ; sets focus back to main GUI EndFunc ButtonElement: 1 ObjEvent: 1 I tested it on my Windows 7 desktop to compare: ButtonElement: 1 ObjEvent: 1 _MY_EVENT_HANDLER_onclick: 0 I'm open to other suggestions to get this to work, if I can't use IE from Windows 10?
  20. @Nine Thanks for the reply, I added some consoleWrites to look at each of the output variables but it didn't show me anything and it still won't run on Windows 10. When I click on the button that's related to the handler, nothing for the SCILite output. I'm still relatively new to AutoIt, so please let me know if I can log this better somehow. My code and the results in the SCILite console are below: If WinActive("Website Title - Internet Explorer") Then $ie = _IEAttach("Website Title") ; Also tried passing the handle here $objElement= _IEGetObjById ($ie, "elementId") consoleWrite('ButtonElement' & $objElement & @CRLF) local $oEvent = ObjEvent($objElement, "_MY_EVENT_HANDLER_") ConsoleWrite('ObjEvent' & $oEvent & @CRLF) EndIf Func _MY_EVENT_HANDLER_onclick($oEvtObj) ConsoleWrite('_MY_EVENT_HANDLER_onclick' & $oEvtObj & @CRLF) setMainWindow() ; sets focus back to main GUI EndFunc >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\gross\Gross.au3"     ButtonElement ObjEvent >Exit code: 0    Time: 47.19
  21. I have this AutoIt script that works on Windows 7. However, when I test it on Windows 10, the objEvent will not execute the function it's supposed to call. So I have a webpage the script will check if it is active, then it will search if a popup button exist (elementId), if so, assign it to the event handler so that when that button is clicked, then handler function will move the focus back to the main GUI again. If WinActive("Website Title - Internet Explorer") Then    $ie = _IEAttach("Website Title")    $objElement= _IEGetObjById ($ie, "elementId")    local $oEvent = ObjEvent($objElement, "_MY_EVENT_HANDLER_") EndIf Func _MY_EVENT_HANDLER_onclick($oEvtObj)     msgbox(0,"Alert Window", "Button Clicked!") setMainWindow() ; sets focus back to main GUI EndFunc I've verified, on Windows 10, that it does see the object element. But it will not trigger the event. Could it be related to some timing issues due to Windows 10 Internet Explorer over Windows 7 Internet Explorer? Windows 7 IE version 11.0.9600.19507 Windows 10 IE version 11.418.18362.0 AutoIt v 3.3
  22. Hello, I'm writing an AutoIt script that will parse scanned data and depending on the data, it will perform certain actions. Currently, I have it when it detects a "user" barcode it will switch focus to an always-open IE browser (by title) to submit that user data into a single input field. This works, if the focus is still in the input field, however, if I remove focus from the input field, I can't get the code to focus back on the element id before setting the value to be submitted. Here is the portion of the code that is not working: Func sendProTracker($input) Global $ie = WinActivate("ProTracker - Internet Explorer") ;$proTrackerInput = _IEGetObjById($ie,"input-scan") ;$sInnerText = _IEPropertyGet($proTrackerInput, "innertext") ;_IEAction($sInnerText, "focus") Send($input & "{ENTER}") EndFunc This is the HTML input field I'm trying to access, there is div around it. <input id="input-scan" class="scanInput form-control" type="text" placeholder="">
  23. Ok, I got it to work! While 1 HotKeySet("{ENTER}", checkBrowser) ... ;additional code WEnd Func checkBrowser()    ; Check is SumatraPDF is active    If WinActive("SumatraPDF") Then       SoundPlay("error.wav")    Else       ; Disables the HotKeySet func for the remaining of this one loop       HotKeySet("{ENTER}")       Send("{ENTER}")    EndIf EndFunc
  24. @TheXman I have GUI with an input that the user can scan in a 1D barcode. The barcode is pushed to 2 separate applications, one opens the PDF in the SumatraPDF and the other in a 3rd party application where the user can perform some recording task. The user typically will not look at the screen when they are scanning (pretty standard until they start their recording task), so they want me to check if the SumatraPDF viewer is active if they accidentally scan in a barcode, if so, have it play an alert sound to alert them that they are still on the current scanned in barcode. I hope that cleared up things.
  25. @TheXman Well, I tried using HotKeySet and scanned in the barcode and the message did alert. So the scan with "Enter" is correct. However, I can't get it to actually send the enter key when the viewer is not active. SumatraPDF is just pdf viewer. HotKeySet("{ENTER}", checkBrowser) Func checkBrowser()    Msgbox(0,"Debug", "Enter is detected")    If WinActive("SumatraPDF") Then       SoundPlay("error.wav")    Else       Send("{ENTER}")    EndIf EndFunc
×
×
  • Create New...