Jump to content
Sign in to follow this  
remin

GuiCtrlRead and GUICtrlSetData values not updated

Recommended Posts

remin

I created a search GUI with an InputBox and a Button to empty the input box.

I read the inputbox using GuiCtrlRead and empty the input box using GUICtrlSetData.

When I click a search button or click the "empty inputbox" button, everything works fine.

However after having done the 1st search and I click again on the search button

or whatever other button the input box field is not updated 

GUICtrlRead($RWSearch)  --> gives a value '0'

What did I wrong?

Same thing when I empty the input box.

The 1st time it works well.

When I empty the inputbox after having done a search it doesn't

work anymore. Nothing happens.

My search GUI is always on TOP so I don't reuse the hotkey between searches.

(The GUI is not deleted after a search), 

 

My code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#include <GuiButton.au3>
#include <Constants.au3>

HotKeySet("^4", "searchmenu")


While 1
    Sleep(10000)
WEnd

Func searchmenu()

global $url
Send("^c")
$InEditBox = ClipGet()

;========GUI=============
 $Form5 =         GUICreate("Search Menu", 345, 410, 100, 100)
 $RWSearch =      GUICtrlCreateInput($InEditBox,                      16,  10, 270, 25)
 $clipc =         GUICtrlCreateButton("x",                           300,  10,  15, 20)
 $textGoogle  =   GUICtrlCreateLabel("Google:",                       20,  50, 100, 20)
 $bsearch =       GUICtrlCreateButton("Search",                      110,  50,  60, 20)
 $bimages =       GUICtrlCreateButton("Images",                      175,  50,  60, 20)

GUISetState(@SW_SHOW)
;========GUI=============

While 1
$nMsg = GUIGetMsg()
Switch $nMsg

   Case $GUI_EVENT_CLOSE
        GuiDelete($Form5)
        ExitLoop

      Case $clipc
           ; empty inputbox
           GUICtrlSetData($RWSearch, "")

      Case $bsearch
           ; search text in google 
           $RWSearch = GUICtrlRead($RWSearch)
           $RWSearch = StringRegExpReplace($RWSearch, "(\s+)", "+")
           $url = "https://www.google.com/search?q=" & $RWSearch
           SearchMenuExec()

      Case $bimages
           ; search images in google
           $RWSearch = GUICtrlRead($RWSearch)
           $RWSearch = StringRegExpReplace($RWSearch, "(\s+)", "+")
           $url = "http://images.google.com/images?hl=en&q=" & $RWSearch
           SearchMenuExec()

EndSwitch
 WEnd
EndFunc

Func SearchMenuExec()
  ClipPut($url)
  ShellExecute($url) 
EndFunc
Edited by remin

Share this post


Link to post
Share on other sites
l3ill

Hi Remin,

  It is working fine for me, I did notice that every time you hit CTRL + 4 it opens a new GUI. Did you want that?

Maybe deleting the GUI after the search would solve some of the problems you are having, and the hotkey will just open anew GUI every time.

Share this post


Link to post
Share on other sites
l3ill

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#include <GuiButton.au3>
#include <Constants.au3>

HotKeySet("^4", "searchmenu")
Global $url


While 1
    Sleep(10000)
WEnd

Func searchmenu()

    Send("^c")
    $InEditBox = ClipGet()

    ;========GUI=============
    $Form5 = GUICreate("Search Menu", 345, 410, 100, 100)
    $RWSearch = GUICtrlCreateInput($InEditBox, 16, 10, 270, 25)
    $clipc = GUICtrlCreateButton("x", 300, 10, 15, 20)
    $textGoogle = GUICtrlCreateLabel("Google:", 20, 50, 100, 20)
    $bsearch = GUICtrlCreateButton("Search", 110, 50, 60, 20)
    $bimages = GUICtrlCreateButton("Images", 175, 50, 60, 20)

    GUISetState(@SW_SHOW)
    ;========GUI=============

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg

            Case $GUI_EVENT_CLOSE
                GUIDelete($Form5)
                ExitLoop
                Return 0

            Case $clipc
                ; empty inputbox
                GUICtrlSetData($RWSearch, "")
                ExitLoop
            Case $bsearch
                ; search text in google
                $RWSearch = GUICtrlRead($RWSearch)
                $RWSearch = StringRegExpReplace($RWSearch, "(\s+)", "+")
                $url = "https://www.google.com/search?q=" & $RWSearch
                SearchMenuExec()
                ExitLoop

            Case $bimages
                ; search images in google
                $RWSearch = GUICtrlRead($RWSearch)
                $RWSearch = StringRegExpReplace($RWSearch, "(\s+)", "+")
                $url = "http://images.google.com/images?hl=en&q=" & $RWSearch
                SearchMenuExec()
                ExitLoop

        EndSwitch
    WEnd
    GUIDelete()

EndFunc   ;==>searchmenu



Func SearchMenuExec()
    ClipPut($url)
    ShellExecute($url)
EndFunc   ;==>SearchMenuExec

Share this post


Link to post
Share on other sites
remin

@Billo,

Thank you for your reply.

I forgot to write in my question that my search GUI is always on TOP so I don't reuse the hotkey between searches.

