Sign in to follow this  
Followers 0
horohoro

WinActivate() doesent work while in a loop

3 posts in this topic

#1 ·  Posted (edited)

Help, help i need help my script doesent activate any window using WinActivate() function what is wrong or what is hapenning? Here is my codes:

#include <GuiConstantsEx.au3>

opt("GUIOnEventMode", 1) ; Change to OnEvent mode

;Creaza formular si fal vizibil
$frmHome = GuiCreate("Bla Bla my title", 370, 49, 500, 600)
GuiSetState(@SW_SHOW, $frmHome)

;Creeaza textbox,label,si buton
$lbl1 = GuiCtrlCreateLabel("Executa operatia: ", 10, 11, 100, 20) ;Label1
$txtCommand = GuiCtrlCreateInput("", 100, 11, 170, 20) ;TextBox1 (input text)
$cmdExecute = GuiCtrlCreateButton("Ruleaza", 280, 11, 80, 20) ;Button1 (executarea scriptului)

;Seteaza un tooltip pentru textbox
GuiCtrlSetTip($txtCommand, "Bla bla my hint ...", "", 1,1)   

;Seteaza evenimentele formului, butonului
GuiSetOnEvent($GUI_EVENT_CLOSE, "Form1_Exit", $frmHome) ;Exit 
GuiCtrlSetOnEvent($cmdExecute, "cmdExecute_Click")

;Incuie obiectele
Func LockInput($state)
    if $state Then
        GuiCtrlSetState($txtCommand, $GUI_DISABLE)
        GuiCtrlSetState($cmdExecute, $GUI_DISABLE)
        Else
        GuiCtrlSetState($txtCommand, $GUI_ENABLE)
        GuiCtrlSetState($cmdExecute, $GUI_ENABLE)
    EndIf
EndFunc

;Evenimentul buton apasat
Func cmdExecute_Click()
    $Text = TextInput()
    $TextChunk = stringsplit($Text, " ")
    
    ;if $Text Then
           WinActivate("[REGEXPTITLE:doesent work while]") ; HERE IS THE BUG! DOESENT ACTIVATE ANY WINDOW ;ANYMORE!
    ;endif
    
EndFunc

;Evenimentul 'x' apasat pe form
Func Form1_Exit()
    Exit
EndFunc

;Returneaza textul textboxului
Func TextInput() 
    return GUICtrlRead($txtCommand)
EndFunc

while 1
wend

If i remove that loop and i try only the function cmdExecute_Click it will activate the window. Respect all the talented ppl

Edited by horohoro

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Well we're going to have to keep it in mind that I'm pretty stupid sometimes.

;Evenimentul buton apasat
Func cmdExecute_Click()
    $Text = TextInput()
    $TextChunk = stringsplit($Text, " ")  
    ;if $Text Then
           WinActivate("[REGEXPTITLE:doesent work while]") ; HERE IS THE BUG! DOESENT ACTIVATE ANY WINDOW ;ANYMORE!
    ;endif
EndFunc

The code above does in fact do nothing when I click the button.

However, if I change "[REGEXPTITLE:doesent work while]" to "Gmail" the code brings up my first browser reference to Gmail or activates my browser window that points to Gmail.

All that I am saying is that the problem doesn't seem to be the WinActivate() function, but instead the problem is most likely the variable you are trying to use inside the function.

Below is a list of codes that all brought up my Gmail window, when the button was pressed:

WinActivate("[REGEXPTITLE:Gmail]") ; I have a browser pointing to Gmail

WinActivate("[REGEXPTITLE:Chrome]") ; I am using the Chrome browser to view the Gmail page

WinActivate("Gmail") ; this also works because "Gmail - Inbox" is at the begining of the title of the window

These codes do nothing when the button is pressed:

WinActivate("[REGEXPTITLE:doesent work while]")

WinActivate("[REGEXPTITLE:songersoft]")

Remember that WinActivate() is case sensitive, there may be away to force match to lowercase using mode -1 to -3 but I've never done that and I cannot be sure how that works at the moment.

Thank you for helping me learn about special descriptions in the window title parameter.

I'm not sure how to help you, good luck.

removing the loop seems to remove the main loop, which gives users no chance to enter data. If somehow removing the loop brings up the window you are trying for on the first and final run through, then I would assume that it is a glitch that cannot be counted on to give the same results on just any computer at any time.

I hope that I am not a problem, I read that I shouldn't try to help someone if I don't know what I'm talking about.

Edited by songersoft

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I have problems with my OS. I got a virus 'W32/Sality.' and my computer is running v slowly (CPU 100% usage, RAM all 512 occupied) and i need to format it now. Im sure the virus is the problem. Thanks u helped me alot since u told me that the WinActivate() worked at you (activated ur gmail,chrome browser). have a nice day :)

Edited by horohoro

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  
Followers 0