Jump to content
undcover

Show my form, only when certain controls are visible.

Recommended Posts

Posted (edited)

Hello, I'm automating part of the note taking ability of my old bad POS, I managed to do much of the heavy lifting in the past weeks, I can finally do everything i want and more.

Now I have a form with two buttons that expand the form to show a note taking beast that can lets us escape the hell of the one way editing the POS actually support (no cursor just delete. want to change the time on that order better delete everything and start the note from scratch, well not anymore)

Now i'm stuck, my form shows up as two buttons over the POS window, however I need it to go away when I minimized the POS or switch to a different page or application, I was able to do so by doing a while loop, it worked badly as it will repeat the show command infinitely and if i break the loop then there's no way to restart the loop if the user didn't interact with the buttons directly.

I have many ways I could know when controls are visible and it worked, I just don't have a way of constantly checking for this without straining the CPU, I know if I work it somehow I could do a while loop that can work, but it'll be CPU intensive. (Bad POS entails BAD PC)

Should I make another form that does the loop? can I make the loop slower ?

I'm using  VB.net VS 2017 with AutoitX dll.

EDIT: Hello anyone who searched for this, if you're and idiot like me and forgot that Timers exist then this will jog your memory

 

Add a timer to your form, set the timer for 1 sec intervals (dealers choice)

start your timer (within form load or manually)

Timer1.start()

then double click the timer to create a Timer tick (for my case the control visibility test i want to make each second)

it should look something like this :

    Private Sub timer1_Tick(sender As Object, e As EventArgs) Handles timer1.Tick
        dim visibleform = ait.ControlCommand("my app", "", "[NAME:wacontact]", "IsVisible", "")
        If visibleform = 0 Then
            Me.Hide()
    ElseIf visibleform = 1 And Me.Visible = False Then ' to prevent the timer ticks from interupting any sendkeys or something we put two conditions.
            Me.Show()
        End If
    End Sub

remarks: ait. is the call I set for Autoit DLL.
 

 

 

Edited by undcover
Solved it myself. showing how for future searchers.

Share this post


Link to post
Share on other sites

If i understood correctly, you could check the Z order of the window.

Check the POS window is minimized, if it is, hide the buttons, else, show.

There may be more than 2 ways of doing this.


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
10 minutes ago, careca said:

If i understood correctly, you could check the Z order of the window.

Check the POS window is minimized, if it is, hide the buttons, else, show.

There may be more than 2 ways of doing this. 

I have so many ways to check if the window is minimized or the control hidden, It works fine... my problem is with constantly checking that state and adjusting my form shown, hidden status accordingly. (the app has no windows)

every loop i do ends up crashing.

Share this post


Link to post
Share on other sites
Public Class Form2
    Dim ait As New AutoItX3
    Public visibleform

    Function firstloop()
        visibleform = ait.ControlCommand("mytest app", "", "[NAME:wacontact]", "IsVisible", "")
        If visibleform = 1 And Form1.Visible = True Then
            Form1.Hide()
        End If
        secondloop()
    End Function
    Function secondloop()
        visibleform = ait.ControlCommand("mytestapp", "", "[NAME:wacontact]", "IsVisible", "")
        If visibleform = 0 And Form1.Visible = False Then
            Form1.Show()
        End If
        firstloop()
    End Function
    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        firstloop()
    End Sub
End Class

This self made loop didn't work for me either, but should give you an idea of my problem.

Share this post


Link to post
Share on other sites

Only now i noticed this is autoitX.

I was thinking about the "regular" autoit.

Sry cant help with this.


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

No worries just solved it, it was way easier than i thought i just had a brain freeze for few hours.

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Atrax27
      I have a webpage that I would like to Focus the Input on a particular field, which is not automatically set as the initial input.
       
      Website:
      https://fiscaloffice.summitoh.net/PropertyTaxValues/PayTaxCC.htm
       
      I want to just simply use the Send(“154xxx”) into the “Parcel” field, then Send(“{ENTER}”) without cycling through tab presses each time before getting to the correct inputbox, where number of tab press numbers might change depending on a few things (using either IE, chrome, etc). On most websites I try this with, the “Login ID” field is the first one that the cursor jumps to so all I do is just start a Send command, but here I can’t do that since it’s not the initial cursor location.
       
      I’ve read a few things on the forums about “_WinAPI_SetFocus” but that appears to work on AutoIT generated form fields only (see below code), I don’t know how to translate it for website use, thanks for any help!
       
      #include <GUIConstantsEx.au3> #Include <WinAPI.au3>   $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput("", 10, 10, 400, 20) GUICtrlCreateButton("Test", 10, 100, 80, 30) GUICtrlSetState(-1, $GUI_FOCUS)   GUISetState() Sleep(5000) _WinAPI_SetFocus(ControlGetHandle("Test", "", $hInput)) While 1     Switch GUIGetMsg()         Case $GUI_EVENT_CLOSE             Exit     EndSwitch WEnd  
         
    • By paradox109
      Hello, 
      I have A simple question about http request. What would be the fastest way to send mupltiple http request at the same time with autoit? The only way i figured  out was to to start multiple processes. This way works fine but its not really a good way. What user would like to see 15 processes running in the background at the same time. I know multithread is also not available in autoit.
    • By BlueSkyMemory
      Hello guys! I'm a rookie in AutoIt lol.
      I've tried to looking up in MSDN and the UDFs, but it can only get the GUID of a usual partition and with the GUID to control it. Now I have no ways😥.
      Thanks a lot for your help!
    • By Zaoka
      Hi guys,
      i have simple report in PowerPivot that shows Orders (Values) by Regions (Row) and Weeks (Columns). In Filter field is WeekDAYS (Monday,Tuesday,Wednesday,Thursday etc )
      how to filter WeekDAYS Filed on WEEKDAYYesterday with autoit ?
      my junky try
      #include <Date.au3> #include <Excel.au3> Local $sWEEKDAYYesterday = _DateDayOfWeek(@WDAY-1) Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, "C:\Users\.......\Orders.xlsb") Sleep (5000) $oExcel.ActiveWorkbook.RefreshAll Sleep (5000) $oExcel.Application.Sheets("Sheet1").PivotTables("PivotTable1").PivotFields("WeekDAYS").PivotFilters($sWEEKDAYYesterday)  
      Error result
      $oExcel.Application.Sheets("PivotTable1").PivotTables("PivotTable1").PivotFields("WeekDAYS").PivotFilters($sWEEKDAYYesterday) $oExcel.Application^ ERROR  
    • By silber
      Probably something simple, but i'm trying to create a trigger that happens if the user is idle for too long (in this example 10 seconds).
      #include <Timers.au3> While 1 $CurrIdleTime = _Timer_GetIdleTime() Switch $CurrIdleTime Case $CurrIdleTime >= 10001 MsgBox(64,"Current Idle Time",$CurrIdleTime) Exit EndSwitch WEnd So if I run this and don't press anything the message box will trigger in 10 seconds, but if press anything the message box will immediately trigger.  The $CurrIdleTime given to me in the message box always reads 0 in the second scenario, so I'm not understanding why the case would trigger if it's clearly not greater than or equal to 10001.
      Does moving the mouse/pressing a key cause _Timer_GetIdleTime() to very quickly go to another value than zero?  I tried specifying Number($CurrIdleTime), but it didn't make any difference.
      Any insight would be appreciated, thank you.
×
×
  • Create New...