(The GUI is not deleted after a search), 

(I'll update my question)

Edited by remin

Share this post


Link to post
Share on other sites
l3ill

No Problem,

  it seems to me the idea was pretty cool to be able to hotkey paste anything you've hi-lited into your search box and then hit search or image and have the gui disappear until needed again.

  anyway, thats what the one does that I posted above. just like yours with a few minor changes.

Good luck.

Share this post


Link to post
Share on other sites
remin

Tnx, but it is not what I want.

I want to keep the GUI, clicking on a button and read with every search the inputbox again.

Share this post


Link to post
Share on other sites
AutID

Maybe something like this? I tried to clean it up a bit but it still is very bad formated. Clean up whatever you dont need and remove the #includes that are useless...

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#include <GuiButton.au3>
#include <Constants.au3>

HotKeySet("^4", "searchmenu")
Global $url


While 1
Sleep(10000)
WEnd

Func searchmenu()

Send("^c")
$InEditBox = ClipGet()

;========GUI=============
$Form5 = GUICreate("Search Menu", 345, 410, 100, 100)
$RWSearch = GUICtrlCreateInput($InEditBox, 16, 10, 270, 25)
$clipc = GUICtrlCreateButton("x", 300, 10, 15, 20)
$textGoogle = GUICtrlCreateLabel("Google:", 20, 50, 100, 20)
$bsearch = GUICtrlCreateButton("Search", 110, 50, 60, 20)
$bimages = GUICtrlCreateButton("Images", 175, 50, 60, 20)
GUISetState(@SW_SHOW)
;========GUI=============

While 1
$nMsg = GUIGetMsg()
Switch $nMsg

Case $GUI_EVENT_CLOSE
GUIDelete($Form5)
Exit
Case $clipc
; empty inputbox
GUICtrlSetData($RWSearch, "")
Case $bsearch
; search text in google
$RWSearch1 = GUICtrlRead($RWSearch)
$RWSearch2 = StringRegExpReplace($RWSearch1, "(\s+)", "+")
$url = "https://www.google.com/search?q=" & $RWSearch2
SearchMenuExec()
Case $bimages
; search images in google
$RWSearch1 = GUICtrlRead($RWSearch)
$RWSearch2 = StringRegExpReplace($RWSearch1, "(\s+)", "+")
$url = "http://images.google.com/images?hl=en&q=" & $RWSearch2
SearchMenuExec()
EndSwitch
WEnd
EndFunc ;==>searchmenu



Func SearchMenuExec()
ClipPut($url)
ShellExecute($url)
EndFunc ;==>SearchMenuExec

Share this post


Link to post
Share on other sites
remin

Wow.. great thank you.

That resolved my question  :)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • Lisuter
      By Lisuter
      Hello...

      How i can write data from txt to +3 Input?
      Example:
      In txt i have:
      Michael XYZ, 21, Boston
      Olex Marshal, 17, Boston
      Alex XYZ, 19, Boston
       
      And now i want load that data to input in autoit. 

      Name          y.o          city
      [ Input1]  [Input2] [Input3]
      [ Input4]  [Input5] [Input6]
      [ Input7]  [Input8] [Input9]
       
      After load should be:
      Name               y.o            city
      [Michael XYZ]      [21]     [Boston]
      [ Olex Marshal]  [17]      [Boston]
      [ Alex XYZ]           [19]      [Boston]
       
      FileOpen("Test.txt",0)                          $aas = GUICtrlSetData($Input1, FileReadLine("Test.txt",1))             FileClose("Test.txt") But its wrong. ofcourse its load all to input 1. So now how do you load this data directly into each input separately? The comma stop sign is here. Each line is a new person
    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • ademon
      By ademon
      Hi. I can not automate the click at a button, because there are three of them exactly in the source page.
      Imagine you have this html source code:
      <div class="submit"><span class="button btnDefault"><span><input type="submit" value="Search" /></span></span></div> How could I select just one element, and do click as an action on it?
      $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@type='submit'][@value='Search']") _WD_ElementAction($sSession, $sElement, 'click') That just do not work.
      Any ideas?

    • Pricehacker
      By Pricehacker
      Hello again!
      I have tried searching for quite some time now but couldn´t find a single working way to change the class of your GUI that doesn´t include changing it manually after its compilation.
      First or "AutoIt v3 GUI" is a pretty boring name tbh and i would like to spice it up a bit, also, and more importantly, I would like to identify my windows by something other than its title as it will change depending on some factors and im using two different programs independently as multi threading isn't supported.
      Any help is appreciated! Thank you!
    • xtcislove
      By xtcislove
      Hello, 
      i have a Problem with  _WinAPI_SetLayeredWindowAttributes, everything is working as excepted if u are on Windows 7.

      But if u are on Windows 10 the transparent background of a control is not clickable anymore. 

      Could someone help?

      Please see example below, put cmd.jpg into the same folder as Example.au3

      Please see trigger.jpg to see which sections are not clickable in Windows 10 (the red dots, the green dots are clickable) on Windows 7 the red ones and green ones are clickable.
       
      The same problem occurs if i use 
       
       
      Example.au3


×