PlkMarudny Posted April 29, 2018 Share Posted April 29, 2018 I use a simple script (below) to display a webpage that takes a selected text as a parameter, when the "^q" keystroke is pressed. Unfortunately, when an user open 3 windows using he script below, Autoit hangs. That's ok, I tried to keep only one window open, closing the previously opened window. But it turned out that always the newly opened window is closed, despite using the handle to the previous window, as confirmed by the console output ... Is there any error in the script? expandcollapse popup#include <GUIConstantsEx.au3> #include <IE.au3> #include <WindowsConstants.au3> #include <StringConstants.au3> ;Local $old_clipboard HotKeySet ("^q", "gettext") While 1 WEnd Func gettext () Local Static $another_handle $old_clipboard = ClipGet () Send ("^c") $current_clipboard = ClipGet () $width = 460 $height = 580 ConsoleWrite( $another_handle & @CRLF ) If $another_handle <> 0 Then WinClose($another_handle) EndIf Local $oIE = _IECreateEmbedded() $another_handle = GUICreate("example", $width, $height, _ (@DesktopWidth - $width) / 2, (@DesktopHeight - $height) / 2, _ $WS_EX_TOOLWINDOW + $WS_CLIPSIBLINGS + $WS_OVERLAPPED + $WS_SYSMENU + $WS_EX_TOPMOST + $WS_EX_STATICEDGE) ConsoleWrite( $another_handle & @CRLF ) GUICtrlCreateObj($oIE, 0, 0, $width, $height) GUICtrlSetColor(-1, 0xff0000) GUISetState(@SW_SHOW) ;Show GUI _IENavigate($oIE, StringFormat("https://duckduckgo.com/?q=%s", StringStripWS(ClipGet (), $STR_STRIPLEADING + $STR_STRIPTRAILING))) ClipPut ($old_clipboard) _IEAction($oIE, "stop") ; Waiting for user to close the window While 1 Local $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() EndFunc Func CheckError($sMsg, $iError, $iExtended) If $iError Then $sMsg = "Error using " & $sMsg & " button (" & $iExtended & ")" Else $sMsg = "" EndIf GUICtrlSetData($g_idError_Message, $sMsg) EndFunc ;==>CheckError Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now