Jump to content

How to remove blockinput(1) effect by running blockinput(0) from another autoit script ?


Recommended Posts

Have you tried using shellexecute() instead of run.

blockinput(1)
Run(@desktopdir & "autoit" & "my.exe")

It probable will not fix your problem but shellexecute() is better for running programs than run().

As for block input I think you can just set scripts to undo another dirty work as in the real programming world it would clash horribly.

sorry I cant help more.

--

James

Edited by Guest
Link to comment
Share on other sites

i can't see how shellexecute related with the solution of that problem.

and i literally didn't understand what are you trying to say with your second sentence.

may be in a simple way, i need a solution like what ctrl+alt+del does to blockinput function. some kind of override. but that override should work in another autoit script.

Edited by autoitaddicted
Link to comment
Share on other sites

2nd script (will be run by no1)

ProcessClose("1stscript.exe")

sleep(5000)

Local $PID = ProcessExists("1stscript.exe") ; Will return the PID or 0 if the process isn't found.

If $PID Then ProcessClose($PID)

Edited by Guest
Link to comment
Share on other sites

i just need to disable input (blockinput) for 5 seconds not more not less for a specific process.

sometimes, that process can fail, so i can't use blockinput(0) in the end of that specific process. because of that i need a different solution. if i use that kind of code from another script:

blockinput(1)

sleep(5000)

blockinput(0)

this also blocks the main script too, while blockinput active main script functions are blocked too.

Link to comment
Share on other sites

2nd script (will be run by no1)

ProcessClose("1stscript.exe")

sleep(5000)

Local $PID = ProcessExists("1stscript.exe") ; Will return the PID or 0 if the process isn't found.

If $PID Then ProcessClose($PID)

Not sure how this is help. Sorry, i couldn't see any connection with blockinput.

Link to comment
Share on other sites

  • Moderators

autoitaddicted,

I am having difficulty understanding your problem. If you use Run to execute your "mu.exe" file, the script continues once the app is launched - so I see no reason why a "process" "failing" would affect anything that happens later. :oops:

What are you running that requires BlockInput and the failure of which blocks the rest of the script from running? As this short snippet shows, Run does not halt the script:

ConsoleWrite("Input blocked at " & @SEC & @CRLF)
Run("notepad.exe", "")
ConsoleWrite("Continuing" & @CRLF)
Sleep(5000)
ConsoleWrite("Input unblocked at " & @SEC & @CRLF)

You see the "Continuing" appear immediately after Notepad opens and the second ConsoleWrite appears 5 secs later. :doh:

So if you want help - more details on what exactly is going on in your script please. :bye:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

autoitaddicted,

Obvious question: can you not combine the 2 scripts? No more problem then. :bye:

If not, have you thought about using some form of interscript communication so the second script can tell the first to unblock? You could use something as simple as an ini file, or just search for "+inter +script +communication" - there are many examples out there. My personal favourite is trancex's MailSlot. :oops:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

You could try something with adlibRegister in the main program.

BlockInput(1)
Run("program")
AdlibRegister("checkProcess", 100)
Func checkProcess()
   Local $PID = ProcessExists("program")
   If $PID Then
      ProcessClose($PID)
      BlockInput(0)
      AdlibUnRegister("checkProcess")
   EndIf
EndFunc

so this just keeps checking to see if the second program is finished, and if it is, then it ends the blockInput.

Link to comment
Share on other sites

You could do this-

Run this after you have compiled mu.exe

#include <winapi.au3>

$gg = GUICreate("funnytitle+[]765");no need to show this window, it'as just so you can receive a message

$WM = _WinAPI_RegisterWindowMessage("anotherfunnytitle+[]765"); get our own message number
GUIRegisterMsg($WM, "blocks")

msgbox(262144,$gg, $wm)
BlockInput(1)
sleep(9000);delay to show that block(1) is working
Run("mu.exe", "")

while 1
    sleep(90)
wend

func blocks($hW,$Msg,$lp)
    if $lp = 0 Then
        BlockInput(0)
        ;exit
    Else
        Blockinput(1)
    EndIf
EndFunc

Do something like this in mu.exe

#include <winapi.au3>
#include <sendmessage.au3>
$WH = WinGetHandle("funnytitle+[]765")
;MsgBox(262144,"handle = ",$WH,3)
$WM = _WinAPI_RegisterWindowMessage("anotherfunnytitle+[]765")
;MsgBox(262144,"$WM = ", $wm,3)
if $WH <> 0 then _SendMessage($WH,$WM,0)

But based on your first post the obvious way to do it is

blockinput(1)
sleep(5000)
blockinput(0)
run("mu.exe")

I assume though that the code you showed is not really what you want to do which is why I showed another possibility.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

You could try something with adlibRegister in the main program.

BlockInput(1) Run("program") AdlibRegister("checkProcess", 100) Func checkProcess() Local $PID = ProcessExists("program") If $PID Then ProcessClose($PID) BlockInput(0) AdlibUnRegister("checkProcess") EndIf EndFunc
so this just keeps checking to see if the second program is finished, and if it is, then it ends the blockInput.
works like a charm THANK YOU SO MUCH
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...