Jump to content

Recommended Posts

Posted

Hi,

Firstly I am a newbie at AutoIT and my experience so far is this is awsome.

I have been tearing my hair out over this one.

I have 2 scripts that both work on their own:

1.

#RequireAdmin
Opt("TrayIconHide", 1)
#include <Misc.au3>
If _Singleton("csvp.exe", 1) = 0 Then
Exit
Else
While 1
  WinWaitActive("Print")
  If WinExists("POS / Sell") Then
   BlockInput(1)
   Send("{ENTER}")
   Sleep(100)
   BlockInput(0)
  EndIf
WEnd
EndIf

2.

#RequireAdmin
Opt("TrayIconHide", 1)
#include <Misc.au3>
If _Singleton("csvp.exe", 1) = 0 Then
   Exit
Else
   While 1
   If StringInStr(WinGetText("POS / Sell", ""), "Print - POS / Sell") > 0 Then
   BlockInput(1)
   Send("{ENTER}")
   Sleep(100)
   BlockInput(0)
   EndIf
   WEnd
EndIf

I am trying to combine the 2 into 1 file. I have yet to be able to get it to work when combined. I have tried many ways but mostly based around this:

#RequireAdmin
Opt("TrayIconHide", 1)
#include <Misc.au3>
If _Singleton("csvp.exe", 1) = 0 Then
   Exit
Else
   While 1
   WinWaitActive("Print")
   If WinExists("POS / Sell") Then
   BlockInput(1)
   Send("{ENTER}")
   Sleep(100)
   BlockInput(0)
   EndIf
   WEnd
  
   While 1
   If StringInStr(WinGetText("POS/ Sell", ""), "Print - POS / Sell") > 0 Then
   BlockInput(1)
   Send("{ENTER}")
   Sleep(100)
   BlockInput(0)
   EndIf
   WEnd
EndIf

Can anyone guide me in the right direction please?

Posted

Check if this works for you:

#RequireAdmin
Opt("TrayIconHide", 1)
#include <Misc.au3>

If _Singleton("csvp.exe", 1) <> 0 then
While 1
WinWaitActive("Print")
If WinExists("POS / Sell") or StringInStr(WinGetText("POS / Sell", ""), "Print - POS / Sell") then 
BlockInput(1)
   Send("{ENTER}")
   Sleep(100)
   BlockInput(0)
   EndIf
WEnd
else
Exit
EndIf

You simply can't combine them like that, since the script will be stuffed in an infinite loop.

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Posted

Doesn't work sorry.

I think it has to do with the WinWaitActive("Print") line. That is only needed for the first script. Not needed at all for the second script.

Posted

Thank you for your help, you showed an alternative method to combine that I hadn't tried, and with some small tweaking, I got it working as intended. Some times we jut need a fresh pair of eyes on it.

For those interested, here is what worked:

#RequireAdmin
Opt("TrayIconHide", 1)
#include <Misc.au3>
If _Singleton("csvp.exe", 1) <> 0 Then
   While 1
   If WinWaitActive("POS / Sell") And WinExists("Print") Then
   BlockInput(1)
   Send("{ENTER}")
   Sleep(100)
   BlockInput(0)
   ElseIf StringInStr(WinGetText("POS / Sell", ""), "Print - POS / Sell") Then
   BlockInput(1)
   Send("{ENTER}")
   Sleep(100)
   BlockInput(0)
   EndIf
   WEnd
Else
   Exit
EndIf

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
  • Recently Browsing   0 members

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