33#include < WindowsConstants.au3>
44#include < GUIConstants.au3>
55#include < GuiMenu.au3>
6+ #include < Misc.au3>
67#include " _WV2_ExtensionPicker.au3"
78
89; Web_Demo_v1.4.2_MASTER.au3
@@ -15,6 +16,8 @@ Global $oWeb, $oJS
1516Global $oMyError = ObjEvent (" AutoIt.Error" , " _ErrFunc" ) ; COM Error Handler
1617Global $hGUI , $Bar
1718Global $g_sProfilePath = @ScriptDir & " \UserDataFolder"
19+ Global $hDLL = DllOpen (" user32.dll" )
20+ Global $g_bURLFullSelected
1821
1922_MainGUI()
2023
@@ -58,17 +61,27 @@ Func _MainGUI()
5861 ; Navigate to a good demo page
5962 $oWeb .Navigate(" https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population" )
6063
64+ GUIRegisterMsg ($WM_COMMAND , " WM_COMMAND" ) ; ; Register the WM_COMMAND message to handle URL FullSelection
65+
6166 GUISetState (@SW_SHOW , $hGUI )
6267
63- Local $iMsg , $sOldURL , $sCurURL
68+ Local $iMsg
6469
6570 While 1
6671 $iMsg = GUIGetMsg ()
6772 Switch $iMsg
6873 Case $GUI_EVENT_CLOSE
6974 Exit
70- Case $Bar .Navigation, $Bar .Address
75+ Case $Bar .Navigation
7176 _NavButton()
77+ Case $Bar .Address
78+ If _IsPressed(" 0D" , $hDLL ) Then ; ENTER key
79+ _NavButton(" Navigate" )
80+ _NavButton()
81+ Else
82+ AdlibRegister (" _SetNavigateToReload" , 700 )
83+ EndIf
84+
7285 Case $Bar .GoBack
7386 $oWeb .GoBack()
7487 Case $Bar .GoForward
@@ -79,12 +92,11 @@ Func _MainGUI()
7992 _ShowFeaturesMenu()
8093 EndSwitch
8194
82- $sCurURL = GUICtrlRead ( $Bar .Address )
83- If $sCurURL <> " " And $sOldURL <> $sCurURL Then
84- $sOldURL = $sCurURL
85- _NavButton( " Navigate " )
95+ ; 1. Διαχείριση Full Selection (Focus )
96+ If $g_bURLFullSelected Then
97+ $g_bURLFullSelected = False
98+ GUICtrlSendMsg ( $Bar .Address, $EM_SETSEL , 0 , - 1 )
8699 EndIf
87-
88100 WEnd
89101EndFunc ; ==>_MainGUI
90102; ---------------------------------------------------------------------------------------
@@ -130,6 +142,8 @@ Func _NavButton($sSetState = Default) ; Set or executes the action of Navigation
130142 GUICtrlSetData ($Bar .Navigation, ChrW (59153 ))
131143 GUICtrlSetTip ($Bar .Navigation, " Stop" )
132144 Case " Navigate"
145+ If $sState = $sSetState Then Return
146+ AdlibUnRegister (" _SetNavigateToReload" ) ; UnRegister it (if exist)
133147 GUICtrlSetData ($Bar .Navigation, ChrW (59217 ))
134148 GUICtrlSetTip ($Bar .Navigation, " Navigate" )
135149 EndSwitch
@@ -177,13 +191,33 @@ Func _Web_GoTo($sURL) ; Navigates to a URL or performs a Google search if the in
177191EndFunc ; ==>_Web_GoTo
178192; ---------------------------------------------------------------------------------------
179193Func _ExitApp() ; OnAutoItExitRegister
194+ DllClose ($hDLL )
180195 If IsObj ($oWeb ) Then $oWeb .Cleanup()
181196EndFunc ; ==>_ExitApp
182197; ---------------------------------------------------------------------------------------
183198Func _ErrFunc($oError ) ; COM Error Handler
184199 ConsoleWrite (' @@ Line(' & $oError .scriptline & ' ) : COM Error Number: (0x' & Hex ($oError .number , 8 ) & ' ) ' & $oError .windescription & @CRLF )
185200EndFunc ; ==>_ErrFunc
186201; ---------------------------------------------------------------------------------------
202+ Func WM_COMMAND($hWnd , $iMsg , $wParam , $lParam ) ; Register the WM_COMMAND message to handle URL FullSelection
203+ #forceref $hWnd, $iMsg
204+ Local Static $hidURL = GUICtrlGetHandle ($Bar .Address)
205+ Local $iCode = BitShift ($wParam , 16 )
206+ If $lParam = $hidURL Then
207+ Switch $iCode
208+ Case $EN_SETFOCUS
209+ $g_bURLFullSelected = True
210+ Case $EN_CHANGE
211+ _NavButton(" Navigate" )
212+ EndSwitch
213+ EndIf
214+ Return $GUI_RUNDEFMSG
215+ EndFunc ; ==>WM_COMMAND
216+ ; ---------------------------------------------------------------------------------------
217+ Func _SetNavigateToReload()
218+ _NavButton(" Reload" )
219+ AdlibUnRegister (" _SetNavigateToReload" ) ; unregister itself.
220+ EndFunc ; ==>_SetNavigateToReload
187221#EndRegion ; === MainGUI ===
188222
189223#Region ; === CONTEX MENUS ===
@@ -285,7 +319,8 @@ EndFunc ;==>_ShowFeaturesMenu
285319#Region ; === EVENTS (v1.4.2 Direct) ===
286320; ---------------------------------------------------------------------------------------
287321Func Web_OnURLChanged($sURL )
288- GUICtrlSetData ($Bar .Address, $sURL )
322+ #forceref $sURL
323+ ; ~ GUICtrlSetData($Bar.Address, $sURL)
289324EndFunc ; ==>Web_OnURLChanged
290325; ---------------------------------------------------------------------------------------
291326Func Web_OnTitleChanged($sTitle )
@@ -303,6 +338,7 @@ Func Web_OnNavigationCompleted($bSuccess, $iError)
303338 #forceref $bSuccess, $iError
304339 $oWeb .ExecuteScript(" finalizeProgress();" )
305340
341+ GUICtrlSetData ($Bar .Address, $oWeb .GetSource())
306342 _NavButton(" Reload" )
307343
308344 ; Using the new Getters for dynamic UI
@@ -336,18 +372,18 @@ Func Web_OnContextMenuRequested($sLink, $iX, $iY, $sSelection)
336372 ConsoleWrite (" $sTag=" & $sTag & @CRLF )
337373
338374 If $sTag = " TABLE" Then
339- _GUICtrlMenu_AddMenuItem($hMenu , " 📥 Export this Table to CSV" , 4001 )
375+ _GUICtrlMenu_AddMenuItem($hMenu , " 📥 Export this Table to CSV" , 4001 )
340376 _GUICtrlMenu_AddMenuItem($hMenu , " " ) ; separator
341377 EndIf
342378
343- _GUICtrlMenu_AddMenuItem($hMenu , " Save Form Map to JSON File" , 3010 )
344- _GUICtrlMenu_AddMenuItem($hMenu , " Fill Form from JSON File" , 3011 )
379+ _GUICtrlMenu_AddMenuItem($hMenu , " 💾 Save Form Map to JSON File" , 3010 )
380+ _GUICtrlMenu_AddMenuItem($hMenu , " 🗃️ Fill Form from JSON File" , 3011 )
345381 _GUICtrlMenu_AddMenuItem($hMenu , " " ) ; separator
346382
347- _GUICtrlMenu_AddMenuItem($hMenu , " Copy Text Selection" , 4010 )
383+ _GUICtrlMenu_AddMenuItem($hMenu , " 📋 Copy Text Selection" , 4010 )
348384 If $sLink <> " " Then _GUICtrlMenu_AddMenuItem($hMenu , " Copy Link URL" , 4011 )
349385 _GUICtrlMenu_AddMenuItem($hMenu , " " ) ; separator
350- _GUICtrlMenu_AddMenuItem($hMenu , " Inspect Element" , 4020 )
386+ _GUICtrlMenu_AddMenuItem($hMenu , " 🔬 Inspect Element" , 4020 )
351387
352388 Local $iCmd = _GUICtrlMenu_TrackPopupMenu($hMenu , $hGUI , - 1 , - 1 , 1 , 1 , 2 )
353389 Switch $iCmd
0 commit comments