Jump to content

how to exit this command


Go to solution Solved by 232showtime,

Recommended Posts

while 1
    If WinExists("[CLASS:TFrmDocRev]") Then
        ControlClick("New Revision", "", "[CLASS:TDBEdit;INSTANCE:1]")
    EndIf

wend

I just want to click it once, dont want to exitloop, because if I exitloop, it will exit my whole script. how do i execute the command once inside the loop???

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

You can just use a variable for that :

$iTest = 0
while 1
    If $iTest = 0 AND WinExists("[CLASS:TFrmDocRev]") Then
        $iTest = 1
        ControlClick("New Revision", "", "[CLASS:TDBEdit;INSTANCE:1]")
    EndIf
wend
Link to comment
Share on other sites

  • Moderators

"its not working" should be removed from the language...

WHAT is not working? How about posting your WHOLE code, so we can better assist you in refactoring it?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

#include <HotKeySetEx.au3>
#include <MsgBoxConstants.au3>
#include <ToolTipTimer.au3>

ToolTip('Script is "Running"', 0, 0)
Global $fPaused = False

HotKeySet("{`}", "TogglePause")
HotKeySet("{F7}", "HexKey")
HotKeySet("{F6}", "Quit")
HotKeySet("{F8}", "doc")
HotKeySet("{F1}", "WC")
HotKeySetEx("{MCLICK}", "MID")
HotKeySet("{F9}", "CHECK")


local $iTest = 0

While 1

    If _IsPressed('70') = 1 Then ControlClick("DOCumentation management system", "", "[CLASS:TBitBtn;INSTANCE:3]");F1 Show Doc
    Sleep(10)
    If _IsPressed('71') = 1 Then ControlClick("DOCumentation management system", "", "[CLASS:TBitBtn;INSTANCE:2]");F2 Show Comments
    Sleep(10)
    If _IsPressed('74') = 1 Then
        WinActivate("DOCumentation management system")
        ControlClick("DOCumentation management system", "", "[CLASS:TEdit;INSTANCE:1]")
        Send("^a")
        Send("^v");F5 Search
    EndIf

    If _IsPressed('02') = 1 Then ControlClick("Revision", "", "[CLASS:TBitBtn;INSTANCE:2]");Save Revision
    Sleep(10)
    If _IsPressed('72') = 1 Then ControlClick("DOCumentation management system", "", "[CLASS:TButton;INSTANCE:2]");F3 Ref Doc Show Revision
    Sleep(10)
    If _IsPressed('73') = 1 Then ControlClick("DOCumentation management system", "", "[CLASS:TButton;INSTANCE:1]");F4 Ref Doc Show Doc
    Sleep(10)

    If WinExists("[CLASS:TFrmStatistic]") Then
        WinClose("[CLASS:TFrmStatistic]")
    EndIf

    Sleep(10)
    If WinExists("[CLASS:TFrmImport]") Then
        WinClose("[CLASS:TFrmImport]")
    EndIf

 If $iTest = 0 AND WinExists("[CLASS:TFrmDocRev]") Then
        $iTest = 1
        ControlClick("New Revision", "", "[CLASS:TDBEdit;INSTANCE:1]"); this is the line that is not working
    EndIf


    If WinExists("[CLASS:bosa_sdm_XL9]") Then ;close popup in exel like ctrl find
        WinClose("[CLASS:bosa_sdm_XL9]")
    EndIf
    Sleep(10)

WEnd

Func _IsPressed($hexKey)

    Local $aR, $bO

    $hexKey = '0x' & $hexKey
    $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
    If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
        $bO = 1
    Else
        $bO = 0
    EndIf

    Return $bO
EndFunc   ;==>_IsPressed

this one is working if i add it into the loop, even if i click on input box2 it keeps on clicking on the input box 1:

while 1     
If WinExists("[CLASS:TFrmDocRev]") Then        
 ControlClick("New Revision", "", "[CLASS:TDBEdit;INSTANCE:1]")     
EndIf 
wend

what im trying to do is control click input box 1 everytime [CLASS:TFrmDocRev] appears... is it possible??? kinda stuck here...

:mad2: :mad2: :mad2:

edit:

made another attemp again,still failed:

Local $iTest = 0
while 1
    If $iTest = 0 AND WinExists("[CLASS:CabinetWClass]") Then
        $iTest = 1
         ControlClick("[CLASS:CabinetWClass]", "", "[CLASS:DirectUIHWND;INSTANCE:1]")
    EndIf
wend
Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

yes same window

check the edit,my second attempt, when i start your code it clicks on the search box when i close the window and open it again it doesn't click on the search box anymore

Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

Of course, because your first request was I just want to click it once, so I gave you an possibility for that.

Now, I don't really understand what you want...

If you want to detect each new occurence of this window, i suggest you to work with it's handles :

Local $hWndLast, $hWnd
While 1
    If WinExists("[CLASS:TFrmDocRev]") Then
        $hWnd = WinGetHandle("[CLASS:TFrmDocRev]")
        If $hWnd <> $hWndLast Then
            $hWndLast = $hWnd
            ControlClick("New Revision", "", "[CLASS:TDBEdit;INSTANCE:1]"); this is the line that is not working
        EndIf
    EndIf
WEnd

But first, try to find the good title/class of you window..

Link to comment
Share on other sites

sorry if i confused you, cant explain well, I Will make it short this time

Like how a hotkey works press the hotkey once, command will execute once

HotKeySet("{F7}", "RunOnceInALoop")

Func RunOnceInALoop()
    If WinExists("[CLASS:CabinetWClass]") Then
         ControlClick("[CLASS:CabinetWClass]", "", "[CLASS:DirectUIHWND;INSTANCE:1]")
endif
endfunc

what im trying to achieve is while script is running in a loop, if target window exists then controlclick will execute once, and if i close and reopen the target window again control click will  execute once, everytime target window is opened

 

another example to avoid confusion, script will run every 10secs, so I got 10 secs to surf net, use calculator, wordpad, browse helpfile or anything i want until command will execute again.

while 1
    If WinExists("[CLASS:CabinetWClass]") Then
         ControlClick("[CLASS:CabinetWClass]", "", "[CLASS:DirectUIHWND;INSTANCE:1]")
    EndIf
    Sleep(10000)
wend
Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

  • Moderators

How about if you post what you did, in case someone runs into a similar issue in the future?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Solution

while 1    
 If WinExists("[CLASS:TFrmDocRev]") Then         
ControlClick("New Revision", "", "[CLASS:TDBEdit;INSTANCE:1]")
WinWaitClose  
EndIf 
wend

this is the only way i know... still need to explore..... :graduated: :graduated: :graduated:

Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...