Help with Search Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
MonuKashyap
Posts: 33
Joined: 06 Jun 2016, 21:32

Help with Search

09 Feb 2018, 01:51

I am making simple search program, and i m trying to kill current busy thread, and dont no how to do that.
any help please?

here's my script, in this script i want to make work the stop button.

Code: Select all

gui, font, s20
gui, add, edit
gui, add, button, gfind vSrchButton default, Find
gui, show
return

Find:
count++
if count=1
Guicontrol,, SrchButton, Stop
loop
{
tooltip % a_Index "`n" count
if count=2
Break
}
msgbox done.
Guicontrol,, SrchButton, Find
Return

esc::
guiclose:
exitapp
User avatar
divanebaba
Posts: 744
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Help with Search

09 Feb 2018, 02:47

MonuKashyap wrote:... kill current busy thread ...
Could be helpful to know, what kind of thread you want to close.
Is it an AHK-tread? Is it same script you want to close, while you are reloading?
Or a damned game you want to play instead of doing usefull things? :mrgreen: :mrgreen:
[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.

ADVERTISING: Patent pending strip accumulator - süper advanced technology - priceless inexpensive, space-saving, energy efficient - Patent priority for sale.
MonuKashyap
Posts: 33
Joined: 06 Jun 2016, 21:32

Re: Help with Search

09 Feb 2018, 06:37

divanebaba wrote:
MonuKashyap wrote:... kill current busy thread ...
Could be helpful to know, what kind of thread you want to close.
Is it an AHK-tread? Is it same script you want to close, while you are reloading?
Or a damned game you want to play instead of doing usefull things? :mrgreen: :mrgreen:
I Want to kill the loop by stop button which is present in the same script
and
if you didn't understand anything, simply run the script then you will definitely understand what i want to do.
and thanks for reply
Odlanir
Posts: 274
Joined: 20 Oct 2016, 08:20

Re: Help with Search

09 Feb 2018, 15:07

A workaround:

Code: Select all

WM_LBUTTONDOWN() {
    global count
    If (A_Gui) {
        GuiControlGet,text,,SrchButton     
        if ( text = "Stop")
            count = 2
    }
}

gui, font, s20
gui, add, edit
gui, add, button, gfind vSrchButton default, Find
gui, show
return

Find:
count++
if count=1
Guicontrol,, SrchButton, Stop
OnMessage(0x0201, "WM_LBUTTONDOWN")
loop
{
tooltip % a_Index "`n" count
if count=2
Break
}
msgbox done.
tooltip,
Guicontrol,, SrchButton, Find
Return
____________________________________________________________________________
Windows 7 Home Premium 64 bit - Autohotkey v1.1.24.02 64-bit Unicode
MonuKashyap
Posts: 33
Joined: 06 Jun 2016, 21:32

Re: Help with Search

11 Feb 2018, 01:00

Odlanir wrote:A workaround:

Code: Select all

WM_LBUTTONDOWN() {
    global count
    If (A_Gui) {
        GuiControlGet,text,,SrchButton     
        if ( text = "Stop")
            count = 2
    }
}

gui, font, s20
gui, add, edit
gui, add, button, gfind vSrchButton default, Find
gui, show
return

Find:
count++
if count=1
Guicontrol,, SrchButton, Stop
OnMessage(0x0201, "WM_LBUTTONDOWN")
loop
{
tooltip % a_Index "`n" count
if count=2
Break
}
msgbox done.
tooltip,
Guicontrol,, SrchButton, Find
Return


The whole code works!! But Only First Time.. AND with click only (need enter button too)
Then it needs to reload.
any more help??
MonuKashyap
Posts: 33
Joined: 06 Jun 2016, 21:32

Re: Help with Search  Topic is solved

11 Feb 2018, 02:46

Well,, Thank you all for replies.. I really appreciate your help and suggestion.
and
I found my solution in this code,-

gui, font, s20
gui, add, edit
gui, add, button, x10 y110 w100 gfind vSrchButton Default, Find
gui, add, button, x10 y110 w100 gstop vStopButton Default, Stop
Guicontrol, hide, StopButton
Guicontrol, disable, StopButton
gui, show
return

Stop:
Stop:=1
Guicontrol, hide, StopButton
Guicontrol, disable, StopButton
Guicontrol, Show, Srchbutton
Guicontrol, Enable, Srchbutton
tooltip
Return

Find:
Guicontrol, hide, Srchbutton
Guicontrol, disable, Srchbutton
Guicontrol, Show, StopButton
Guicontrol, Enable, StopButton
Stop:=0
loop
{
tooltip % a_Index "`n" count
if Stop
Break
}
msgbox done.
Return

esc::
guiclose:
exitapp



I found this trick by spending more time on goolge, ahk forum, and many more experiments...
Hope this trick helps you too for some task in future..
Thanks once again to everyone.
garry
Posts: 1459
Joined: 22 Dec 2013, 12:50

Re: Help with Search

11 Feb 2018, 03:39

thank you all for help
@MonuKashyap , this is your script below ( just used CODE for better readable and little modified as example for me to keep it ) , the variable 'count' was empty , can use if wanted ( here it's same as a_index )
added guicontrol for Edit
as title = How to start and break a loop with ONE button

Code: Select all

;-- https://autohotkey.com/boards/viewtopic.php?f=5&t=43986
;-- test start / stop break a loopX & GUI example

;- example GUI,2: / not needed to write '2:' if define first as 'NEW'
;- GUI,2: New,, Example   ;- only write once '2:'
#warn
Setworkingdir,%a_scriptdir%
count:=0

Gui,2: default
gui,2: font, s20
gui,2: add, edit , vED1 right cGray
gui,2: add, button, x10  y110 w100 gStart vStartButton Default, Start
gui,2: add, button, x10  y110 w100 gStop  vStopButton  Default, Stop

gui,2: add, button, x150 y110 w160 gCalc center,Calculator

Guicontrol,2: hide   , StopButton
Guicontrol,2: disable, StopButton
gui,2: show,,Loop_Test
return

calc:
run,calc
return

Stop:
Stop:=1
Guicontrol,2: hide   , StopButton
Guicontrol,2: disable, StopButton
Guicontrol,2: Show   , Startbutton
Guicontrol,2: Enable , Startbutton
tooltip
Return

Start:
Guicontrol,2: hide   , Startbutton
Guicontrol,2: disable, Startbutton
Guicontrol,2: Show   , StopButton
Guicontrol,2: Enable , StopButton
Stop:=0
loop
{
; do something until STOP
count++
Guicontrol,2:,ed1,%count%
tooltip, % "A_Index=" . a_Index . "`nCount=" . count
if Stop
  Break
}
msgbox, 262208,STOP ,Loop stopped`nYou can start again ( if wanted ),3
Return

esc::
2guiclose:
exitapp
Odlanir
Posts: 274
Joined: 20 Oct 2016, 08:20

Re: Help with Search

11 Feb 2018, 04:23

With minor mods the code I gave you works all the time, also with enter key.

Code: Select all

#SingleInstance, force
#NoEnv
#Persistent
WM_LBUTTONDOWN() {
    global count
    If (A_Gui) {
        GuiControlGet,text,,SrchButton     
        if ( text = "Stop")
            count = 2
    }
}
gui, font, s20
gui, add, edit
gui, add, button, gfind vSrchButton default, Find
gui, show
return

Find:
count++
if count=1
Guicontrol,, SrchButton, Stop
OnMessage(0x0201, "WM_LBUTTONDOWN"), OnMessage(0x100, "WM_LBUTTONDOWN")
loop
{
tooltip % a_Index "`n" count
    if (count=2) {
        count := 0
        Break
    }
}
msgbox done.
tooltip,
Guicontrol,, SrchButton, Find
Return
____________________________________________________________________________
Windows 7 Home Premium 64 bit - Autohotkey v1.1.24.02 64-bit Unicode
garry
Posts: 1459
Joined: 22 Dec 2013, 12:50

Re: Help with Search

11 Feb 2018, 09:33

@Odlanir , thank you again for the good short example

Return to “Ask For Help”

Who is online

Users browsing this forum: Bugz000, DavidBevi, Imjohn, ozz, Scr1pter, TAC109, YoucefHam and 25 guests