0

i got a trouble in my python function, i call a exe program what return result i use to excute in python code to detect the system mouse shape in the screen. The exe function will return diffrent result with each mouse shape state(arrow, hand). The problem is when python function call exe, appear Windows shell contain the result i want in, i read it by:

def check():
    program = r'D:\vs project\aaaaaa\Debug\mousedetect.exe'
    with subprocess.Popen([program], stdout=subprocess.PIPE, universal_newlines=True,shell=False) as p:
        for line in p.stdout:
            print(line)

In the position the Windows shell appear, it cover the screen so the value of mouse state in screen return is wrong. So, have anyway to run the exe to take result in Window shell with that Windows shell run in background?

AlphaWolf
  • 395
  • 2
  • 7
  • 16
  • the window is likely a byproduct of `program`, which you don't show, so there's no way to help you with that. – CAB Sep 27 '16 at 15:03
  • I don't know in python subprocess call have an option is `shell=False` is what i want or not, tried it but still like before `subprocess.Popen([program], stdout=subprocess.PIPE, universal_newlines=True, shell=False)` – AlphaWolf Sep 27 '16 at 15:14
  • I used your code, replaced `program` with `'dir'`. No window pops open. – CAB Sep 27 '16 at 15:32
  • in my code: `program = r'D:\vs project\aaaaaa\Debug\mousedetect.exe'`so you mean use the program directory in that line? – AlphaWolf Sep 27 '16 at 15:38
  • No. I was saying your example code was incomplete because you did no show the value of `program`. See this answer for a possible solution; http://stackoverflow.com/a/1016651/2800918 – CAB Sep 27 '16 at 15:49
  • @CAB my complete code is edited in post – AlphaWolf Sep 27 '16 at 15:52
  • Did the other post I referenced work out for you? – CAB Sep 27 '16 at 23:55
  • Perhaps you can change mousedetect.exe to hide its own window, or to not create one at all. I have no other idea. Best of luck to you. – CAB Sep 28 '16 at 17:20

0 Answers0